DGtal 1.4.2
Loading...
Searching...
No Matches
SetValueIterator.h
1
17#pragma once
18
31#if defined(SetValueIterator_RECURSES)
32#error Recursive header files inclusion detected in SetValueIterator.h
33#else // defined(SetValueIterator_RECURSES)
35#define SetValueIterator_RECURSES
36
37#if !defined SetValueIterator_h
39#define SetValueIterator_h
40
42// Inclusions
43#include "DGtal/base/Common.h"
44#include "DGtal/kernel/domains/CDomain.h"
45#include "DGtal/images/CTrivialImage.h"
46
47#include <iostream>
48
50
51namespace DGtal
52{
53
55 // template class SetValueIterator
65 template <typename TImage, typename TIteratorOnPts
66 = typename TImage::Domain::ConstIterator>
68 {
69 // ----------------------- Types definitions ------------------------------
70 public:
71
72 using iterator_category = std::output_iterator_tag;
73 using value_type = void;
74 using difference_type = void;
75 using pointer = void;
76 using reference = void;
77
78 typedef TImage Image;
80
81
82 // ----------------------- Standard services ------------------------------
83 public:
89 SetValueIterator(const TIteratorOnPts& aItOnPts, Image &aImg)
90: myImg(&aImg), myItOnPts(aItOnPts) {}
91
98: myImg(&aImg), myItOnPts(myImg->domain().begin()) {}
99
105: myImg(other.myImg), myItOnPts(other.myItOnPts) {}
106
111
112 // ----------------------- Interface --------------------------------------
113 public:
114
120 SetValueIterator& operator=(const typename Image::Value& aValue)
121 {
122 myImg->setValue( *myItOnPts, aValue );
123 return *this;
124 }
125
130 SetValueIterator& operator*() { return *this; }
131
136 SetValueIterator& operator++() { ++myItOnPts; return *this; }
137
143 {
144 SetValueIterator tmp = *this;
145 ++myItOnPts;
146 return tmp;
147 }
148
149
150 // ------------------------- Private Datas --------------------------------
151 private:
152
153 // ------------------------- Hidden services ------------------------------
154 protected:
155
156
157 private:
158
159
160 // ------------------------- Internals ------------------------------------
161 private:
162
167
171 TIteratorOnPts myItOnPts;
172
173 }; // end of class SetValueIterator
174
175}
177// Includes inline functions.
178//#include "DGtal/images/SetValueIterator.ih"
179
180//
182
183#endif // !defined SetValueIterator_h
184
185#undef SetValueIterator_RECURSES
186#endif // else defined(SetValueIterator_RECURSES)
Aim: implements an output iterator, which is able to write values in an underlying image,...
std::output_iterator_tag iterator_category
BOOST_CONCEPT_ASSERT((concepts::CTrivialImage< Image >))
SetValueIterator(const SetValueIterator &other)
SetValueIterator & operator*()
SetValueIterator(const TIteratorOnPts &aItOnPts, Image &aImg)
SetValueIterator & operator=(const typename Image::Value &aValue)
SetValueIterator & operator++()
SetValueIterator operator++(int)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines the concept describing an image without extra ranges, which is a refinement of CTrivialC...
Domain domain