Blender V5.0
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
11
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#include "MEM_guardedalloc.h"
24
25using namespace std;
26
27namespace Freestyle {
28
29//
30// Interface0D
31//
33
34class FEdge;
35class SVertex;
36class ViewVertex;
37class NonTVertex;
38class TVertex;
39
42 public:
45
47 virtual ~Interface0D() {};
48
50 virtual string getExactTypeName() const
51 {
52 return "Interface0D";
53 }
54
55 // Data access methods
56
58 virtual real getX() const;
59
61 virtual real getY() const;
62
64 virtual real getZ() const;
65
67 virtual Geometry::Vec3r getPoint3D() const;
68
70 virtual real getProjectedX() const;
71
73 virtual real getProjectedY() const;
74
76 virtual real getProjectedZ() const;
77
79 virtual Geometry::Vec2r getPoint2D() const;
80
83 virtual FEdge *getFEdge(Interface0D &);
84
86 virtual Id getId() const;
87
89 virtual Nature::VertexNature getNature() const;
90
92 virtual SVertex *castToSVertex();
93
96
99
101 virtual TVertex *castToTVertex();
102
103 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Interface0D")
104};
105
106//
107// Interface0DIteratorNested
108//
110
112 public:
114
115 virtual string getExactTypeName() const
116 {
117 return "Interface0DIteratorNested";
118 }
119
120 virtual Interface0D &operator*() = 0;
121
123 {
124 return &(operator*());
125 }
126
127 virtual int increment() = 0;
128
129 virtual int decrement() = 0;
130
131 virtual bool isBegin() const = 0;
132
133 virtual bool isEnd() const = 0;
134
135 virtual bool operator==(const Interface0DIteratorNested &it) const = 0;
136
137 virtual bool operator!=(const Interface0DIteratorNested &it) const
138 {
139 return !(*this == it);
140 }
141
143 virtual float t() const = 0;
144
146 virtual float u() const = 0;
147
148 virtual Interface0DIteratorNested *copy() const = 0;
149};
150
151//
152// Interface0DIterator
153//
155
163 public:
165 {
166 _iterator = it;
167 }
168
171 {
172 _iterator = it._iterator->copy();
173 }
174
177 {
178 if (_iterator) {
179 delete _iterator;
180 }
181 }
182
189 {
190 if (_iterator) {
191 delete _iterator;
192 }
193 _iterator = it._iterator->copy();
194 return *this;
195 }
196
198 virtual string getExactTypeName() const
199 {
200 if (!_iterator) {
201 return "Interface0DIterator";
202 }
203 return _iterator->getExactTypeName() + "Proxy";
204 }
205
206 // FIXME test it != 0 (exceptions ?)
207
212 {
213 return _iterator->operator*();
214 }
215
220 {
221 return &(operator*());
222 }
223
226 {
227 _iterator->increment();
228 return *this;
229 }
230
233 {
235 _iterator->increment();
236 return ret;
237 }
238
241 {
242 _iterator->decrement();
243 return *this;
244 }
245
248 {
250 _iterator->decrement();
251 return ret;
252 }
253
255 virtual int increment()
256 {
257 return _iterator->increment();
258 }
259
261 virtual int decrement()
262 {
263 return _iterator->decrement();
264 }
265
269 virtual bool isBegin() const
270 {
271 return _iterator->isBegin();
272 }
273
276 virtual bool isEnd() const
277 {
278 return _iterator->isEnd();
279 }
280
282 virtual bool atLast() const
283 {
284 if (_iterator->isEnd()) {
285 return false;
286 }
287
288 _iterator->increment();
289 bool result = _iterator->isEnd();
290 _iterator->decrement();
291 return result;
292 }
293
295 bool operator==(const Interface0DIterator &it) const
296 {
297 return _iterator->operator==(*(it._iterator));
298 }
299
301 bool operator!=(const Interface0DIterator &it) const
302 {
303 return !(*this == it);
304 }
305
307 inline float t() const
308 {
309 return _iterator->t();
310 }
311
313 inline float u() const
314 {
315 return _iterator->u();
316 }
317
318 protected:
320};
321
322} /* 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:50
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
VecMat::Vec2< real > Vec2r
Definition Geom.h:24
VecMat::Vec3< real > Vec3r
Definition Geom.h:30
ushort VertexNature
Definition Nature.h:22
inherits from class Rep
Definition AppCanvas.cpp:20
double real
Definition Precision.h:14
return ret