Blender  V2.93
Interface0D.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
24 #include <iostream>
25 #include <string>
26 
27 #include "../geometry/Geom.h"
28 
29 #include "../system/Id.h"
30 #include "../system/Iterator.h"
31 #include "../system/Precision.h"
32 
33 #include "../winged_edge/Nature.h"
34 
35 #ifdef WITH_CXX_GUARDEDALLOC
36 # include "MEM_guardedalloc.h"
37 #endif
38 
39 using namespace std;
40 
41 namespace Freestyle {
42 
43 //
44 // Interface0D
45 //
47 
48 class FEdge;
49 class SVertex;
50 class ViewVertex;
51 class NonTVertex;
52 class TVertex;
53 
55 class Interface0D {
56  public:
59  {
60  }
61 
63  virtual ~Interface0D(){};
64 
66  virtual string getExactTypeName() const
67  {
68  return "Interface0D";
69  }
70 
71  // Data access methods
72 
74  virtual real getX() const;
75 
77  virtual real getY() const;
78 
80  virtual real getZ() const;
81 
83  virtual Geometry::Vec3r getPoint3D() const;
84 
86  virtual real getProjectedX() const;
87 
89  virtual real getProjectedY() const;
90 
92  virtual real getProjectedZ() const;
93 
95  virtual Geometry::Vec2r getPoint2D() const;
96 
99  virtual FEdge *getFEdge(Interface0D &);
100 
102  virtual Id getId() const;
103 
105  virtual Nature::VertexNature getNature() const;
106 
108  virtual SVertex *castToSVertex();
109 
111  virtual ViewVertex *castToViewVertex();
112 
114  virtual NonTVertex *castToNonTVertex();
115 
117  virtual TVertex *castToTVertex();
118 
119 #ifdef WITH_CXX_GUARDEDALLOC
120  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Interface0D")
121 #endif
122 };
123 
124 //
125 // Interface0DIteratorNested
126 //
128 
130  public:
132  {
133  }
134 
135  virtual string getExactTypeName() const
136  {
137  return "Interface0DIteratorNested";
138  }
139 
140  virtual Interface0D &operator*() = 0;
141 
143  {
144  return &(operator*());
145  }
146 
147  virtual int increment() = 0;
148 
149  virtual int decrement() = 0;
150 
151  virtual bool isBegin() const = 0;
152 
153  virtual bool isEnd() const = 0;
154 
155  virtual bool operator==(const Interface0DIteratorNested &it) const = 0;
156 
157  virtual bool operator!=(const Interface0DIteratorNested &it) const
158  {
159  return !(*this == it);
160  }
161 
163  virtual float t() const = 0;
164 
166  virtual float u() const = 0;
167 
168  virtual Interface0DIteratorNested *copy() const = 0;
169 };
170 
171 //
172 // Interface0DIterator
173 //
175 
183  public:
185  {
186  _iterator = it;
187  }
188 
191  {
192  _iterator = it._iterator->copy();
193  }
194 
197  {
198  if (_iterator) {
199  delete _iterator;
200  }
201  }
202 
209  {
210  if (_iterator) {
211  delete _iterator;
212  }
213  _iterator = it._iterator->copy();
214  return *this;
215  }
216 
218  virtual string getExactTypeName() const
219  {
220  if (!_iterator) {
221  return "Interface0DIterator";
222  }
223  return _iterator->getExactTypeName() + "Proxy";
224  }
225 
226  // FIXME test it != 0 (exceptions ?)
227 
232  {
233  return _iterator->operator*();
234  }
235 
240  {
241  return &(operator*());
242  }
243 
246  {
247  _iterator->increment();
248  return *this;
249  }
250 
253  {
254  Interface0DIterator ret(*this);
255  _iterator->increment();
256  return ret;
257  }
258 
261  {
262  _iterator->decrement();
263  return *this;
264  }
265 
268  {
269  Interface0DIterator ret(*this);
270  _iterator->decrement();
271  return ret;
272  }
273 
275  virtual int increment()
276  {
277  return _iterator->increment();
278  }
279 
281  virtual int decrement()
282  {
283  return _iterator->decrement();
284  }
285 
289  virtual bool isBegin() const
290  {
291  return _iterator->isBegin();
292  }
293 
296  virtual bool isEnd() const
297  {
298  return _iterator->isEnd();
299  }
300 
302  virtual bool atLast() const
303  {
304  if (_iterator->isEnd()) {
305  return false;
306  }
307 
308  _iterator->increment();
309  bool result = _iterator->isEnd();
310  _iterator->decrement();
311  return result;
312  }
313 
315  bool operator==(const Interface0DIterator &it) const
316  {
317  return _iterator->operator==(*(it._iterator));
318  }
319 
321  bool operator!=(const Interface0DIterator &it) const
322  {
323  return !(*this == it);
324  }
325 
327  inline float t() const
328  {
329  return _iterator->t();
330  }
331 
333  inline float u() const
334  {
335  return _iterator->u();
336  }
337 
338  protected:
340 };
341 
342 } /* 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:142
virtual Interface0DIteratorNested * copy() const =0
virtual Interface0D & operator*()=0
virtual bool isBegin() const =0
virtual string getExactTypeName() const
Definition: Interface0D.h:135
virtual bool operator!=(const Interface0DIteratorNested &it) const
Definition: Interface0D.h:157
Interface0DIterator & operator=(const Interface0DIterator &it)
Definition: Interface0D.h:208
Interface0DIterator operator++(int)
Definition: Interface0D.h:252
Interface0DIterator & operator--()
Definition: Interface0D.h:260
Interface0DIterator(const Interface0DIterator &it)
Definition: Interface0D.h:190
virtual bool atLast() const
Definition: Interface0D.h:302
virtual bool isBegin() const
Definition: Interface0D.h:289
Interface0DIterator(Interface0DIteratorNested *it=NULL)
Definition: Interface0D.h:184
bool operator==(const Interface0DIterator &it) const
Definition: Interface0D.h:315
Interface0DIterator operator--(int)
Definition: Interface0D.h:267
virtual string getExactTypeName() const
Definition: Interface0D.h:218
Interface0DIterator & operator++()
Definition: Interface0D.h:245
virtual bool isEnd() const
Definition: Interface0D.h:296
Interface0DIteratorNested * _iterator
Definition: Interface0D.h:339
bool operator!=(const Interface0DIterator &it) const
Definition: Interface0D.h:321
virtual string getExactTypeName() const
Definition: Interface0D.h:66
FEdge * getFEdge(Interface0D &it1, Interface0D &it2)
Definition: Functions0D.cpp:32
unsigned short VertexNature
Definition: Nature.h:32
Vec< T, N > operator*(const typename Vec< T, N >::value_type r, const Vec< T, N > &v)
Definition: VecMat.h:858
inherits from class Rep
Definition: AppCanvas.cpp:32
double real
Definition: Precision.h:26
return ret