Blender  V3.3
StrokeIterators.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #include "Stroke.h"
11 
12 namespace Freestyle {
13 
14 namespace StrokeInternal {
15 
16 //
17 // StrokeVertexIterator
18 //
20 
34  public:
37  {
38  }
39 
42  {
43  _it = vi._it;
44  _begin = vi._begin;
45  _end = vi._end;
46  }
47 
48  StrokeVertexIterator(const Stroke::vertex_container::iterator &it,
49  const Stroke::vertex_container::iterator &begin,
50  const Stroke::vertex_container::iterator &end)
51  {
52  _it = it;
53  _begin = begin;
54  _end = end;
55  }
56 
58  {
59  }
60 
65  {
67  return ret;
68  }
69 
76  {
77  _it = vi._it;
78  _begin = vi._begin;
79  _end = vi._end;
80  return *this;
81  }
82 
84  virtual string getExactTypeName() const
85  {
86  return "StrokeVertexIterator";
87  }
88 
93  {
94  return **_it;
95  }
96 
101  {
102  return &(operator*());
103  }
104 
107  {
108  increment();
109  return *this;
110  }
111 
114  {
115  StrokeVertexIterator ret(*this);
116  increment();
117  return ret;
118  }
119 
122  {
123  decrement();
124  return *this;
125  }
126 
129  {
130  StrokeVertexIterator ret(*this);
131  decrement();
132  return ret;
133  }
134 
136  virtual int increment()
137  {
138  ++_it;
139  return 0;
140  }
141 
143  virtual int decrement()
144  {
145  --_it;
146  return 0;
147  }
148 
150  bool isBegin() const
151  {
152  return _it == _begin;
153  }
154 
156  bool atLast()
157  {
158  if (_it == _end) {
159  return false;
160  }
161 
162  ++_it;
163  bool result = (_it == _end);
164  --_it;
165  return result;
166  }
167 
169  bool isEnd() const
170  {
171  return _it == _end;
172  }
173 
175  virtual bool operator==(const Interface0DIteratorNested &it) const
176  {
177  const StrokeVertexIterator *it_exact = dynamic_cast<const StrokeVertexIterator *>(&it);
178  if (!it_exact) {
179  return false;
180  }
181  return (_it == it_exact->_it);
182  }
183 
185  virtual float t() const
186  {
187  return (*_it)->curvilinearAbscissa();
188  }
189 
191  virtual float u() const
192  {
193  return (*_it)->u();
194  }
195 
197  virtual StrokeVertexIterator *copy() const
198  {
199  return new StrokeVertexIterator(*this);
200  }
201 
202  //
203  // Not exported in Python
204  //
206  const Stroke::vertex_container::iterator &getIt()
207  {
208  return _it;
209  }
210 
211  private:
212  Stroke::vertex_container::iterator _it;
213  Stroke::vertex_container::iterator _begin;
214  Stroke::vertex_container::iterator _end;
215 };
216 
217 } // end of namespace StrokeInternal
218 
219 } /* 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:18
return ret