DGtal  1.2.0
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 
51 namespace DGtal
52 {
53 
55  // template class SetValueIterator
65  template <typename TImage, typename TIteratorOnPts
68  public std::iterator<std::output_iterator_tag,void,void,void,void>
69  {
70  // ----------------------- Types definitions ------------------------------
71  public:
72 
73  typedef TImage Image;
75 
76 
77  // ----------------------- Standard services ------------------------------
78  public:
84  SetValueIterator(const TIteratorOnPts& aItOnPts, Image &aImg)
85 : myImg(&aImg), myItOnPts(aItOnPts) {}
86 
93 : myImg(&aImg), myItOnPts(myImg->domain().begin()) {}
94 
100 : myImg(other.myImg), myItOnPts(other.myItOnPts) {}
101 
106 
107  // ----------------------- Interface --------------------------------------
108  public:
109 
115  SetValueIterator& operator=(const typename Image::Value& aValue)
116  {
117  myImg->setValue( *myItOnPts, aValue );
118  return *this;
119  }
120 
125  SetValueIterator& operator*() { return *this; }
126 
131  SetValueIterator& operator++() { ++myItOnPts; return *this; }
132 
138  {
139  SetValueIterator tmp = *this;
140  ++myItOnPts;
141  return tmp;
142  }
143 
144 
145  // ------------------------- Private Datas --------------------------------
146  private:
147 
148  // ------------------------- Hidden services ------------------------------
149  protected:
150 
151 
152  private:
153 
154 
155  // ------------------------- Internals ------------------------------------
156  private:
157 
162 
166  TIteratorOnPts myItOnPts;
167 
168  }; // end of class SetValueIterator
169 
170 }
172 // Includes inline functions.
173 //#include "DGtal/images/SetValueIterator.ih"
174 
175 //
177 
178 #endif // !defined SetValueIterator_h
179 
180 #undef SetValueIterator_RECURSES
181 #endif // else defined(SetValueIterator_RECURSES)
Aim: implements an output iterator, which is able to write values in an underlying image,...
BOOST_CONCEPT_ASSERT((concepts::CTrivialImage< Image >))
SetValueIterator(const SetValueIterator &other)
SetValueIterator & operator++()
SetValueIterator & operator*()
SetValueIterator(const TIteratorOnPts &aItOnPts, Image &aImg)
SetValueIterator & operator=(const typename Image::Value &aValue)
SetValueIterator operator++(int)
MyDigitalSurface::ConstIterator ConstIterator
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...
Definition: CTrivialImage.h:85
Domain domain