Blender V4.3
StrokeIterators.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
12#include "Stroke.h"
13
14namespace Freestyle {
15
16namespace StrokeInternal {
17
18//
19// StrokeVertexIterator
20//
22
36 public:
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
67
74 {
75 _it = vi._it;
76 _begin = vi._begin;
77 _end = vi._end;
78 return *this;
79 }
80
82 virtual string getExactTypeName() const
83 {
84 return "StrokeVertexIterator";
85 }
86
91 {
92 return **_it;
93 }
94
99 {
100 return &(operator*());
101 }
102
105 {
106 increment();
107 return *this;
108 }
109
112 {
114 increment();
115 return ret;
116 }
117
120 {
121 decrement();
122 return *this;
123 }
124
127 {
129 decrement();
130 return ret;
131 }
132
134 virtual int increment()
135 {
136 ++_it;
137 return 0;
138 }
139
141 virtual int decrement()
142 {
143 --_it;
144 return 0;
145 }
146
148 bool isBegin() const
149 {
150 return _it == _begin;
151 }
152
154 bool atLast()
155 {
156 if (_it == _end) {
157 return false;
158 }
159
160 ++_it;
161 bool result = (_it == _end);
162 --_it;
163 return result;
164 }
165
167 bool isEnd() const
168 {
169 return _it == _end;
170 }
171
173 virtual bool operator==(const Interface0DIteratorNested &it) const
174 {
175 const StrokeVertexIterator *it_exact = dynamic_cast<const StrokeVertexIterator *>(&it);
176 if (!it_exact) {
177 return false;
178 }
179 return (_it == it_exact->_it);
180 }
181
183 virtual float t() const
184 {
185 return (*_it)->curvilinearAbscissa();
186 }
187
189 virtual float u() const
190 {
191 return (*_it)->u();
192 }
193
195 virtual StrokeVertexIterator *copy() const
196 {
197 return new StrokeVertexIterator(*this);
198 }
199
200 //
201 // Not exported in Python
202 //
204 const Stroke::vertex_container::iterator &getIt()
205 {
206 return _it;
207 }
208
209 private:
210 Stroke::vertex_container::iterator _it;
211 Stroke::vertex_container::iterator _begin;
212 Stroke::vertex_container::iterator _end;
213};
214
215} // end of namespace StrokeInternal
216
217} /* namespace Freestyle */
Classes to define a stroke.
virtual StrokeVertexIterator & operator++()
Interface0DIterator castToInterface0DIterator() const
virtual bool operator==(const Interface0DIteratorNested &it) const
virtual StrokeVertexIterator * copy() const
StrokeVertexIterator(const Stroke::vertex_container::iterator &it, const Stroke::vertex_container::iterator &begin, const Stroke::vertex_container::iterator &end)
StrokeVertexIterator & operator=(const StrokeVertexIterator &vi)
const Stroke::vertex_container::iterator & getIt()
StrokeVertexIterator(const StrokeVertexIterator &vi)
virtual StrokeVertexIterator & operator--()
virtual StrokeVertexIterator operator++(int)
virtual StrokeVertexIterator operator--(int)
inherits from class Rep
Definition AppCanvas.cpp:20
return ret