DGtal  1.2.0
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)
37 #define PowerMap_RECURSES
38 
39 #if !defined PowerMap_h
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
131  typename TImageContainer::Domain::Space >::value ));
132 
133  //ImageContainer value type must be TSpace::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 
246  {
247  return myImagePtr->constRange();
248  }
249 
255  Value operator()(const Point &aPoint) const
256  {
257  return myImagePtr->operator()(aPoint);
258  }
259 
264  {
265  return myMetricPtr;
266  }
267 
272  {
273  return myWeightImagePtr;
274  }
275 
281  {
282  return myPeriodicitySpec;
283  }
284 
290  inline
291  bool isPeriodic( const Dimension n ) const
292  {
293  return myPeriodicitySpec[ n ];
294  }
295 
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 
383 
386 
389 
392 
394  std::vector< Dimension > myPeriodicityIndex; // Could be boost::static_vector but it needs Boost >= 1.54.
395 
398 
399  protected:
402 
405 
408 
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)
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'.
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
Component Coordinate
Type for Point elements.
Definition: PointVector.h:617
Aim: Implementation of the linear in time Power map construction.
Definition: PowerMap.h:111
PeriodicitySpec const & getPeriodicitySpec() const
Definition: PowerMap.h:280
Point myUpperBoundCopy
Copy of the image lower bound.
Definition: PowerMap.h:388
std::vector< Dimension > myPeriodicityIndex
Index of the periodic dimensions.
Definition: PowerMap.h:394
Point myDomainExtent
Domain extent.
Definition: PowerMap.h:397
Space::Point::Coordinate Abscissa
Definition: PowerMap.h:127
BOOST_STATIC_ASSERT((boost::is_same< typename TWeightImage::Domain::Space::Vector, typename TImageContainer::Value >::value))
BOOST_CONCEPT_ASSERT((concepts::CPowerSeparableMetric< TPowerSeparableMetric >))
TWeightImage::Value Weight
Definition: PowerMap.h:121
void computeOtherStep1D(const Point &row, const Dimension dim) const
PowerMap(ConstAlias< Domain > aDomain, ConstAlias< WeightImage > aWeightImage, ConstAlias< PowerSeparableMetric > aMetric, PeriodicitySpec const &aPeriodicitySpec)
const WeightImage * weightImagePtr() const
Definition: PowerMap.h:271
ConstRange constRange() const
Definition: PowerMap.h:245
const WeightImage * myWeightImagePtr
Pointer to the point predicate.
Definition: PowerMap.h:407
PowerMap(ConstAlias< Domain > aDomain, ConstAlias< WeightImage > aWeightImage, ConstAlias< PowerSeparableMetric > aMetric)
Point projectPoint(Point aPoint) const
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition: PowerMap.h:159
Value operator()(const Point &aPoint) const
Definition: PowerMap.h:255
const Domain * myDomainPtr
Pointer to the computation domain.
Definition: PowerMap.h:382
bool isPeriodic(const Dimension n) const
Definition: PowerMap.h:291
const PowerSeparableMetric * metricPtr() const
Definition: PowerMap.h:263
TImageContainer OutputImage
Type of resulting image.
Definition: PowerMap.h:148
TImageContainer::Domain Domain
Definition of the underlying domain type.
Definition: PowerMap.h:142
const PowerSeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: PowerMap.h:401
Point::Coordinate projectCoordinate(typename Point::Coordinate aCoordinate, const Dimension aDim) const
WeightImage::Domain::Space Space
Definition: PowerMap.h:122
Space::Size Size
Definition: PowerMap.h:126
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
PowerMap()=delete
TWeightImage WeightImage
Copy of the distance image types.
Definition: PowerMap.h:120
Vector Value
Definition of the image model value type.
Definition: PowerMap.h:151
PowerMap< TWeightImage, TPowerSeparableMetric, TImageContainer > Self
Self type.
Definition: PowerMap.h:156
const Domain & domain() const
Definition: PowerMap.h:235
TPowerSeparableMetric PowerSeparableMetric
We construct the type associated to the separable metric.
Definition: PowerMap.h:145
void computeOtherSteps(const Dimension dim) const
BOOST_STATIC_ASSERT((boost::is_same< HyperRectDomain< typename TWeightImage::Domain::Space >, typename TImageContainer::Domain >::value))
Self & operator=(const Self &aOtherPowerMap)=default
BOOST_STATIC_ASSERT((boost::is_same< typename TWeightImage::Domain::Space, typename TImageContainer::Domain::Space >::value))
PeriodicitySpec myPeriodicitySpec
Periodicity along each dimension.
Definition: PowerMap.h:410
void selfDisplay(std::ostream &out) const
Point myInfinity
Value to act as a +infinity value.
Definition: PowerMap.h:391
BOOST_CONCEPT_ASSERT((concepts::CConstImage< TWeightImage >))
OutputImage::ConstRange ConstRange
Definition of the image value type.
Definition: PowerMap.h:153
Point myLowerBoundCopy
Copy of the image lower bound.
Definition: PowerMap.h:385
Space::Dimension Dimension
Definition: PowerMap.h:125
~PowerMap()=default
CountedPtr< OutputImage > myImagePtr
Power map image.
Definition: PowerMap.h:404
Space::Point Point
Definition: PowerMap.h:124
Space::Vector Vector
Definition: PowerMap.h:123
Point projectPoint(Point aPoint, const Dimension aMaxDim) const
UnsignedInteger 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
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Definition: CConstImage.h:95
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:103
Aim: defines the concept of separable metrics.
FreemanChain< int >::Vector Vector
const Point aPoint(3, 4)
Image::ConstRange ConstRange
HyperRectDomain< Space > Domain
unsigned int dim(const Vector &z)