DGtal  0.9.2
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 "DGtal/base/Common.h"
49 #include "DGtal/base/CountedPtr.h"
50 #include "DGtal/images/ImageContainerBySTLVector.h"
51 #include "DGtal/kernel/CPointPredicate.h"
52 #include "DGtal/kernel/domains/HyperRectDomain.h"
53 #include "DGtal/geometry/volumes/distance/CSeparableMetric.h"
54 #include "DGtal/kernel/domains/HyperRectDomain.h"
55 #include "DGtal/base/ConstAlias.h"
57 
58 namespace DGtal
59 {
60 
62  // template class VoronoiMap
106  template < typename TSpace,
107  typename TPointPredicate,
108  typename TSeparableMetric,
109  typename TImageContainer =
110  ImageContainerBySTLVector<HyperRectDomain<TSpace>,
111  typename TSpace::Vector>
112  >
114  {
115 
116  public:
120 
122  BOOST_STATIC_ASSERT ((boost::is_same< typename TSpace::Point,
123  typename TPointPredicate::Point >::value ));
124 
125  //ImageContainer::Domain::Space must match with TSpace
126  BOOST_STATIC_ASSERT ((boost::is_same< TSpace,
127  typename TImageContainer::Domain::Space >::value ));
128 
129  //ImageContainer value type must be TSpace::Vector
130  BOOST_STATIC_ASSERT ((boost::is_same< typename TSpace::Vector,
131  typename TImageContainer::Value >::value ));
132 
133  //ImageContainer domain type must be HyperRectangular
135  typename TImageContainer::Domain >::value ));
136 
138  typedef TSpace Space;
139 
141  typedef TPointPredicate PointPredicate;
142 
144  typedef typename TImageContainer::Domain Domain;
145 
147  typedef TSeparableMetric SeparableMetric;
148 
151 
152  typedef typename Space::Vector Vector;
153  typedef typename Space::Point Point;
154  typedef typename Space::Dimension Dimension;
155  typedef typename Space::Size Size;
157 
159  typedef TImageContainer OutputImage;
161  typedef Vector Value;
162 
164  typedef typename OutputImage::ConstRange ConstRange;
165 
167  typedef VoronoiMap<TSpace, TPointPredicate,
168  TSeparableMetric,TImageContainer> Self;
169 
170 
190  ConstAlias<PointPredicate> predicate,
192 
196  ~VoronoiMap();
197 
198  public:
199  // ------------------- ConstImage model ------------------------
200 
207  Self & operator=(const Self &aOtherVoronoiMap );
208 
213  const Domain & domain() const
214  {
215  return *myDomainPtr;
216  }
217 
218 
223  ConstRange constRange() const
224  {
225  return myImagePtr->constRange();
226  }
227 
234  Value operator()(const Point &aPoint) const
235  {
236  return myImagePtr->operator()(aPoint);
237  }
238 
242  const SeparableMetric* metric() const
243  {
244  return myMetricPtr;
245  }
246 
252  void selfDisplay ( std::ostream & out ) const;
253 
254  // ------------------- Private functions ------------------------
255  private:
256 
263  void compute ( ) ;
264 
265 
271  void computeOtherSteps(const Dimension dim) const;
281  void computeOtherStep1D (const Point &row,
282  const Dimension dim) const;
283 
284  // ------------------- protected methods ------------------------
285  protected:
286 
291  VoronoiMap();
292 
293 
294  // ------------------- Private members ------------------------
295  private:
296 
298  const Domain * myDomainPtr;
299 
301  const PointPredicate * myPointPredicatePtr;
302 
305 
308 
310  Point myInfinity;
311 
312  protected:
313 
315  const SeparableMetric * myMetricPtr;
316 
319 
320  }; // end of class VoronoiMap
321 
328  template <typename S, typename P,
329  typename Sep, typename TI>
330  std::ostream&
331  operator<< ( std::ostream & out, const VoronoiMap<S,P,Sep,TI> & object );
332 
333 
334 } // namespace DGtal
335 
336 
338 // Includes inline functions.
339 #include "DGtal/geometry/volumes/distance/VoronoiMap.ih"
340 
341 // //
343 
344 #endif // !defined VoronoiMap_h
345 
346 #undef VoronoiMap_RECURSES
347 #endif // else defined(VoronoiMap_RECURSES)
Space::Size Size
Definition: VoronoiMap.h:155
Aim: Implementation of the linear in time Voronoi map construction.
Definition: VoronoiMap.h:113
Point myLowerBoundCopy
Copy of the image lower bound.
Definition: VoronoiMap.h:304
Component Coordinate
Type for Point elements.
Definition: PointVector.h:158
Value operator()(const Point &aPoint) const
Definition: VoronoiMap.h:234
TSeparableMetric SeparableMetric
Definition of the separable metric type.
Definition: VoronoiMap.h:147
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
void computeOtherSteps(const Dimension dim) const
const SeparableMetric * metric() const
Definition: VoronoiMap.h:242
OutputImage::ConstRange ConstRange
Definition of the image value type.
Definition: VoronoiMap.h:164
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
void computeOtherStep1D(const Point &row, const Dimension dim) const
const SeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: VoronoiMap.h:315
Point myUpperBoundCopy
Copy of the image lower bound.
Definition: VoronoiMap.h:307
Space::Point::Coordinate Abscissa
Definition: VoronoiMap.h:156
const Domain * myDomainPtr
Pointer to the computation domain.
Definition: VoronoiMap.h:298
Point myInfinity
Value to act as a +infinity value.
Definition: VoronoiMap.h:310
Self & operator=(const Self &aOtherVoronoiMap)
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
BOOST_STATIC_ASSERT((boost::is_same< typename TSpace::Point, typename TPointPredicate::Point >::value))
Both Space points and PointPredicate points must be the same.
DGtal::int64_t IntegerLong
Large integer type for SeparableMetricHelper construction.
Definition: VoronoiMap.h:150
Space::Vector Vector
Definition: VoronoiMap.h:152
Aim: Defines a predicate on a point.
TImageContainer OutputImage
Type of resulting image.
Definition: VoronoiMap.h:159
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines...
Definition: CSpace.h:105
VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer > Self
Self type.
Definition: VoronoiMap.h:168
TSpace Space
Copy of the space type.
Definition: VoronoiMap.h:138
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
TPointPredicate PointPredicate
Copy of the point predicate type.
Definition: VoronoiMap.h:141
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: defines the concept of separable metrics.
UnsignedInteger Size
Type used to represent sizes in the digital space.
Definition: SpaceND.h:107
void selfDisplay(std::ostream &out) const
Vector Value
Definition of the image value type.
Definition: VoronoiMap.h:161
const Domain & domain() const
Definition: VoronoiMap.h:213
CountedPtr< OutputImage > myImagePtr
Voronoi map image.
Definition: VoronoiMap.h:318
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition: SpaceND.h:110
Space::Point Point
Definition: VoronoiMap.h:153
const PointPredicate * myPointPredicatePtr
Pointer to the point predicate.
Definition: VoronoiMap.h:301
TImageContainer::Domain Domain
Definition of the underlying domain type.
Definition: VoronoiMap.h:144
boost::int64_t int64_t
signed 94-bit integer.
Definition: BasicTypes.h:74
ConstRange constRange() const
Definition: VoronoiMap.h:223
Space::Dimension Dimension
Definition: VoronoiMap.h:154