DGtal  1.0.0
VoronoiMap.h
1 
17 #pragma once
18 
34 #if defined(VoronoiMap_RECURSES)
35 #error Recursive header files inclusion detected in VoronoiMap.h
36 #else // defined(VoronoiMap_RECURSES)
37 
38 #define VoronoiMap_RECURSES
39 
40 #if !defined VoronoiMap_h
41 
42 #define VoronoiMap_h
43 
45 // Inclusions
46 #include <iostream>
47 #include <vector>
48 #include <array>
49 #include "DGtal/base/Common.h"
50 #include "DGtal/base/CountedPtr.h"
51 #include "DGtal/images/ImageContainerBySTLVector.h"
52 #include "DGtal/images/CImage.h"
53 #include "DGtal/kernel/CPointPredicate.h"
54 #include "DGtal/kernel/domains/HyperRectDomain.h"
55 #include "DGtal/geometry/volumes/distance/CSeparableMetric.h"
56 #include "DGtal/kernel/domains/HyperRectDomain.h"
57 #include "DGtal/base/ConstAlias.h"
59 
60 namespace DGtal
61 {
62 
64  // template class VoronoiMap
119  template < typename TSpace,
120  typename TPointPredicate,
121  typename TSeparableMetric,
122  typename TImageContainer =
123  ImageContainerBySTLVector<HyperRectDomain<TSpace>,
124  typename TSpace::Vector>
125  >
127  {
128 
129  public:
134 
136  BOOST_STATIC_ASSERT ((boost::is_same< typename TSpace::Point,
137  typename TPointPredicate::Point >::value ));
138 
139  //ImageContainer::Domain::Space must match with TSpace
140  BOOST_STATIC_ASSERT ((boost::is_same< TSpace,
141  typename TImageContainer::Domain::Space >::value ));
142 
143  //ImageContainer value type must be TSpace::Vector
144  BOOST_STATIC_ASSERT ((boost::is_same< typename TSpace::Vector,
145  typename TImageContainer::Value >::value ));
146 
147  //ImageContainer domain type must be HyperRectangular
149  typename TImageContainer::Domain >::value ));
150 
152  typedef TSpace Space;
153 
155  typedef TPointPredicate PointPredicate;
156 
158  typedef typename TImageContainer::Domain Domain;
159 
161  typedef TSeparableMetric SeparableMetric;
162 
165 
166  typedef typename Space::Vector Vector;
167  typedef typename Space::Point Point;
168  typedef typename Space::Dimension Dimension;
169  typedef typename Space::Size Size;
171 
173  typedef TImageContainer OutputImage;
174 
176  typedef Vector Value;
177 
180 
182  typedef VoronoiMap< TSpace, TPointPredicate,
183  TSeparableMetric,TImageContainer > Self;
184 
185 
187  typedef std::array< bool, Space::dimension > PeriodicitySpec;
188 
209  ConstAlias<PointPredicate> predicate,
211 
237  ConstAlias<PointPredicate> predicate,
239  PeriodicitySpec const & aPeriodicitySpec);
243  ~VoronoiMap() = default;
244 
248  VoronoiMap() = delete;
249 
250  public:
251  // ------------------- ConstImage model ------------------------
252 
259  Self & operator=(const Self &aOtherVoronoiMap ) = default;
260 
265  const Domain & domain() const
266  {
267  return *myDomainPtr;
268  }
269 
275  {
276  return myImagePtr->constRange();
277  }
278 
285  Value operator()(const Point &aPoint) const
286  {
287  return myImagePtr->operator()(aPoint);
288  }
289 
293  const SeparableMetric* metric() const
294  {
295  return myMetricPtr;
296  }
297 
303  {
304  return myPeriodicitySpec;
305  }
306 
312  bool isPeriodic( const Dimension n ) const
313  {
314  return myPeriodicitySpec[ n ];
315  }
316 
327  Point projectPoint( Point aPoint ) const;
328 
334  void selfDisplay ( std::ostream & out ) const;
335 
336  // ------------------- Private functions ------------------------
337  private:
338 
345  void compute ( ) ;
346 
347 
353  void computeOtherSteps(const Dimension dim) const;
363  void computeOtherStep1D (const Point &row,
364  const Dimension dim) const;
365 
377  typename Point::Coordinate projectCoordinate( typename Point::Coordinate aCoordinate, const Dimension aDim ) const;
378 
379  // ------------------- Private members ------------------------
380  private:
381 
384 
387 
390 
393 
396 
398  std::vector< Dimension > myPeriodicityIndex; // Could be boost::static_vector but it needs Boost >= 1.54.
399 
402 
403  protected:
404 
407 
410 
413 
414  }; // end of class VoronoiMap
415 
422  template <typename S, typename P,
423  typename Sep, typename TI>
424  std::ostream&
425  operator<< ( std::ostream & out, const VoronoiMap<S,P,Sep,TI> & object );
426 
427 
428 } // namespace DGtal
429 
430 
432 // Includes inline functions.
433 #include "DGtal/geometry/volumes/distance/VoronoiMap.ih"
434 
435 // //
437 
438 #endif // !defined VoronoiMap_h
439 
440 #undef VoronoiMap_RECURSES
441 #endif // else defined(VoronoiMap_RECURSES)
Space::Size Size
Definition: VoronoiMap.h:169
const Point aPoint(3, 4)
Aim: Implementation of the linear in time Voronoi map construction.
Definition: VoronoiMap.h:126
Point myLowerBoundCopy
Copy of the image lower bound.
Definition: VoronoiMap.h:389
HyperRectDomain< Space > Domain
Component Coordinate
Type for Point elements.
Definition: PointVector.h:617
Self & operator=(const Self &aOtherVoronoiMap)=default
ConstRange constRange() const
Definition: VoronoiMap.h:274
PeriodicitySpec const & getPeriodicitySpec() const
Definition: VoronoiMap.h:302
TSeparableMetric SeparableMetric
Definition of the separable metric type.
Definition: VoronoiMap.h:161
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
DGtal::uint32_t Dimension
Definition: Common.h:127
Value operator()(const Point &aPoint) const
Definition: VoronoiMap.h:285
Image::ConstRange ConstRange
OutputImage::ConstRange ConstRange
Definition of the image value type.
Definition: VoronoiMap.h:179
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
BOOST_STATIC_ASSERT((boost::is_same< typename TSpace::Point, typename TPointPredicate::Point >::value))
Both Space points and PointPredicate points must be the same.
Point myDomainExtent
Domain extent.
Definition: VoronoiMap.h:401
PeriodicitySpec myPeriodicitySpec
Periodicity along each dimension.
Definition: VoronoiMap.h:412
const SeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: VoronoiMap.h:406
const SeparableMetric * metric() const
Definition: VoronoiMap.h:293
Point myUpperBoundCopy
Copy of the image lower bound.
Definition: VoronoiMap.h:392
Space::Point::Coordinate Abscissa
Definition: VoronoiMap.h:170
const Domain * myDomainPtr
Pointer to the computation domain.
Definition: VoronoiMap.h:383
bool isPeriodic(const Dimension n) const
Definition: VoronoiMap.h:312
Point myInfinity
Value to act as a +infinity value.
Definition: VoronoiMap.h:395
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer > Self
Self type.
Definition: VoronoiMap.h:183
PointVector< dim, Integer > Vector
Vectors in DGtal::SpaceND.
Definition: SpaceND.h:113
DGtal::Dimension Dimension
Copy of the type used for the dimension.
Definition: SpaceND.h:129
DGtal::int64_t IntegerLong
Large integer type for SeparableMetricHelper construction.
Definition: VoronoiMap.h:164
Space::Vector Vector
Definition: VoronoiMap.h:166
Aim: Defines a predicate on a point.
const Domain & domain() const
Definition: VoronoiMap.h:265
TImageContainer OutputImage
Type of resulting image.
Definition: VoronoiMap.h:173
~VoronoiMap()=default
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:105
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
std::vector< Dimension > myPeriodicityIndex
Index of the periodic dimensions.
Definition: VoronoiMap.h:398
TSpace Space
Copy of the space type.
Definition: VoronoiMap.h:152
Point::Coordinate projectCoordinate(typename Point::Coordinate aCoordinate, const Dimension aDim) const
void computeOtherSteps(const Dimension dim) const
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
TPointPredicate PointPredicate
Copy of the point predicate type.
Definition: VoronoiMap.h:155
void computeOtherStep1D(const Point &row, const Dimension dim) const
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
Aim: defines the concept of separable metrics.
UnsignedInteger Size
Type used to represent sizes in the digital space.
Definition: SpaceND.h:107
unsigned int dim(const Vector &z)
FreemanChain< int >::Vector Vector
Vector Value
Definition of the image value type.
Definition: VoronoiMap.h:176
CountedPtr< OutputImage > myImagePtr
Voronoi map image.
Definition: VoronoiMap.h:409
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition: VoronoiMap.h:187
Point projectPoint(Point aPoint) const
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition: SpaceND.h:110
Space::Point Point
Definition: VoronoiMap.h:167
const PointPredicate * myPointPredicatePtr
Pointer to the point predicate.
Definition: VoronoiMap.h:386
TImageContainer::Domain Domain
Definition of the underlying domain type.
Definition: VoronoiMap.h:158
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:102
boost::int64_t int64_t
signed 94-bit integer.
Definition: BasicTypes.h:74
Space::Dimension Dimension
Definition: VoronoiMap.h:168
void selfDisplay(std::ostream &out) const