DGtal  1.4.beta
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 
149 
151  typedef Vector Value;
154 
157 
159  typedef std::array< bool, Space::dimension > PeriodicitySpec;
160 
185  ConstAlias<WeightImage> aWeightImage,
187 
210  ConstAlias<WeightImage> aWeightImage,
212  PeriodicitySpec const & aPeriodicitySpec);
213 
217  PowerMap() = delete;
218 
222  ~PowerMap() = default;
223 
224  public:
225  // ------------------- ConstImage model ------------------------
226 
233  Self & operator=(const Self &aOtherPowerMap ) = default;
234 
239  const Domain & domain() const
240  {
241  return *myDomainPtr;
242  }
243 
244 
250  {
251  return myImagePtr->constRange();
252  }
253 
259  Value operator()(const Point &aPoint) const
260  {
261  return myImagePtr->operator()(aPoint);
262  }
263 
268  {
269  return myMetricPtr;
270  }
271 
276  {
277  return myWeightImagePtr;
278  }
279 
285  {
286  return myPeriodicitySpec;
287  }
288 
294  inline
295  bool isPeriodic( const Dimension n ) const
296  {
297  return myPeriodicitySpec[ n ];
298  }
299 
310  Point projectPoint( Point aPoint ) const;
311 
317  void selfDisplay ( std::ostream & out ) const;
318 
319  // ------------------- Private functions ------------------------
320  private:
321 
328  void compute ( ) ;
329 
330 
336  void computeOtherSteps(const Dimension dim) const;
337 
347  void computeOtherStep1D (const Point &row,
348  const Dimension dim) const;
349 
362  Point projectPoint( Point aPoint, const Dimension aMaxDim ) const;
363 
375  typename Point::Coordinate projectCoordinate( typename Point::Coordinate aCoordinate, const Dimension aDim ) const;
376 
377  // ------------------- protected methods ------------------------
378  protected:
379 
380 
381 
382  // ------------------- Private members ------------------------
383  private:
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:
406 
409 
412 
415 
416  }; // end of class PowerMap
417 
424  template <typename W,
425  typename Sep,
426  typename Image>
427  std::ostream&
428  operator<< ( std::ostream & out, const PowerMap<W,Sep,Image> & object );
429 
430 } // namespace DGtal
431 
432 
434 // Includes inline functions.
435 #include "DGtal/geometry/volumes/distance/PowerMap.ih"
436 
437 // //
439 
440 #endif // !defined PowerMap_h
441 
442 #undef PowerMap_RECURSES
443 #endif // else defined(PowerMap_RECURSES)
DGtal::PowerMap::PowerMap
PowerMap()=delete
DGtal::PowerMap::myDomainExtent
Point myDomainExtent
Domain extent.
Definition: PowerMap.h:401
DGtal::PowerMap::myInfinity
Point myInfinity
Value to act as a +infinity value.
Definition: PowerMap.h:395
DGtal::PowerMap::computeOtherSteps
void computeOtherSteps(const Dimension dim) const
DGtal::SpaceND::Dimension
DGtal::Dimension Dimension
Copy of the type used for the dimension.
Definition: SpaceND.h:129
DGtal::PowerMap::compute
void compute()
DGtal::PowerMap
Aim: Implementation of the linear in time Power map construction.
Definition: PowerMap.h:110
DGtal::PowerMap::weightImagePtr
const WeightImage * weightImagePtr() const
Definition: PowerMap.h:275
DGtal::PowerMap::Vector
Space::Vector Vector
Definition: PowerMap.h:123
DGtal::PowerMap::~PowerMap
~PowerMap()=default
DGtal::ConstAlias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition: HyperRectDomain.h:99
DGtal::ImageContainerBySTLVector::Domain
TDomain Domain
Definition: ImageContainerBySTLVector.h:137
DGtal::SimpleRandomAccessConstRangeFromPoint
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
Definition: SimpleRandomAccessConstRangeFromPoint.h:73
DGtal::ImageContainerBySTLVector::Value
TValue Value
Definition: ImageContainerBySTLVector.h:153
DGtal::PowerMap::myPeriodicitySpec
PeriodicitySpec myPeriodicitySpec
Periodicity along each dimension.
Definition: PowerMap.h:414
DGtal::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::PointVector< dim, Integer >::Coordinate
Component Coordinate
Type for Point elements.
Definition: PointVector.h:617
DGtal::PowerMap::myPeriodicityIndex
std::vector< Dimension > myPeriodicityIndex
Index of the periodic dimensions.
Definition: PowerMap.h:398
DGtal::PowerMap::operator=
Self & operator=(const Self &aOtherPowerMap)=default
DGtal::SpaceND::Point
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition: SpaceND.h:110
DGtal::PowerMap::projectPoint
Point projectPoint(Point aPoint) const
aPoint
const Point aPoint(3, 4)
DGtal::ImageContainerBySTLVector::constRange
ConstRange constRange() const
DGtal::PowerMap::ConstRange
OutputImage::ConstRange ConstRange
Definition of the image value type.
Definition: PowerMap.h:153
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:137
DGtal::SpaceND::Size
size_t Size
Type used to represent sizes in the digital space.
Definition: SpaceND.h:107
DGtal::PowerMap::Space
WeightImage::Domain::Space Space
Definition: PowerMap.h:122
DGtal::PowerMap::Weight
TWeightImage::Value Weight
Definition: PowerMap.h:121
DGtal::PowerMap::computeOtherStep1D
void computeOtherStep1D(const Point &row, const Dimension dim) const
DGtal::PowerMap::operator()
Value operator()(const Point &aPoint) const
Definition: PowerMap.h:259
dim
unsigned int dim(const Vector &z)
Definition: viewDualSurface.cpp:174
DGtal::PowerMap::myImagePtr
CountedPtr< OutputImage > myImagePtr
Power map image.
Definition: PowerMap.h:408
DGtal::PowerMap::metricPtr
const PowerSeparableMetric * metricPtr() const
Definition: PowerMap.h:267
DGtal::PowerMap::getPeriodicitySpec
const PeriodicitySpec & getPeriodicitySpec() const
Definition: PowerMap.h:284
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::PowerMap::myUpperBoundCopy
Point myUpperBoundCopy
Copy of the image lower bound.
Definition: PowerMap.h:392
DGtal::PowerMap::PeriodicitySpec
std::array< bool, Space::dimension > PeriodicitySpec
Periodicity specification type.
Definition: PowerMap.h:159
DGtal::PowerMap::myDomainPtr
const Domain * myDomainPtr
Pointer to the computation domain.
Definition: PowerMap.h:386
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::PowerMap::Dimension
Space::Dimension Dimension
Definition: PowerMap.h:125
DGtal::concepts::CPowerSeparableMetric
Aim: defines the concept of separable metrics.
Definition: CPowerSeparableMetric.h:89
DGtal::PowerMap::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((boost::is_same< typename TWeightImage::Domain::Space, typename TImageContainer::Domain::Space >::value))
DGtal::PowerMap::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
DGtal::PowerMap::constRange
ConstRange constRange() const
Definition: PowerMap.h:249
DGtal::PowerMap::Domain
TImageContainer::Domain Domain
Definition of the underlying domain type.
Definition: PowerMap.h:142
DGtal::CountedPtr< OutputImage >
DGtal::PowerMap::myMetricPtr
const PowerSeparableMetric * myMetricPtr
Pointer to the separable metric instance.
Definition: PowerMap.h:405
Vector
FreemanChain< int >::Vector Vector
Definition: testCombinDSS.cpp:60
DGtal::Image
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:69
DGtal::PowerMap::OutputImage
TImageContainer OutputImage
Type of resulting image.
Definition: PowerMap.h:148
DGtal::PowerMap::myWeightImagePtr
const WeightImage * myWeightImagePtr
Pointer to the point predicate.
Definition: PowerMap.h:411
DGtal::PowerMap::PowerSeparableMetric
TPowerSeparableMetric PowerSeparableMetric
We construct the type associated to the separable metric.
Definition: PowerMap.h:145
DGtal::PointVector< dim, Integer >
DGtal::PowerMap::projectCoordinate
Point::Coordinate projectCoordinate(typename Point::Coordinate aCoordinate, const Dimension aDim) const
DGtal::PowerMap::isPeriodic
bool isPeriodic(const Dimension n) const
Definition: PowerMap.h:295
DGtal::PowerMap::myLowerBoundCopy
Point myLowerBoundCopy
Copy of the image lower bound.
Definition: PowerMap.h:389
DGtal::PowerMap::Self
PowerMap< TWeightImage, TPowerSeparableMetric, TImageContainer > Self
Self type.
Definition: PowerMap.h:156
DGtal::PowerMap::Point
Space::Point Point
Definition: PowerMap.h:124
Space
SpaceND< 2 > Space
Definition: testSimpleRandomAccessRangeFromPoint.cpp:42
DGtal::PowerMap::Abscissa
Space::Point::Coordinate Abscissa
Definition: PowerMap.h:127
DGtal::PowerMap::Size
Space::Size Size
Definition: PowerMap.h:126
DGtal::PowerMap::WeightImage
TWeightImage WeightImage
Copy of the distance image types.
Definition: PowerMap.h:120
DGtal::PowerMap::Value
Vector Value
Definition of the image model value type.
Definition: PowerMap.h:151
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::PowerMap::domain
const Domain & domain() const
Definition: PowerMap.h:239
DGtal::concepts::CConstImage
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Definition: CConstImage.h:94
DGtal::PowerMap::selfDisplay
void selfDisplay(std::ostream &out) const
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::concepts::CImage
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:102