DGtal 1.3.0
Loading...
Searching...
No Matches
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)
37#define DefaultImageRange_RECURSES
38
39#if !defined DefaultImageRange_h
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
52namespace 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
156 Domain d = myImagePtr->domain();
157 return ConstIterator( d.begin(), *myImagePtr );
158 }
159
166 Domain d = myImagePtr->domain();
167 return ConstIterator( d.begin(aPoint), *myImagePtr );
168 }
169
175 Domain d = myImagePtr->domain();
176 return ConstIterator( d.end(), *myImagePtr );
177 }
178
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
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
225 Domain d = myImagePtr->domain();
226 return OutputIterator( d.begin(aPoint), *myImagePtr );
227 }
228
234 Domain d = myImagePtr->domain();
235 return ReverseOutputIterator( d.rbegin(), *myImagePtr );
236 }
237
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...
Aim: model of CConstBidirectionalRangeFromPoint and CBidirectionalRangeWithWritableIteratorFromPoint ...
std::reverse_iterator< ConstIterator > ConstReverseIterator
ReverseOutputIterator routputIterator() const
DefaultImageRange(TImage &aImage)
OutputIterator outputIterator() const
SetValueIterator< TImage > OutputIterator
output iterator types
ConstReverseIterator rend() const
SetValueIterator< TImage, typename Domain::ConstReverseIterator > ReverseOutputIterator
BOOST_CONCEPT_ASSERT((concepts::CDomain< Domain >))
constant iterator types
ConstReverseIterator rbegin() const
ConstIterator begin() const
ReverseOutputIterator routputIterator(const Point &aPoint) const
DefaultImageRange(const DefaultImageRange &other)
ConstReverseIterator rbegin(const Point &aPoint) const
OutputIterator outputIterator(const Point &aPoint) const
ConstIterator end() const
DefaultImageRange & operator=(const DefaultImageRange &other)
ConstIterator begin(const Point &aPoint) const
ConstIteratorAdapter< typename Domain::ConstIterator, TImage, Value > ConstIterator
BOOST_CONCEPT_ASSERT((concepts::CTrivialImage< TImage >))
Iterator for HyperRectDomain.
Aim: implements an output iterator, which is able to write values in an underlying image,...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:130
Aim: Defines the concept describing an image without extra ranges, which is a refinement of CTrivialC...
Definition: CTrivialImage.h:85
const Point aPoint(3, 4)