Blender V4.3
Interface0D.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 <iostream>
13#include <string>
14
15#include "../geometry/Geom.h"
16
17#include "../system/Id.h"
18#include "../system/Iterator.h"
19#include "../system/Precision.h"
20
22
23#ifdef WITH_CXX_GUARDEDALLOC
24# include "MEM_guardedalloc.h"
25#endif
26
27using namespace std;
28
29namespace Freestyle {
30
31//
32// Interface0D
33//
35
36class FEdge;
37class SVertex;
38class ViewVertex;
39class NonTVertex;
40class TVertex;
41
44 public:
47
49 virtual ~Interface0D(){};
50
52 virtual string getExactTypeName() const
53 {
54 return "Interface0D";
55 }
56
57 // Data access methods
58
60 virtual real getX() const;
61
63 virtual real getY() const;
64
66 virtual real getZ() const;
67
69 virtual Geometry::Vec3r getPoint3D() const;
70
72 virtual real getProjectedX() const;
73
75 virtual real getProjectedY() const;
76
78 virtual real getProjectedZ() const;
79
81 virtual Geometry::Vec2r getPoint2D() const;
82
85 virtual FEdge *getFEdge(Interface0D &);
86
88 virtual Id getId() const;
89
91 virtual Nature::VertexNature getNature() const;
92
94 virtual SVertex *castToSVertex();
95
98
100 virtual NonTVertex *castToNonTVertex();
101
103 virtual TVertex *castToTVertex();
104
105#ifdef WITH_CXX_GUARDEDALLOC
106 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Interface0D")
107#endif
108};
109
110//
111// Interface0DIteratorNested
112//
114
116 public:
118
119 virtual string getExactTypeName() const
120 {
121 return "Interface0DIteratorNested";
122 }
123
124 virtual Interface0D &operator*() = 0;
125
127 {
128 return &(operator*());
129 }
130
131 virtual int increment() = 0;
132
133 virtual int decrement() = 0;
134
135 virtual bool isBegin() const = 0;
136
137 virtual bool isEnd() const = 0;
138
139 virtual bool operator==(const Interface0DIteratorNested &it) const = 0;
140
141 virtual bool operator!=(const Interface0DIteratorNested &it) const
142 {
143 return !(*this == it);
144 }
145
147 virtual float t() const = 0;
148
150 virtual float u() const = 0;
151
152 virtual Interface0DIteratorNested *copy() const = 0;
153};
154
155//
156// Interface0DIterator
157//
159
167 public:
169 {
170 _iterator = it;
171 }
172
175 {
176 _iterator = it._iterator->copy();
177 }
178
181 {
182 if (_iterator) {
183 delete _iterator;
184 }
185 }
186
193 {
194 if (_iterator) {
195 delete _iterator;
196 }
197 _iterator = it._iterator->copy();
198 return *this;
199 }
200
202 virtual string getExactTypeName() const
203 {
204 if (!_iterator) {
205 return "Interface0DIterator";
206 }
207 return _iterator->getExactTypeName() + "Proxy";
208 }
209
210 // FIXME test it != 0 (exceptions ?)
211
216 {
217 return _iterator->operator*();
218 }
219
224 {
225 return &(operator*());
226 }
227
230 {
231 _iterator->increment();
232 return *this;
233 }
234
237 {
239 _iterator->increment();
240 return ret;
241 }
242
245 {
246 _iterator->decrement();
247 return *this;
248 }
249
252 {
254 _iterator->decrement();
255 return ret;
256 }
257
259 virtual int increment()
260 {
261 return _iterator->increment();
262 }
263
265 virtual int decrement()
266 {
267 return _iterator->decrement();
268 }
269
273 virtual bool isBegin() const
274 {
275 return _iterator->isBegin();
276 }
277
280 virtual bool isEnd() const
281 {
282 return _iterator->isEnd();
283 }
284
286 virtual bool atLast() const
287 {
288 if (_iterator->isEnd()) {
289 return false;
290 }
291
292 _iterator->increment();
293 bool result = _iterator->isEnd();
294 _iterator->decrement();
295 return result;
296 }
297
299 bool operator==(const Interface0DIterator &it) const
300 {
301 return _iterator->operator==(*(it._iterator));
302 }
303
305 bool operator!=(const Interface0DIterator &it) const
306 {
307 return !(*this == it);
308 }
309
311 inline float t() const
312 {
313 return _iterator->t();
314 }
315
317 inline float u() const
318 {
319 return _iterator->u();
320 }
321
322 protected:
324};
325
326} /* namespace Freestyle */
Vectors and Matrices (useful type definitions)
Identification system.
Read Guarded memory(de)allocation.
Different natures for both vertices and edges.
Define the float precision used in the program.
virtual bool operator==(const Interface0DIteratorNested &it) const =0
virtual bool isEnd() const =0
virtual float u() const =0
virtual Interface0DIteratorNested * copy() const =0
virtual Interface0D & operator*()=0
virtual float t() const =0
virtual Interface0D * operator->()
virtual bool isBegin() const =0
virtual string getExactTypeName() const
virtual bool operator!=(const Interface0DIteratorNested &it) const
Interface0DIterator & operator++()
Interface0DIterator operator++(int)
Interface0DIterator(Interface0DIteratorNested *it=nullptr)
Interface0DIterator(const Interface0DIterator &it)
virtual bool atLast() const
virtual bool isBegin() const
bool operator==(const Interface0DIterator &it) const
Interface0DIterator operator--(int)
virtual string getExactTypeName() const
virtual bool isEnd() const
Interface0DIterator & operator=(const Interface0DIterator &it)
Interface0DIteratorNested * _iterator
bool operator!=(const Interface0DIterator &it) const
Interface0DIterator & operator--()
virtual real getProjectedX() const
virtual real getZ() const
virtual Geometry::Vec2r getPoint2D() const
virtual FEdge * getFEdge(Interface0D &)
virtual string getExactTypeName() const
Definition Interface0D.h:52
virtual real getY() const
virtual ViewVertex * castToViewVertex()
virtual NonTVertex * castToNonTVertex()
virtual Nature::VertexNature getNature() const
virtual TVertex * castToTVertex()
virtual Id getId() const
virtual Geometry::Vec3r getPoint3D() const
virtual real getProjectedZ() const
virtual real getX() const
virtual SVertex * castToSVertex()
virtual real getProjectedY() const
ushort VertexNature
Definition Nature.h:22
inherits from class Rep
Definition AppCanvas.cpp:20
double real
Definition Precision.h:14
return ret