DGtal  1.4.beta
DefaultConstImageRange.h
1 
17 #pragma once
18 
33 #if defined(DefaultConstImageRange_RECURSES)
34 #error Recursive header files inclusion detected in DefaultConstImageRange.h
35 #else // defined(DefaultConstImageRange_RECURSES)
36 
37 #define DefaultConstImageRange_RECURSES
38 
39 #if !defined DefaultConstImageRange_h
40 
41 #define DefaultConstImageRange_h
42 
44 // Inclusions
45 #include "DGtal/base/ConstIteratorAdapter.h"
46 #include "DGtal/base/ConstAlias.h"
47 #include "DGtal/kernel/domains/CDomain.h"
48 #include "DGtal/images/CTrivialConstImage.h"
49 #include "DGtal/images/SetValueIterator.h"
50 #include "boost/concept_check.hpp"
52 
53 namespace DGtal
54 {
55 
56 
58  // class DefaultConstImageRange
60 
75  template <typename TImage>
77  {
78 
79 
80  // ------------------------- inner types --------------------------------
81  public:
82 
84  typedef typename TImage::Domain Domain;
85  typedef typename TImage::Point Point;
86  typedef typename TImage::Value Value;
87 
91  typedef std::reverse_iterator<ConstIterator> ConstReverseIterator;
92 
93  // ------------------------- standard services --------------------------------
94 
101  : myImagePtr(&aImage) {}
102 
108  : myImagePtr(other.myImagePtr) {}
109 
116  {
117  if ( this != &other )
118  {
119  myImagePtr = other.myImagePtr;
120  }
121  return *this;
122  }
123 
128 
133  bool isValid() const { return true; }
134 
135 
136 
137  // ------------------------- private data --------------------------------
138  private:
142  const TImage* myImagePtr;
143 
144  // ------------------------- iterator services (read-only) --------------------------------
145  public:
146 
152  Domain d = myImagePtr->domain();
153  return ConstIterator( d.begin(), *myImagePtr );
154  }
155 
161  ConstIterator begin(const Point& aPoint) const {
162  Domain d = myImagePtr->domain();
163  return ConstIterator( d.begin(aPoint), *myImagePtr );
164  }
165 
170  ConstIterator end() const {
171  Domain d = myImagePtr->domain();
172  return ConstIterator( d.end(), *myImagePtr );
173  }
174 
180  return ConstReverseIterator(this->end());
181  }
182 
188  ConstReverseIterator rbegin(const Point& aPoint) const {
189  Domain d = myImagePtr->domain();
190  typename Domain::ConstIterator itOnPts = d.begin(aPoint);
191  if ( itOnPts != d.end() ) ++itOnPts;
192  ConstIterator itOnVals( itOnPts, *myImagePtr );
193  return ConstReverseIterator( itOnVals );
194  }
195 
201  return ConstReverseIterator(this->begin());
202  }
203 
204 
205  }; //end class DefaultConstImageRange
206 
207 } // namespace DGtal
208 
210 
211 
212 #endif // !defined DefaultConstImageRange_h
213 
214 #undef DefaultConstImageRange_RECURSES
215 #endif // else defined(DefaultConstImageRange_RECURSES)
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::DefaultConstImageRange::ConstIterator
ConstIteratorAdapter< typename Domain::ConstIterator, TImage, Value > ConstIterator
Definition: DefaultConstImageRange.h:90
DGtal::DefaultConstImageRange::begin
ConstIterator begin(const Point &aPoint) const
Definition: DefaultConstImageRange.h:161
DGtal::DefaultConstImageRange::isValid
bool isValid() const
Definition: DefaultConstImageRange.h:133
aPoint
const Point aPoint(3, 4)
DGtal::DefaultConstImageRange::Value
TImage::Value Value
Definition: DefaultConstImageRange.h:86
DGtal::DefaultConstImageRange
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
Definition: DefaultConstImageRange.h:76
DGtal::DefaultConstImageRange::rbegin
ConstReverseIterator rbegin(const Point &aPoint) const
Definition: DefaultConstImageRange.h:188
DGtal::DefaultConstImageRange::Point
TImage::Point Point
Definition: DefaultConstImageRange.h:85
DGtal::concepts::CDomain
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Domain
HyperRectDomain< Space > Domain
Definition: testSimpleRandomAccessRangeFromPoint.cpp:44
DGtal::DefaultConstImageRange::rend
ConstReverseIterator rend() const
Definition: DefaultConstImageRange.h:200
DGtal::DefaultConstImageRange::ConstReverseIterator
std::reverse_iterator< ConstIterator > ConstReverseIterator
Definition: DefaultConstImageRange.h:91
DGtal::DefaultConstImageRange::DefaultConstImageRange
DefaultConstImageRange(const DefaultConstImageRange &other)
Definition: DefaultConstImageRange.h:107
DGtal::DefaultConstImageRange::end
ConstIterator end() const
Definition: DefaultConstImageRange.h:170
DGtal::DefaultConstImageRange::myImagePtr
const TImage * myImagePtr
Definition: DefaultConstImageRange.h:142
DGtal::HyperRectDomain_Iterator
Iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:142
DGtal::DefaultConstImageRange::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CTrivialConstImage< TImage >))
DGtal::DefaultConstImageRange::DefaultConstImageRange
DefaultConstImageRange(ConstAlias< TImage > aImage)
Definition: DefaultConstImageRange.h:100
DGtal::DefaultConstImageRange::begin
ConstIterator begin() const
Definition: DefaultConstImageRange.h:151
DGtal::DefaultConstImageRange::Domain
TImage::Domain Domain
Definition: DefaultConstImageRange.h:84
DGtal::DefaultConstImageRange::operator=
DefaultConstImageRange & operator=(const DefaultConstImageRange &other)
Definition: DefaultConstImageRange.h:115
DGtal::concepts::CTrivialConstImage
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Definition: CTrivialConstImage.h:88
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::DefaultConstImageRange::rbegin
ConstReverseIterator rbegin() const
Definition: DefaultConstImageRange.h:179
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::DefaultConstImageRange::~DefaultConstImageRange
~DefaultConstImageRange()
Definition: DefaultConstImageRange.h:127
DGtal::ConstIteratorAdapter
This class adapts any iterator so that operator* returns another element than the one pointed to by t...
Definition: ConstIteratorAdapter.h:85