Blender  V3.3
Interface0D.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #include <iostream>
11 #include <string>
12 
13 #include "../geometry/Geom.h"
14 
15 #include "../system/Id.h"
16 #include "../system/Iterator.h"
17 #include "../system/Precision.h"
18 
19 #include "../winged_edge/Nature.h"
20 
21 #ifdef WITH_CXX_GUARDEDALLOC
22 # include "MEM_guardedalloc.h"
23 #endif
24 
25 using namespace std;
26 
27 namespace Freestyle {
28 
29 //
30 // Interface0D
31 //
33 
34 class FEdge;
35 class SVertex;
36 class ViewVertex;
37 class NonTVertex;
38 class TVertex;
39 
41 class Interface0D {
42  public:
45  {
46  }
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 
97  virtual ViewVertex *castToViewVertex();
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  }
120 
121  virtual string getExactTypeName() const
122  {
123  return "Interface0DIteratorNested";
124  }
125 
126  virtual Interface0D &operator*() = 0;
127 
129  {
130  return &(operator*());
131  }
132 
133  virtual int increment() = 0;
134 
135  virtual int decrement() = 0;
136 
137  virtual bool isBegin() const = 0;
138 
139  virtual bool isEnd() const = 0;
140 
141  virtual bool operator==(const Interface0DIteratorNested &it) const = 0;
142 
143  virtual bool operator!=(const Interface0DIteratorNested &it) const
144  {
145  return !(*this == it);
146  }
147 
149  virtual float t() const = 0;
150 
152  virtual float u() const = 0;
153 
154  virtual Interface0DIteratorNested *copy() const = 0;
155 };
156 
157 //
158 // Interface0DIterator
159 //
161 
169  public:
171  {
172  _iterator = it;
173  }
174 
177  {
178  _iterator = it._iterator->copy();
179  }
180 
183  {
184  if (_iterator) {
185  delete _iterator;
186  }
187  }
188 
195  {
196  if (_iterator) {
197  delete _iterator;
198  }
199  _iterator = it._iterator->copy();
200  return *this;
201  }
202 
204  virtual string getExactTypeName() const
205  {
206  if (!_iterator) {
207  return "Interface0DIterator";
208  }
209  return _iterator->getExactTypeName() + "Proxy";
210  }
211 
212  // FIXME test it != 0 (exceptions ?)
213 
218  {
219  return _iterator->operator*();
220  }
221 
226  {
227  return &(operator*());
228  }
229 
232  {
233  _iterator->increment();
234  return *this;
235  }
236 
239  {
240  Interface0DIterator ret(*this);
241  _iterator->increment();
242  return ret;
243  }
244 
247  {
248  _iterator->decrement();
249  return *this;
250  }
251 
254  {
255  Interface0DIterator ret(*this);
256  _iterator->decrement();
257  return ret;
258  }
259 
261  virtual int increment()
262  {
263  return _iterator->increment();
264  }
265 
267  virtual int decrement()
268  {
269  return _iterator->decrement();
270  }
271 
275  virtual bool isBegin() const
276  {
277  return _iterator->isBegin();
278  }
279 
282  virtual bool isEnd() const
283  {
284  return _iterator->isEnd();
285  }
286 
288  virtual bool atLast() const
289  {
290  if (_iterator->isEnd()) {
291  return false;
292  }
293 
294  _iterator->increment();
295  bool result = _iterator->isEnd();
296  _iterator->decrement();
297  return result;
298  }
299 
301  bool operator==(const Interface0DIterator &it) const
302  {
303  return _iterator->operator==(*(it._iterator));
304  }
305 
307  bool operator!=(const Interface0DIterator &it) const
308  {
309  return !(*this == it);
310  }
311 
313  inline float t() const
314  {
315  return _iterator->t();
316  }
317 
319  inline float u() const
320  {
321  return _iterator->u();
322  }
323 
324  protected:
326 };
327 
328 } /* namespace Freestyle */
Read Guarded memory(de)allocation.
SIMD_FORCE_INLINE const btScalar & getZ() const
Return the z value.
Definition: btQuadWord.h:103
SIMD_FORCE_INLINE const btScalar & getX() const
Return the x value.
Definition: btQuadWord.h:99
SIMD_FORCE_INLINE const btScalar & getY() const
Return the y value.
Definition: btQuadWord.h:101
virtual bool operator==(const Interface0DIteratorNested &it) const =0
virtual bool isEnd() const =0
virtual float u() const =0
virtual float t() const =0
virtual Interface0D * operator->()
Definition: Interface0D.h:128
virtual Interface0DIteratorNested * copy() const =0
virtual Interface0D & operator*()=0
virtual bool isBegin() const =0
virtual string getExactTypeName() const
Definition: Interface0D.h:121
virtual bool operator!=(const Interface0DIteratorNested &it) const
Definition: Interface0D.h:143
Interface0DIterator & operator=(const Interface0DIterator &it)
Definition: Interface0D.h:194
Interface0DIterator operator++(int)
Definition: Interface0D.h:238
Interface0DIterator & operator--()
Definition: Interface0D.h:246
Interface0DIterator(const Interface0DIterator &it)
Definition: Interface0D.h:176
virtual bool atLast() const
Definition: Interface0D.h:288
virtual bool isBegin() const
Definition: Interface0D.h:275
Interface0DIterator(Interface0DIteratorNested *it=NULL)
Definition: Interface0D.h:170
bool operator==(const Interface0DIterator &it) const
Definition: Interface0D.h:301
Interface0DIterator operator--(int)
Definition: Interface0D.h:253
virtual string getExactTypeName() const
Definition: Interface0D.h:204
Interface0DIterator & operator++()
Definition: Interface0D.h:231
virtual bool isEnd() const
Definition: Interface0D.h:282
Interface0DIteratorNested * _iterator
Definition: Interface0D.h:325
bool operator!=(const Interface0DIterator &it) const
Definition: Interface0D.h:307
virtual string getExactTypeName() const
Definition: Interface0D.h:52
FEdge * getFEdge(Interface0D &it1, Interface0D &it2)
Definition: Functions0D.cpp:18
unsigned short VertexNature
Definition: Nature.h:18
Vec< T, N > operator*(const typename Vec< T, N >::value_type r, const Vec< T, N > &v)
Definition: VecMat.h:844
inherits from class Rep
Definition: AppCanvas.cpp:18
double real
Definition: Precision.h:12
return ret