DGtal  0.9.2
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 
151  ConstIterator begin() const {
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 
179  ConstReverseIterator rbegin() const {
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 
200  ConstReverseIterator rend() const {
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)
DefaultConstImageRange(const DefaultConstImageRange &other)
This class adapts any iterator so that operator* returns another element than the one pointed to by t...
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
ConstReverseIterator rbegin(const Point &aPoint) const
DefaultConstImageRange & operator=(const DefaultConstImageRange &other)
ConstReverseIterator rend() const
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
std::reverse_iterator< ConstIterator > ConstReverseIterator
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
ConstReverseIterator rbegin() const
ConstIterator begin(const Point &aPoint) const
DGtal is the top-level namespace which contains all DGtal functions and types.
BOOST_CONCEPT_ASSERT((concepts::CTrivialConstImage< TImage >))
DefaultConstImageRange(ConstAlias< TImage > aImage)
ConstIteratorAdapter< typename Domain::ConstIterator, TImage, Value > ConstIterator