DGtal  1.4.beta
VoronoiMapComplete.h
1 
17 #pragma once
18 
34 #if defined(VoronoiMapComplete_RECURSES)
35 #error Recursive header files inclusion detected in VoronoiMapComplete.h
36 #else // defined(VoronoiMapComplete_RECURSES)
38 #define VoronoiMapComplete_RECURSES
39 
40 #if !defined VoronoiMapComplete_h
42 #define VoronoiMapComplete_h
43 
45 // Inclusions
46 #include <iostream>
47 #include <vector>
48 #include <array>
49 #include <set>
50 #include "DGtal/base/Common.h"
51 #include "DGtal/base/CountedPtr.h"
52 #include "DGtal/images/ImageContainerBySTLVector.h"
53 #include "DGtal/images/CImage.h"
54 #include "DGtal/kernel/CPointPredicate.h"
55 #include "DGtal/kernel/domains/HyperRectDomain.h"
56 #include "DGtal/geometry/volumes/distance/CSeparableMetric.h"
57 #include "DGtal/kernel/domains/HyperRectDomain.h"
58 #include "DGtal/base/ConstAlias.h"
60 
61 namespace DGtal
62 {
63 
65  // template class VoronoiMapComplete
128  template < typename TSpace,
129  typename TPointPredicate,
130  typename TSeparableMetric,
131  typename TImageContainer =
132  ImageContainerBySTLVector<HyperRectDomain<TSpace>,
133  std::set<typename TSpace::Vector> >
134  >
136  {
137 
138  public:
143 
145  BOOST_STATIC_ASSERT ((boost::is_same< typename TSpace::Point,
146  typename TPointPredicate::Point >::value ));
147 
148  //ImageContainer::Domain::Space must match with TSpace
149  BOOST_STATIC_ASSERT ((boost::is_same< TSpace,
150  typename TImageContainer::Domain::Space >::value ));
151 
152  //ImageContainer value type must be std::vector<TSpace::Vector>
153  BOOST_STATIC_ASSERT ((boost::is_same< std::set<typename TSpace::Vector>,
154  typename TImageContainer::Value >::value ));
155 
156  //ImageContainer domain type must be HyperRectangular
158  typename TImageContainer::Domain >::value ));
159 
161  typedef TSpace Space;
162 
164  typedef TPointPredicate PointPredicate;
165 
167  typedef typename TImageContainer::Domain Domain;
168 
170  typedef TSeparableMetric SeparableMetric;
171 
174 
175  typedef typename Space::Vector Vector;
176  typedef typename Space::Point Point;
177  typedef typename Space::Dimension Dimension;
178  typedef typename Space::Size Size;
180 
183 
185  typedef typename OutputImage::Value Value;
186 
189 
191  typedef VoronoiMapComplete< TSpace, TPointPredicate,
192  TSeparableMetric,TImageContainer > Self;
193 
194 
196  typedef std::array< bool, Space::dimension > PeriodicitySpec;
197 
218  ConstAlias<PointPredicate> predicate,
220 
246  ConstAlias<PointPredicate> predicate,
248  PeriodicitySpec const & aPeriodicitySpec);
252  ~VoronoiMapComplete() = default;
253 
257  VoronoiMapComplete() = delete;
258 
259  public:
260  // ------------------- ConstImage model ------------------------
261 
268  Self & operator=(const Self &aOtherVoronoiMap ) = default;
269 
274  const Domain & domain() const
275  {
276  return *myDomainPtr;
277  }
278 
284  {
285  return myImagePtr->constRange();
286  }
287 
294  Value operator()(const Point &aPoint) const
295  {
296  return myImagePtr->operator()(aPoint);
297  }
298 
302  const SeparableMetric* metric() const
303  {
304  return myMetricPtr;
305  }
306 
312  {
313  return myPeriodicitySpec;
314  }
315 
321  bool isPeriodic( const Dimension n ) const
322  {
323  return myPeriodicitySpec[ n ];
324  }
325 
337 
343  void selfDisplay ( std::ostream & out ) const;
344 
345  // ------------------- Private functions ------------------------
346  private:
347 
354  void compute ( ) ;
355 
361  void computeOtherSteps(const Dimension dim) const;
371  void computeOtherStep1D (const Point &row,
372  const Dimension dim) const;
373 
385  typename Point::Coordinate projectCoordinate( typename Point::Coordinate aCoordinate, const Dimension aDim ) const;
386 
387  // ------------------- Private members ------------------------
388  private:
389 
392 
395 
398 
401 
404 
406  std::vector< Dimension > myPeriodicityIndex; // Could be boost::static_vector but it needs Boost >= 1.54.
407 
410 
411  protected:
412 
415 
418 
421 
422  }; // end of class VoronoiMapComplete
423 
430  template <typename S, typename P,
431  typename Sep, typename TI>
432  std::ostream&
433  operator<< ( std::ostream & out, const VoronoiMapComplete<S,P,Sep,TI> & object );
434 
435 
436 } // namespace DGtal
437 
438 
440 // Includes inline functions.
441 #include "DGtal/geometry/volumes/distance/VoronoiMapComplete.ih"
442 
443 // //
445 
446 #endif // !defined VoronoiMap_h
447 
448 #undef VoronoiMapComplete_RECURSES
449 #endif // else defined(VoronoiMapComplete_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Component Coordinate
Type for Point elements.
Definition: PointVector.h:617
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
size_t Size
Type used to represent sizes in the digital space.
Definition: SpaceND.h:107
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.
CountedPtr< OutputImage > myImagePtr
Voronoi map image.
Space::Point::Coordinate Abscissa
Self & operator=(const Self &aOtherVoronoiMap)=default
Value operator()(const Point &aPoint) const
Point myDomainExtent
Domain extent.
OutputImage::Value Value
Definition of the image value type.
const SeparableMetric * metric() const
Point::Coordinate projectCoordinate(typename Point::Coordinate aCoordinate, const Dimension aDim) const
BOOST_STATIC_ASSERT((boost::is_same< HyperRectDomain< TSpace >, typename TImageContainer::Domain >::value))
bool isPeriodic(const Dimension n) const
void selfDisplay(std::ostream &out) const
PeriodicitySpec const & getPeriodicitySpec() const
std::vector< Dimension > myPeriodicityIndex
Index of the periodic dimensions.
VoronoiMapComplete(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric, PeriodicitySpec const &aPeriodicitySpec)
ConstRange constRange() const
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
Point myLowerBoundCopy
Copy of the image lower bound.
BOOST_STATIC_ASSERT((boost::is_same< TSpace, typename TImageContainer::Domain::Space >::value))
TImageContainer OutputImage
Type of resulting image.
BOOST_STATIC_ASSERT((boost::is_same< typename TSpace::Point, typename TPointPredicate::Point >::value))
Both Space points and PointPredicate points must be the same.
BOOST_CONCEPT_ASSERT((concepts::CSeparableMetric< TSeparableMetric >))
TImageContainer::Domain Domain
Definition of the underlying domain type.
void computeOtherStep1D(const Point &row, const Dimension dim) const
VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer > Self
Self type.
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
TSeparableMetric SeparableMetric
Definition of the separable metric type.
const PointPredicate * myPointPredicatePtr
Pointer to the point predicate.
DGtal::int64_t IntegerLong
Large integer type for SeparableMetricHelper construction.
const Domain * myDomainPtr
Pointer to the computation domain.
Point myInfinity
Value to act as a +infinity value.
BOOST_STATIC_ASSERT((boost::is_same< std::set< typename TSpace::Vector >, typename TImageContainer::Value >::value))
const SeparableMetric * myMetricPtr
Pointer to the separable metric instance.
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< TPointPredicate >))
Point projectPoint(Point aPoint) const
TPointPredicate PointPredicate
Copy of the point predicate type.
void computeOtherSteps(const Dimension dim) const
const Domain & domain() const
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
OutputImage::ConstRange ConstRange
Definition of the image value type.
TSpace Space
Copy of the space type.
VoronoiMapComplete(ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric)
Point myUpperBoundCopy
Copy of the image lower bound.
PeriodicitySpec myPeriodicitySpec
Periodicity along each dimension.
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 ATu0v1< TKSpace, TLinearAlgebra > &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
MyPointD Point
Definition: testClone2.cpp:383
const Point aPoint(3, 4)
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer
unsigned int dim(const Vector &z)