Blender  V2.93
StrokeIterators.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
24 #include "Stroke.h"
25 
26 namespace Freestyle {
27 
28 namespace StrokeInternal {
29 
30 //
31 // StrokeVertexIterator
32 //
34 
48  public:
51  {
52  }
53 
56  {
57  _it = vi._it;
58  _begin = vi._begin;
59  _end = vi._end;
60  }
61 
62  StrokeVertexIterator(const Stroke::vertex_container::iterator &it,
63  const Stroke::vertex_container::iterator &begin,
64  const Stroke::vertex_container::iterator &end)
65  {
66  _it = it;
67  _begin = begin;
68  _end = end;
69  }
70 
72  {
73  }
74 
79  {
81  return ret;
82  }
83 
90  {
91  _it = vi._it;
92  _begin = vi._begin;
93  _end = vi._end;
94  return *this;
95  }
96 
98  virtual string getExactTypeName() const
99  {
100  return "StrokeVertexIterator";
101  }
102 
107  {
108  return **_it;
109  }
110 
115  {
116  return &(operator*());
117  }
118 
121  {
122  increment();
123  return *this;
124  }
125 
128  {
129  StrokeVertexIterator ret(*this);
130  increment();
131  return ret;
132  }
133 
136  {
137  decrement();
138  return *this;
139  }
140 
143  {
144  StrokeVertexIterator ret(*this);
145  decrement();
146  return ret;
147  }
148 
150  virtual int increment()
151  {
152  ++_it;
153  return 0;
154  }
155 
157  virtual int decrement()
158  {
159  --_it;
160  return 0;
161  }
162 
164  bool isBegin() const
165  {
166  return _it == _begin;
167  }
168 
170  bool atLast()
171  {
172  if (_it == _end) {
173  return false;
174  }
175 
176  ++_it;
177  bool result = (_it == _end);
178  --_it;
179  return result;
180  }
181 
183  bool isEnd() const
184  {
185  return _it == _end;
186  }
187 
189  virtual bool operator==(const Interface0DIteratorNested &it) const
190  {
191  const StrokeVertexIterator *it_exact = dynamic_cast<const StrokeVertexIterator *>(&it);
192  if (!it_exact) {
193  return false;
194  }
195  return (_it == it_exact->_it);
196  }
197 
199  virtual float t() const
200  {
201  return (*_it)->curvilinearAbscissa();
202  }
203 
205  virtual float u() const
206  {
207  return (*_it)->u();
208  }
209 
211  virtual StrokeVertexIterator *copy() const
212  {
213  return new StrokeVertexIterator(*this);
214  }
215 
216  //
217  // Not exported in Python
218  //
220  const Stroke::vertex_container::iterator &getIt()
221  {
222  return _it;
223  }
224 
225  private:
226  Stroke::vertex_container::iterator _it;
227  Stroke::vertex_container::iterator _begin;
228  Stroke::vertex_container::iterator _end;
229 };
230 
231 } // end of namespace StrokeInternal
232 
233 } /* namespace Freestyle */
Classes to define a stroke.
Interface0DIterator castToInterface0DIterator() const
virtual bool operator==(const Interface0DIteratorNested &it) const
virtual StrokeVertexIterator & operator--()
StrokeVertexIterator(const Stroke::vertex_container::iterator &it, const Stroke::vertex_container::iterator &begin, const Stroke::vertex_container::iterator &end)
StrokeVertexIterator(const StrokeVertexIterator &vi)
StrokeVertexIterator & operator=(const StrokeVertexIterator &vi)
virtual StrokeVertexIterator operator++(int)
virtual StrokeVertexIterator operator--(int)
const Stroke::vertex_container::iterator & getIt()
virtual StrokeVertexIterator * copy() const
virtual StrokeVertexIterator & operator++()
inherits from class Rep
Definition: AppCanvas.cpp:32
return ret