Blender  V2.93
ViewEdgeXBuilder.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 <map>
25 #include <utility>
26 #include <vector>
27 
28 #if 0 // soc
29 # if defined(__GNUC__) && (__GNUC__ >= 3)
30 /* hash_map is not part of the C++ standard anymore;
31  * hash_map.h has been kept though for backward compatibility */
32 # include <hash_map.h>
33 # else
34 # include <hash_map>
35 # endif
36 #endif
37 
38 #include "Interface1D.h"
39 
40 #include "../geometry/Geom.h"
41 
42 #include "../system/FreestyleConfig.h"
43 
44 #ifdef WITH_CXX_GUARDEDALLOC
45 # include "MEM_guardedalloc.h"
46 #endif
47 
48 using namespace std;
49 
50 namespace Freestyle {
51 
52 using namespace Geometry;
53 
54 class SVertex;
55 
57 struct SVertexHasher {
58 #define _MUL 950706376UL
59 #define _MOD 2147483647UL
60  inline size_t operator()(const Vec3r &p) const
61  {
62  size_t res = ((unsigned long)(p[0] * _MUL)) % _MOD;
63  res = ((res + (unsigned long)(p[1]) * _MUL)) % _MOD;
64  return ((res + (unsigned long)(p[2]) * _MUL)) % _MOD;
65  }
66 #undef _MUL
67 #undef _MOD
68 };
69 
70 // Key_compare predicate for hash_map. In particular, return false if equal.
71 struct epsilonEquals {
72  bool operator()(const Vec3r &v1, const Vec3r &v2) const
73  {
74  real norm = (v1 - v2).norm();
75  return (norm < 1.0e-06);
76  }
77 };
78 
79 // typedef hash_map<Vec3r, SVertex*, SVertexHasher, epsilonEquals> SVertexMap;
80 typedef map<Vec3r, SVertex *> SVertexMap;
81 
82 class WXFaceLayer;
83 
85 class OWXFaceLayer {
86  public:
88  bool order;
89 
91  {
92  fl = NULL;
93  order = true;
94  }
95 
96  OWXFaceLayer(WXFaceLayer *ifl, bool iOrder = true)
97  {
98  fl = ifl;
99  order = iOrder;
100  }
101 
103  {
104  fl = iBrother.fl;
105  order = iBrother.order;
106  return *this;
107  }
108 
109  bool operator==(const OWXFaceLayer &b)
110  {
111  return ((fl == b.fl) && (order == b.order));
112  }
113 
114  bool operator!=(const OWXFaceLayer &b)
115  {
116  return !(*this == b);
117  }
118 
119 #ifdef WITH_CXX_GUARDEDALLOC
120  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OWXFaceLayer")
121 #endif
122 };
123 
124 class WXEdge;
125 
127 class OWXEdge {
128  public:
130  bool order;
131 
133  {
134  e = NULL;
135  order = true;
136  }
137 
138  OWXEdge(WXEdge *ie, bool iOrder = true)
139  {
140  e = ie;
141  order = iOrder;
142  }
143 
144  OWXEdge &operator=(const OWXEdge &iBrother)
145  {
146  e = iBrother.e;
147  order = iBrother.order;
148  return *this;
149  }
150 
151  bool operator==(const OWXEdge &b)
152  {
153  return ((e == b.e) && (order == b.order));
154  }
155 
156  bool operator!=(const OWXEdge &b)
157  {
158  return !(*this == b);
159  }
160 
161 #ifdef WITH_CXX_GUARDEDALLOC
162  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OWXEdge")
163 #endif
164 };
165 
166 class WOEdge;
167 class WXEdge;
168 class WXShape;
169 class SVertex;
170 class FEdge;
171 class ViewVertex;
172 class ViewEdge;
173 class ViewShape;
174 
176  protected:
177  int _currentViewId; // Id for view edges
178  int _currentFId; // Id for FEdges
179  int _currentSVertexId; // Id for SVertex
180 
181  public:
183  {
184  _currentViewId = 1;
185  _currentFId = 0;
186  _currentSVertexId = 0;
187  }
188 
190  {
191  }
192 
208  virtual void BuildViewEdges(WXShape *iWShape,
209  ViewShape *oVShape,
210  std::vector<ViewEdge *> &ioVEdges,
211  std::vector<ViewVertex *> &ioVVertices,
212  std::vector<FEdge *> &ioFEdges,
213  std::vector<SVertex *> &ioSVertices);
214 
216  ViewEdge *BuildSmoothViewEdge(const OWXFaceLayer &iFaceLayer);
217 
219  ViewEdge *BuildSharpViewEdge(const OWXEdge &iWEdge);
220 
221  public:
223  inline int currentViewId() const
224  {
225  return _currentViewId;
226  }
227 
228  inline int currentFId() const
229  {
230  return _currentFId;
231  }
232 
233  inline int currentSVertexId() const
234  {
235  return _currentSVertexId;
236  }
237 
239  inline void setCurrentViewId(int id)
240  {
241  _currentViewId = id;
242  }
243 
244  inline void setCurrentFId(int id)
245  {
246  _currentFId = id;
247  }
248 
249  inline void setCurrentSVertexId(int id)
250  {
251  _currentSVertexId = id;
252  }
253 
254  protected:
256  virtual void Init(ViewShape *oVShape);
257 
258  // SMOOTH //
260  bool stopSmoothViewEdge(WXFaceLayer *iFaceLayer);
261  OWXFaceLayer FindNextFaceLayer(const OWXFaceLayer &iFaceLayer);
262  OWXFaceLayer FindPreviousFaceLayer(const OWXFaceLayer &iFaceLayer);
263  FEdge *BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer &ifl);
264 
265  // SHARP //
267  bool stopSharpViewEdge(WXEdge *iEdge);
268  int retrieveFaceMarks(WXEdge *iEdge);
269  OWXEdge FindNextWEdge(const OWXEdge &iEdge);
270  OWXEdge FindPreviousWEdge(const OWXEdge &iEdge);
271  FEdge *BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe);
272 
273  // GENERAL //
275  SVertex *MakeSVertex(Vec3r &iPoint);
277  SVertex *MakeSVertex(Vec3r &iPoint, bool shared);
279  ViewVertex *MakeViewVertex(SVertex *iSVertex);
280 
281  // oldtmp values
282  // IdHashTable _hashtable;
283  // VVIdHashTable _multivertexHashTable;
287 
288 #ifdef WITH_CXX_GUARDEDALLOC
289  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:ViewEdgeXBuilder")
290 #endif
291 };
292 
293 } /* namespace Freestyle */
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint order
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Interface 1D and related tools definitions.
Read Guarded memory(de)allocation.
#define _MOD
#define _MUL
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Definition: btVector3.h:263
bool operator!=(const OWXEdge &b)
OWXEdge & operator=(const OWXEdge &iBrother)
OWXEdge(WXEdge *ie, bool iOrder=true)
bool operator==(const OWXEdge &b)
OWXFaceLayer(WXFaceLayer *ifl, bool iOrder=true)
bool operator==(const OWXFaceLayer &b)
OWXFaceLayer & operator=(const OWXFaceLayer &iBrother)
bool operator!=(const OWXFaceLayer &b)
inherits from class Rep
Definition: AppCanvas.cpp:32
map< Vec3r, SVertex * > SVertexMap
double real
Definition: Precision.h:26
size_t operator()(const Vec3r &p) const
bool operator()(const Vec3r &v1, const Vec3r &v2) const