DGtal 1.4.0
Loading...
Searching...
No Matches
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)
38#define VoronoiMap_RECURSES
39
40#if !defined VoronoiMap_h
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
60namespace 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
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;
170 typedef typename Space::Point::Coordinate Abscissa;
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
211
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
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
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)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition ConstAlias.h:187
Aim: Smart pointer based on reference counts.
Definition CountedPtr.h:80
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition SpaceND.h:110
size_t Size
Type used to represent sizes in the digital space.
Definition SpaceND.h:107
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
Aim: Implementation of the linear in time Voronoi map construction.
Definition VoronoiMap.h:127
ConstRange constRange() const
Definition VoronoiMap.h:274
Point myLowerBoundCopy
Copy of the image lower bound.
Definition VoronoiMap.h:389
Point::Coordinate projectCoordinate(typename Point::Coordinate aCoordinate, const Dimension aDim) const
Point myDomainExtent
Domain extent.
Definition VoronoiMap.h:401
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Space::Point Point
Definition VoronoiMap.h:167
Space::Vector Vector
Definition VoronoiMap.h:166
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
std::vector< Dimension > myPeriodicityIndex
Index of the periodic dimensions.
Definition VoronoiMap.h:398
BOOST_STATIC_ASSERT((boost::is_same< typename TSpace::Point, typename TPointPredicate::Point >::value))
Both Space points and PointPredicate points must be the same.
PeriodicitySpec myPeriodicitySpec
Periodicity along each dimension.
Definition VoronoiMap.h:412
BOOST_STATIC_ASSERT((boost::is_same< typename TSpace::Vector, typename TImageContainer::Value >::value))
BOOST_STATIC_ASSERT((boost::is_same< TSpace, typename TImageContainer::Domain::Space >::value))
bool isPeriodic(const Dimension n) const
Definition VoronoiMap.h:312
TImageContainer::Domain Domain
Definition of the underlying domain type.
Definition VoronoiMap.h:158
TSeparableMetric SeparableMetric
Definition of the separable metric type.
Definition VoronoiMap.h:161
Self & operator=(const Self &aOtherVoronoiMap)=default
void computeOtherSteps(const Dimension dim) const
BOOST_STATIC_ASSERT((boost::is_same< HyperRectDomain< TSpace >, typename TImageContainer::Domain >::value))
Space::Dimension Dimension
Definition VoronoiMap.h:168
Point myInfinity
Value to act as a +infinity value.
Definition VoronoiMap.h:395
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition VoronoiMap.h:187
Value operator()(const Point &aPoint) const
Definition VoronoiMap.h:285
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer > Self
Self type.
Definition VoronoiMap.h:183
VoronoiMap(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric, PeriodicitySpec const &aPeriodicitySpec)
CountedPtr< OutputImage > myImagePtr
Voronoi map image.
Definition VoronoiMap.h:409
Space::Size Size
Definition VoronoiMap.h:169
PeriodicitySpec const & getPeriodicitySpec() const
Definition VoronoiMap.h:302
void selfDisplay(std::ostream &out) const
TSpace Space
Copy of the space type.
Definition VoronoiMap.h:152
Point myUpperBoundCopy
Copy of the image lower bound.
Definition VoronoiMap.h:392
Space::Point::Coordinate Abscissa
Definition VoronoiMap.h:170
const SeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition VoronoiMap.h:406
const SeparableMetric * metric() const
Definition VoronoiMap.h:293
Vector Value
Definition of the image value type.
Definition VoronoiMap.h:176
DGtal::int64_t IntegerLong
Large integer type for SeparableMetricHelper construction.
Definition VoronoiMap.h:164
TImageContainer OutputImage
Type of resulting image.
Definition VoronoiMap.h:173
TPointPredicate PointPredicate
Copy of the point predicate type.
Definition VoronoiMap.h:155
BOOST_CONCEPT_ASSERT((concepts::CSeparableMetric< TSeparableMetric >))
~VoronoiMap()=default
const Domain * myDomainPtr
Pointer to the computation domain.
Definition VoronoiMap.h:383
const Domain & domain() const
Definition VoronoiMap.h:265
Point projectPoint(Point aPoint) const
VoronoiMap(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric)
OutputImage::ConstRange ConstRange
Definition of the image value type.
Definition VoronoiMap.h:179
void computeOtherStep1D(const Point &row, const Dimension dim) const
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< TPointPredicate >))
const PointPredicate * myPointPredicatePtr
Pointer to the point predicate.
Definition VoronoiMap.h:386
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::int64_t int64_t
signed 94-bit integer.
Definition BasicTypes.h:74
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition CImage.h:103
Aim: Defines a predicate on a point.
Aim: defines the concept of separable metrics.
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition CSpace.h:106
const Point aPoint(3, 4)
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer