DGtal  0.9.3
PowerMap.h
1 
17 #pragma once
18 
33 #if defined(PowerMap_RECURSES)
34 #error Recursive header files inclusion detected in PowerMap.h
35 #else // defined(PowerMap_RECURSES)
36 
37 #define PowerMap_RECURSES
38 
39 #if !defined PowerMap_h
40 
41 #define PowerMap_h
42 
44 // Inclusions
45 #include <iostream>
46 #include <utility>
47 #include <vector>
48 #include "DGtal/base/Common.h"
49 #include "DGtal/base/CountedPtr.h"
50 #include "DGtal/base/ConstAlias.h"
51 #include "DGtal/images/ImageContainerBySTLVector.h"
52 #include "DGtal/kernel/domains/HyperRectDomain.h"
53 #include "DGtal/images/CConstImage.h"
54 #include "DGtal/images/CImage.h"
55 #include "DGtal/geometry/volumes/distance/CPowerSeparableMetric.h"
56 #include "DGtal/kernel/domains/HyperRectDomain.h"
58 
59 namespace DGtal
60 {
61 
63  // template class PowerMap
105  template < typename TWeightImage,
106  typename TPowerSeparableMetric,
107  typename TImageContainer =
108  ImageContainerBySTLVector<HyperRectDomain<typename TWeightImage::Domain::Space>,
110  class PowerMap
111  {
112 
113  public:
114 
118 
120  typedef TWeightImage WeightImage;
121  typedef typename TWeightImage::Value Weight;
123  typedef typename Space::Vector Vector;
124  typedef typename Space::Point Point;
125  typedef typename Space::Dimension Dimension;
126  typedef typename Space::Size Size;
128 
129  //ImageContainer::Domain::Space must match with TSpace
130  BOOST_STATIC_ASSERT ((boost::is_same< typename TWeightImage::Domain::Space,
131  typename TImageContainer::Domain::Space >::value ));
132 
133  //ImageContainer value type must be TSpace::Vector
134  BOOST_STATIC_ASSERT ((boost::is_same< typename TWeightImage::Domain::Space::Vector,
135  typename TImageContainer::Value >::value ));
136 
137  //ImageContainer domain type must be HyperRectangular
139  typename TImageContainer::Domain >::value ));
140 
142  typedef typename TImageContainer::Domain Domain;
143 
145  typedef TPowerSeparableMetric PowerSeparableMetric;
146 
148  typedef TImageContainer OutputImage;
149 
151  typedef Vector Value;
154 
157 
159  typedef std::array< bool, Space::dimension > PeriodicitySpec;
160 
181  ConstAlias<WeightImage> aWeightImage,
183 
206  ConstAlias<WeightImage> aWeightImage,
208  PeriodicitySpec const & aPeriodicitySpec);
209 
213  PowerMap() = delete;
214 
218  ~PowerMap() = default;
219 
220  public:
221  // ------------------- ConstImage model ------------------------
222 
229  Self & operator=(const Self &aOtherPowerMap ) = default;
230 
235  const Domain & domain() const
236  {
237  return *myDomainPtr;
238  }
239 
240 
245  ConstRange constRange() const
246  {
247  return myImagePtr->constRange();
248  }
249 
255  Value operator()(const Point &aPoint) const
256  {
257  return myImagePtr->operator()(aPoint);
258  }
259 
263  const PowerSeparableMetric* metricPtr() const
264  {
265  return myMetricPtr;
266  }
267 
271  const WeightImage* weightImagePtr() const
272  {
273  return myWeightImagePtr;
274  }
275 
280  PeriodicitySpec const & getPeriodicitySpec() const
281  {
282  return myPeriodicitySpec;
283  }
284 
290  inline
291  bool isPeriodic( const Dimension n ) const
292  {
293  return myPeriodicitySpec[ n ];
294  }
295 
306  Point projectPoint( Point aPoint ) const;
307 
313  void selfDisplay ( std::ostream & out ) const;
314 
315  // ------------------- Private functions ------------------------
316  private:
317 
324  void compute ( ) ;
325 
326 
332  void computeOtherSteps(const Dimension dim) const;
333 
343  void computeOtherStep1D (const Point &row,
344  const Dimension dim) const;
345 
358  Point projectPoint( Point aPoint, const Dimension aMaxDim ) const;
359 
371  typename Point::Coordinate projectCoordinate( typename Point::Coordinate aCoordinate, const Dimension aDim ) const;
372 
373  // ------------------- protected methods ------------------------
374  protected:
375 
376 
377 
378  // ------------------- Private members ------------------------
379  private:
380 
382  const Domain * myDomainPtr;
383 
386 
389 
391  Point myInfinity;
392 
394  std::vector< Dimension > myPeriodicityIndex; // Could be boost::static_vector but it needs Boost >= 1.54.
395 
398 
399  protected:
401  const PowerSeparableMetric * myMetricPtr;
402 
405 
407  const WeightImage * myWeightImagePtr;
408 
410  PeriodicitySpec myPeriodicitySpec;
411 
412  }; // end of class PowerMap
413 
420  template <typename W,
421  typename Sep,
422  typename Image>
423  std::ostream&
424  operator<< ( std::ostream & out, const PowerMap<W,Sep,Image> & object );
425 
426 } // namespace DGtal
427 
428 
430 // Includes inline functions.
431 #include "DGtal/geometry/volumes/distance/PowerMap.ih"
432 
433 // //
435 
436 #endif // !defined PowerMap_h
437 
438 #undef PowerMap_RECURSES
439 #endif // else defined(PowerMap_RECURSES)
const Point aPoint(3, 4)
HyperRectDomain< Space > Domain
TWeightImage WeightImage
Copy of the distance image types.
Definition: PowerMap.h:120
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:69
OutputImage::ConstRange ConstRange
Definition of the image value type.
Definition: PowerMap.h:153
const Domain & domain() const
Definition: PowerMap.h:235
Self & operator=(const Self &aOtherPowerMap)=default
void computeOtherSteps(const Dimension dim) const
std::vector< Dimension > myPeriodicityIndex
Index of the periodic dimensions.
Definition: PowerMap.h:394
Component Coordinate
Type for Point elements.
Definition: PointVector.h:158
Point projectPoint(Point aPoint) const
Space::Vector Vector
Definition: PowerMap.h:123
Value operator()(const Point &aPoint) const
Definition: PowerMap.h:255
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
Point myInfinity
Value to act as a +infinity value.
Definition: PowerMap.h:391
Image::ConstRange ConstRange
WeightImage::Domain::Space Space
Definition: PowerMap.h:122
const WeightImage * weightImagePtr() const
Definition: PowerMap.h:271
Aim: Parallelepidec region of a digital space, model of a &#39;CDomain&#39;.
~PowerMap()=default
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition: PowerMap.h:159
TWeightImage::Value Weight
Definition: PowerMap.h:121
DGtal::Dimension Dimension
Copy of the type used for the dimension.
Definition: SpaceND.h:129
const PowerSeparableMetric * metricPtr() const
Definition: PowerMap.h:263
void computeOtherStep1D(const Point &row, const Dimension dim) const
const Domain * myDomainPtr
Pointer to the computation domain.
Definition: PowerMap.h:382
CountedPtr< OutputImage > myImagePtr
Power map image.
Definition: PowerMap.h:404
ConstRange constRange() const
Definition: PowerMap.h:245
Point myUpperBoundCopy
Copy of the image lower bound.
Definition: PowerMap.h:388
Aim: Implementation of the linear in time Power map construction.
Definition: PowerMap.h:110
Aim: defines the concept of separable metrics.
const WeightImage * myWeightImagePtr
Pointer to the point predicate.
Definition: PowerMap.h:407
BOOST_STATIC_ASSERT((boost::is_same< typename TWeightImage::Domain::Space, typename TImageContainer::Domain::Space >::value))
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Point myLowerBoundCopy
Copy of the image lower bound.
Definition: PowerMap.h:385
DGtal is the top-level namespace which contains all DGtal functions and types.
UnsignedInteger Size
Type used to represent sizes in the digital space.
Definition: SpaceND.h:107
PeriodicitySpec const & getPeriodicitySpec() const
Definition: PowerMap.h:280
unsigned int dim(const Vector &z)
Space::Dimension Dimension
Definition: PowerMap.h:125
FreemanChain< int >::Vector Vector
bool isPeriodic(const Dimension n) const
Definition: PowerMap.h:291
TImageContainer::Domain Domain
Definition of the underlying domain type.
Definition: PowerMap.h:142
Space::Point::Coordinate Abscissa
Definition: PowerMap.h:127
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition: SpaceND.h:110
const PowerSeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: PowerMap.h:401
TPowerSeparableMetric PowerSeparableMetric
We construct the type associated to the separable metric.
Definition: PowerMap.h:145
TImageContainer OutputImage
Type of resulting image.
Definition: PowerMap.h:148
Point myDomainExtent
Domain extent.
Definition: PowerMap.h:397
PowerMap()=delete
PowerMap< TWeightImage, TPowerSeparableMetric, TImageContainer > Self
Self type.
Definition: PowerMap.h:156
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Definition: CConstImage.h:94
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:102
Space::Size Size
Definition: PowerMap.h:126
Point::Coordinate projectCoordinate(typename Point::Coordinate aCoordinate, const Dimension aDim) const
Vector Value
Definition of the image model value type.
Definition: PowerMap.h:151
PeriodicitySpec myPeriodicitySpec
Periodicity along each dimension.
Definition: PowerMap.h:410
Space::Point Point
Definition: PowerMap.h:124
void selfDisplay(std::ostream &out) const