DGtal 1.3.0
Loading...
Searching...
No Matches
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
59namespace DGtal
60{
61
63 // template class PowerMap
105 template < typename TWeightImage,
106 typename TPowerSeparableMetric,
107 typename TImageContainer =
108 ImageContainerBySTLVector<HyperRectDomain<typename TWeightImage::Domain::Space>,
109 typename TWeightImage::Domain::Space::Vector> >
111 {
112
113 public:
114
118
120 typedef TWeightImage WeightImage;
121 typedef typename TWeightImage::Value Weight;
122 typedef typename WeightImage::Domain::Space Space;
123 typedef typename Space::Vector Vector;
124 typedef typename Space::Point Point;
125 typedef typename Space::Dimension Dimension;
126 typedef typename Space::Size Size;
127 typedef typename Space::Point::Coordinate Abscissa;
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
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
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
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)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: Smart pointer based on reference counts.
Definition: CountedPtr.h:80
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
Aim: Implementation of the linear in time Power map construction.
Definition: PowerMap.h:111
Point myUpperBoundCopy
Copy of the image lower bound.
Definition: PowerMap.h:392
std::vector< Dimension > myPeriodicityIndex
Index of the periodic dimensions.
Definition: PowerMap.h:398
Point myDomainExtent
Domain extent.
Definition: PowerMap.h:401
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:275
ConstRange constRange() const
Definition: PowerMap.h:249
const WeightImage * myWeightImagePtr
Pointer to the point predicate.
Definition: PowerMap.h:411
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:259
const Domain * myDomainPtr
Pointer to the computation domain.
Definition: PowerMap.h:386
PeriodicitySpec const & getPeriodicitySpec() const
Definition: PowerMap.h:284
bool isPeriodic(const Dimension n) const
Definition: PowerMap.h:295
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:405
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
const Domain & domain() const
Definition: PowerMap.h:239
const PowerSeparableMetric * metricPtr() const
Definition: PowerMap.h:267
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
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))
BOOST_STATIC_ASSERT((boost::is_same< typename TWeightImage::Domain::Space, typename TImageContainer::Domain::Space >::value))
PeriodicitySpec myPeriodicitySpec
Periodicity along each dimension.
Definition: PowerMap.h:414
void selfDisplay(std::ostream &out) const
Point myInfinity
Value to act as a +infinity value.
Definition: PowerMap.h:395
BOOST_CONCEPT_ASSERT((concepts::CConstImage< TWeightImage >))
Self & operator=(const Self &aOtherPowerMap)=default
OutputImage::ConstRange ConstRange
Definition of the image value type.
Definition: PowerMap.h:153
Point myLowerBoundCopy
Copy of the image lower bound.
Definition: PowerMap.h:389
Space::Dimension Dimension
Definition: PowerMap.h:125
~PowerMap()=default
CountedPtr< OutputImage > myImagePtr
Power map image.
Definition: PowerMap.h:408
Space::Point Point
Definition: PowerMap.h:124
Space::Vector Vector
Definition: PowerMap.h:123
Point projectPoint(Point aPoint, const Dimension aMaxDim) const
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition: SpaceND.h:110
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
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.
const Point aPoint(3, 4)
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer