DGtal  0.9.2
DefaultImageRange.h
1 
17 #pragma once
18 
33 #if defined(DefaultImageRange_RECURSES)
34 #error Recursive header files inclusion detected in DefaultImageRange.h
35 #else // defined(DefaultImageRange_RECURSES)
36 
37 #define DefaultImageRange_RECURSES
38 
39 #if !defined DefaultImageRange_h
40 
41 #define DefaultImageRange_h
42 
44 // Inclusions
45 #include "DGtal/base/ConstIteratorAdapter.h"
46 #include "DGtal/kernel/domains/CDomain.h"
47 #include "DGtal/images/CTrivialImage.h"
48 #include "DGtal/images/SetValueIterator.h"
49 #include "boost/concept_check.hpp"
51 
52 namespace DGtal
53 {
54 
55 
57  // class DefaultImageRange
59 
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 
96 
97  // ------------------------- standard services --------------------------------
98 
104  DefaultImageRange( TImage& aImage )
105  : myImagePtr(&aImage) {}
106 
112  : myImagePtr(other.myImagePtr) {}
113 
120  {
121  if ( this != &other )
122  {
123  myImagePtr = other.myImagePtr;
124  }
125  return *this;
126  }
127 
132 
137  bool isValid() const { return true; }
138 
139 
140 
141  // ------------------------- private data --------------------------------
142  private:
146  TImage* myImagePtr;
147 
148  // ------------------------- iterator services (read-only) --------------------------------
149  public:
150 
155  ConstIterator begin() const {
156  Domain d = myImagePtr->domain();
157  return ConstIterator( d.begin(), *myImagePtr );
158  }
159 
165  ConstIterator begin(const Point& aPoint) const {
166  Domain d = myImagePtr->domain();
167  return ConstIterator( d.begin(aPoint), *myImagePtr );
168  }
169 
174  ConstIterator end() const {
175  Domain d = myImagePtr->domain();
176  return ConstIterator( d.end(), *myImagePtr );
177  }
178 
183  ConstReverseIterator rbegin() const {
184  return ConstReverseIterator(this->end());
185  }
186 
192  ConstReverseIterator rbegin(const Point& aPoint) const {
193  Domain d = myImagePtr->domain();
194  typename Domain::ConstIterator itOnPts = d.begin(aPoint);
195  if ( itOnPts != d.end() ) ++itOnPts;
196  ConstIterator itOnVals( itOnPts, *myImagePtr );
197  return ConstReverseIterator( itOnVals );
198  }
199 
204  ConstReverseIterator rend() const {
205  return ConstReverseIterator(this->begin());
206  }
207 
208  // ------------------------- iterator services (write-only) --------------------------------
209  public:
214  OutputIterator outputIterator() const {
215  Domain d = myImagePtr->domain();
216  return OutputIterator( d.begin(), *myImagePtr );
217  }
218 
224  OutputIterator outputIterator(const Point& aPoint) const {
225  Domain d = myImagePtr->domain();
226  return OutputIterator( d.begin(aPoint), *myImagePtr );
227  }
228 
233  ReverseOutputIterator routputIterator() const {
234  Domain d = myImagePtr->domain();
235  return ReverseOutputIterator( d.rbegin(), *myImagePtr );
236  }
237 
243  ReverseOutputIterator routputIterator(const Point& aPoint) const {
244  Domain d = myImagePtr->domain();
245  return ReverseOutputIterator( d.rbegin(aPoint), *myImagePtr );
246  }
247 
248  }; //end class DefaultImageRange
249 
250 } // namespace DGtal
251 
253 
254 
255 #endif // !defined DefaultImageRange_h
256 
257 #undef DefaultImageRange_RECURSES
258 #endif // else defined(DefaultImageRange_RECURSES)
This class adapts any iterator so that operator* returns another element than the one pointed to by t...
ConstIteratorAdapter< typename Domain::ConstIterator, TImage, Value > ConstIterator
Aim: model of CConstBidirectionalRangeFromPoint and CBidirectionalRangeWithWritableIteratorFromPoint ...
Aim: implements an output iterator, which is able to write values in an underlying image...
ReverseOutputIterator routputIterator() const
ConstIterator end() const
DefaultImageRange(const DefaultImageRange &other)
BOOST_CONCEPT_ASSERT((concepts::CTrivialImage< TImage >))
DefaultImageRange(TImage &aImage)
ConstReverseIterator rbegin() const
OutputIterator outputIterator(const Point &aPoint) const
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
OutputIterator outputIterator() const
ConstIterator begin(const Point &aPoint) const
DGtal is the top-level namespace which contains all DGtal functions and types.
ConstReverseIterator rend() const
Aim: Defines the concept describing an image without extra ranges, which is a refinement of CTrivialC...
Definition: CTrivialImage.h:84
ConstIterator begin() const
SetValueIterator< TImage > OutputIterator
output iterator types
DefaultImageRange & operator=(const DefaultImageRange &other)
std::reverse_iterator< ConstIterator > ConstReverseIterator
ConstReverseIterator rbegin(const Point &aPoint) const
SetValueIterator< TImage, typename Domain::ConstReverseIterator > ReverseOutputIterator
ReverseOutputIterator routputIterator(const Point &aPoint) const