DGtal  1.3.beta
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 
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)
DGtal::VoronoiMap::metric
const SeparableMetric * metric() const
Definition: VoronoiMap.h:293
DGtal::SpaceND::Dimension
DGtal::Dimension Dimension
Copy of the type used for the dimension.
Definition: SpaceND.h:129
DGtal::VoronoiMap::Vector
Space::Vector Vector
Definition: VoronoiMap.h:166
DGtal::ConstAlias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition: HyperRectDomain.h:99
DGtal::ImageContainerBySTLVector::Domain
TDomain Domain
Definition: ImageContainerBySTLVector.h:137
DGtal::concepts::CSpace
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:105
DGtal::SimpleRandomAccessConstRangeFromPoint
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
Definition: SimpleRandomAccessConstRangeFromPoint.h:73
DGtal::ImageContainerBySTLVector::Value
TValue Value
Definition: ImageContainerBySTLVector.h:153
DGtal::VoronoiMap
Aim: Implementation of the linear in time Voronoi map construction.
Definition: VoronoiMap.h:126
DGtal::VoronoiMap::myLowerBoundCopy
Point myLowerBoundCopy
Copy of the image lower bound.
Definition: VoronoiMap.h:389
DGtal::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::PointVector< dim, Integer >::Coordinate
Component Coordinate
Type for Point elements.
Definition: PointVector.h:617
DGtal::VoronoiMap::Value
Vector Value
Definition of the image value type.
Definition: VoronoiMap.h:176
aPoint
const Point aPoint(3, 4)
DGtal::VoronoiMap::myMetricPtr
const SeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: VoronoiMap.h:406
DGtal::VoronoiMap::Abscissa
Space::Point::Coordinate Abscissa
Definition: VoronoiMap.h:170
DGtal::ImageContainerBySTLVector::constRange
ConstRange constRange() const
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:137
DGtal::VoronoiMap::constRange
ConstRange constRange() const
Definition: VoronoiMap.h:274
DGtal::SpaceND::Size
size_t Size
Type used to represent sizes in the digital space.
Definition: SpaceND.h:107
DGtal::VoronoiMap::myInfinity
Point myInfinity
Value to act as a +infinity value.
Definition: VoronoiMap.h:395
DGtal::VoronoiMap::Self
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer > Self
Self type.
Definition: VoronoiMap.h:183
DGtal::VoronoiMap::getPeriodicitySpec
const PeriodicitySpec & getPeriodicitySpec() const
Definition: VoronoiMap.h:302
dim
unsigned int dim(const Vector &z)
Definition: viewDualSurface.cpp:174
DGtal::VoronoiMap::OutputImage
TImageContainer OutputImage
Type of resulting image.
Definition: VoronoiMap.h:173
DGtal::VoronoiMap::VoronoiMap
VoronoiMap()=delete
DGtal::VoronoiMap::Space
TSpace Space
Copy of the space type.
Definition: VoronoiMap.h:152
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::VoronoiMap::projectCoordinate
Point::Coordinate projectCoordinate(typename Point::Coordinate aCoordinate, const Dimension aDim) const
DGtal::VoronoiMap::domain
const Domain & domain() const
Definition: VoronoiMap.h:265
DGtal::VoronoiMap::Point
Space::Point Point
Definition: VoronoiMap.h:167
DGtal::VoronoiMap::myPeriodicitySpec
PeriodicitySpec myPeriodicitySpec
Periodicity along each dimension.
Definition: VoronoiMap.h:412
DGtal::VoronoiMap::projectPoint
Point projectPoint(Point aPoint) const
DGtal::VoronoiMap::ConstRange
OutputImage::ConstRange ConstRange
Definition of the image value type.
Definition: VoronoiMap.h:179
DGtal::VoronoiMap::operator()
Value operator()(const Point &aPoint) const
Definition: VoronoiMap.h:285
DGtal::VoronoiMap::SeparableMetric
TSeparableMetric SeparableMetric
Definition of the separable metric type.
Definition: VoronoiMap.h:161
DGtal::VoronoiMap::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
DGtal::VoronoiMap::operator=
Self & operator=(const Self &aOtherVoronoiMap)=default
DGtal::VoronoiMap::myDomainPtr
const Domain * myDomainPtr
Pointer to the computation domain.
Definition: VoronoiMap.h:383
DGtal::VoronoiMap::myImagePtr
CountedPtr< OutputImage > myImagePtr
Voronoi map image.
Definition: VoronoiMap.h:409
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::VoronoiMap::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::VoronoiMap::~VoronoiMap
~VoronoiMap()=default
DGtal::VoronoiMap::Size
Space::Size Size
Definition: VoronoiMap.h:169
DGtal::VoronoiMap::computeOtherStep1D
void computeOtherStep1D(const Point &row, const Dimension dim) const
DGtal::VoronoiMap::myPointPredicatePtr
const PointPredicate * myPointPredicatePtr
Pointer to the point predicate.
Definition: VoronoiMap.h:386
DGtal::VoronoiMap::PeriodicitySpec
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition: VoronoiMap.h:187
DGtal::VoronoiMap::PointPredicate
TPointPredicate PointPredicate
Copy of the point predicate type.
Definition: VoronoiMap.h:155
DGtal::CountedPtr< OutputImage >
DGtal::VoronoiMap::IntegerLong
DGtal::int64_t IntegerLong
Large integer type for SeparableMetricHelper construction.
Definition: VoronoiMap.h:164
DGtal::VoronoiMap::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((boost::is_same< typename TSpace::Point, typename TPointPredicate::Point >::value))
Both Space points and PointPredicate points must be the same.
Vector
FreemanChain< int >::Vector Vector
Definition: testCombinDSS.cpp:60
DGtal::VoronoiMap::myUpperBoundCopy
Point myUpperBoundCopy
Copy of the image lower bound.
Definition: VoronoiMap.h:392
DGtal::VoronoiMap::computeOtherSteps
void computeOtherSteps(const Dimension dim) const
DGtal::PointVector< dim, Integer >
DGtal::VoronoiMap::Dimension
Space::Dimension Dimension
Definition: VoronoiMap.h:168
DGtal::VoronoiMap::isPeriodic
bool isPeriodic(const Dimension n) const
Definition: VoronoiMap.h:312
DGtal::concepts::CPointPredicate
Aim: Defines a predicate on a point.
Definition: CPointPredicate.h:80
Space
SpaceND< 2 > Space
Definition: testSimpleRandomAccessRangeFromPoint.cpp:42
DGtal::int64_t
boost::int64_t int64_t
signed 94-bit integer.
Definition: BasicTypes.h:74
DGtal::VoronoiMap::myDomainExtent
Point myDomainExtent
Domain extent.
Definition: VoronoiMap.h:401
DGtal::VoronoiMap::Domain
TImageContainer::Domain Domain
Definition of the underlying domain type.
Definition: VoronoiMap.h:158
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::VoronoiMap::myPeriodicityIndex
std::vector< Dimension > myPeriodicityIndex
Index of the periodic dimensions.
Definition: VoronoiMap.h:398
DGtal::concepts::CSeparableMetric
Aim: defines the concept of separable metrics.
Definition: CSeparableMetric.h:101
DGtal::VoronoiMap::compute
void compute()
DGtal::concepts::CImage
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:102