Blender  V3.3
ViewEdgeXBuilder.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #include <map>
11 #include <utility>
12 #include <vector>
13 
14 #if 0 // soc
15 # if defined(__GNUC__) && (__GNUC__ >= 3)
16 /* hash_map is not part of the C++ standard anymore;
17  * hash_map.h has been kept though for backward compatibility */
18 # include <hash_map.h>
19 # else
20 # include <hash_map>
21 # endif
22 #endif
23 
24 #include "Interface1D.h"
25 
26 #include "../geometry/Geom.h"
27 
28 #include "../system/FreestyleConfig.h"
29 
30 #ifdef WITH_CXX_GUARDEDALLOC
31 # include "MEM_guardedalloc.h"
32 #endif
33 
34 using namespace std;
35 
36 namespace Freestyle {
37 
38 using namespace Geometry;
39 
40 class SVertex;
41 
43 struct SVertexHasher {
44 #define _MUL 950706376UL
45 #define _MOD 2147483647UL
46  inline size_t operator()(const Vec3r &p) const
47  {
48  size_t res = ((unsigned long)(p[0] * _MUL)) % _MOD;
49  res = ((res + (unsigned long)(p[1]) * _MUL)) % _MOD;
50  return ((res + (unsigned long)(p[2]) * _MUL)) % _MOD;
51  }
52 #undef _MUL
53 #undef _MOD
54 };
55 
56 // Key_compare predicate for hash_map. In particular, return false if equal.
57 struct epsilonEquals {
58  bool operator()(const Vec3r &v1, const Vec3r &v2) const
59  {
60  real norm = (v1 - v2).norm();
61  return (norm < 1.0e-06);
62  }
63 };
64 
65 // typedef hash_map<Vec3r, SVertex*, SVertexHasher, epsilonEquals> SVertexMap;
66 typedef map<Vec3r, SVertex *> SVertexMap;
67 
68 class WXFaceLayer;
69 
71 class OWXFaceLayer {
72  public:
74  bool order;
75 
77  {
78  fl = NULL;
79  order = true;
80  }
81 
82  OWXFaceLayer(WXFaceLayer *ifl, bool iOrder = true)
83  {
84  fl = ifl;
85  order = iOrder;
86  }
87 
89  {
90  fl = iBrother.fl;
91  order = iBrother.order;
92  return *this;
93  }
94 
95  bool operator==(const OWXFaceLayer &b)
96  {
97  return ((fl == b.fl) && (order == b.order));
98  }
99 
100  bool operator!=(const OWXFaceLayer &b)
101  {
102  return !(*this == b);
103  }
104 
105 #ifdef WITH_CXX_GUARDEDALLOC
106  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OWXFaceLayer")
107 #endif
108 };
109 
110 class WXEdge;
111 
113 class OWXEdge {
114  public:
116  bool order;
117 
119  {
120  e = NULL;
121  order = true;
122  }
123 
124  OWXEdge(WXEdge *ie, bool iOrder = true)
125  {
126  e = ie;
127  order = iOrder;
128  }
129 
130  OWXEdge &operator=(const OWXEdge &iBrother)
131  {
132  e = iBrother.e;
133  order = iBrother.order;
134  return *this;
135  }
136 
137  bool operator==(const OWXEdge &b)
138  {
139  return ((e == b.e) && (order == b.order));
140  }
141 
142  bool operator!=(const OWXEdge &b)
143  {
144  return !(*this == b);
145  }
146 
147 #ifdef WITH_CXX_GUARDEDALLOC
148  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OWXEdge")
149 #endif
150 };
151 
152 class WOEdge;
153 class WXEdge;
154 class WXShape;
155 class SVertex;
156 class FEdge;
157 class ViewVertex;
158 class ViewEdge;
159 class ViewShape;
160 
162  protected:
163  int _currentViewId; // Id for view edges
164  int _currentFId; // Id for FEdges
165  int _currentSVertexId; // Id for SVertex
166 
167  public:
169  {
170  _currentViewId = 1;
171  _currentFId = 0;
172  _currentSVertexId = 0;
173  }
174 
176  {
177  }
178 
194  virtual void BuildViewEdges(WXShape *iWShape,
195  ViewShape *oVShape,
196  std::vector<ViewEdge *> &ioVEdges,
197  std::vector<ViewVertex *> &ioVVertices,
198  std::vector<FEdge *> &ioFEdges,
199  std::vector<SVertex *> &ioSVertices);
200 
202  ViewEdge *BuildSmoothViewEdge(const OWXFaceLayer &iFaceLayer);
203 
205  ViewEdge *BuildSharpViewEdge(const OWXEdge &iWEdge);
206 
207  public:
209  inline int currentViewId() const
210  {
211  return _currentViewId;
212  }
213 
214  inline int currentFId() const
215  {
216  return _currentFId;
217  }
218 
219  inline int currentSVertexId() const
220  {
221  return _currentSVertexId;
222  }
223 
225  inline void setCurrentViewId(int id)
226  {
227  _currentViewId = id;
228  }
229 
230  inline void setCurrentFId(int id)
231  {
232  _currentFId = id;
233  }
234 
235  inline void setCurrentSVertexId(int id)
236  {
237  _currentSVertexId = id;
238  }
239 
240  protected:
242  virtual void Init(ViewShape *oVShape);
243 
244  // SMOOTH //
246  bool stopSmoothViewEdge(WXFaceLayer *iFaceLayer);
247  OWXFaceLayer FindNextFaceLayer(const OWXFaceLayer &iFaceLayer);
248  OWXFaceLayer FindPreviousFaceLayer(const OWXFaceLayer &iFaceLayer);
249  FEdge *BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer &ifl);
250 
251  // SHARP //
253  bool stopSharpViewEdge(WXEdge *iEdge);
254  int retrieveFaceMarks(WXEdge *iEdge);
255  OWXEdge FindNextWEdge(const OWXEdge &iEdge);
256  OWXEdge FindPreviousWEdge(const OWXEdge &iEdge);
257  FEdge *BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe);
258 
259  // GENERAL //
261  SVertex *MakeSVertex(Vec3r &iPoint);
263  SVertex *MakeSVertex(Vec3r &iPoint, bool shared);
265  ViewVertex *MakeViewVertex(SVertex *iSVertex);
266 
267  // oldtmp values
268  // IdHashTable _hashtable;
269  // VVIdHashTable _multivertexHashTable;
273 
274 #ifdef WITH_CXX_GUARDEDALLOC
275  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:ViewEdgeXBuilder")
276 #endif
277 };
278 
279 } /* 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:18
map< Vec3r, SVertex * > SVertexMap
double real
Definition: Precision.h:12
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
size_t operator()(const Vec3r &p) const
bool operator()(const Vec3r &v1, const Vec3r &v2) const