Blender V5.0
ViewEdgeXBuilder.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 <map>
13#include <utility>
14#include <vector>
15
16#if 0 // soc
17# if defined(__GNUC__) && (__GNUC__ >= 3)
18/* hash_map is not part of the C++ standard anymore;
19 * hash_map.h has been kept though for backward compatibility */
20# include <hash_map.h>
21# else
22# include <hash_map>
23# endif
24#endif
25
26#include "Interface1D.h"
27
28#include "../geometry/Geom.h"
29
31
32#include "MEM_guardedalloc.h"
33
34using namespace std;
35
36namespace Freestyle {
37
38using namespace Geometry;
39
40class SVertex;
41
44#define _MUL 950706376UL
45#define _MOD 2147483647UL
46 inline size_t operator()(const Vec3r &p) const
47 {
48 size_t res = (ulong(p[0] * _MUL)) % _MOD;
49 res = ((res + ulong(p[1]) * _MUL)) % _MOD;
50 return ((res + ulong(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.
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;
66typedef map<Vec3r, SVertex *> SVertexMap;
67
68class WXFaceLayer;
69
72 public:
74 bool order;
75
77 {
78 fl = nullptr;
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
96 {
97 return ((fl == b.fl) && (order == b.order));
98 }
99
101 {
102 return !(*this == b);
103 }
104
105 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OWXFaceLayer")
106};
107
108class WXEdge;
109
111class OWXEdge {
112 public:
114 bool order;
115
117 {
118 e = nullptr;
119 order = true;
120 }
121
122 OWXEdge(WXEdge *ie, bool iOrder = true)
123 {
124 e = ie;
125 order = iOrder;
126 }
127
128 OWXEdge &operator=(const OWXEdge &iBrother)
129 {
130 e = iBrother.e;
131 order = iBrother.order;
132 return *this;
133 }
134
135 bool operator==(const OWXEdge &b)
136 {
137 return ((e == b.e) && (order == b.order));
138 }
139
140 bool operator!=(const OWXEdge &b)
141 {
142 return !(*this == b);
143 }
144
145 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OWXEdge")
146};
147
148class WOEdge;
149class WXEdge;
150class WXShape;
151class SVertex;
152class FEdge;
153class ViewVertex;
154class ViewEdge;
155class ViewShape;
156
158 protected:
159 int _currentViewId; // Id for view edges
160 int _currentFId; // Id for FEdges
161 int _currentSVertexId; // Id for SVertex
162
163 public:
165 {
166 _currentViewId = 1;
167 _currentFId = 0;
169 }
170
171 virtual ~ViewEdgeXBuilder() {}
172
188 virtual void BuildViewEdges(WXShape *iWShape,
189 ViewShape *oVShape,
190 std::vector<ViewEdge *> &ioVEdges,
191 std::vector<ViewVertex *> &ioVVertices,
192 std::vector<FEdge *> &ioFEdges,
193 std::vector<SVertex *> &ioSVertices);
194
196 ViewEdge *BuildSmoothViewEdge(const OWXFaceLayer &iFaceLayer);
197
199 ViewEdge *BuildSharpViewEdge(const OWXEdge &iWEdge);
200
201 public:
203 inline int currentViewId() const
204 {
205 return _currentViewId;
206 }
207
208 inline int currentFId() const
209 {
210 return _currentFId;
211 }
212
213 inline int currentSVertexId() const
214 {
215 return _currentSVertexId;
216 }
217
219 inline void setCurrentViewId(int id)
220 {
221 _currentViewId = id;
222 }
223
224 inline void setCurrentFId(int id)
225 {
226 _currentFId = id;
227 }
228
229 inline void setCurrentSVertexId(int id)
230 {
232 }
233
234 protected:
236 virtual void Init(ViewShape *oVShape);
237
238 // SMOOTH //
240 bool stopSmoothViewEdge(WXFaceLayer *iFaceLayer);
243 FEdge *BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer &ifl);
244
245 // SHARP //
247 bool stopSharpViewEdge(WXEdge *iEdge);
248 int retrieveFaceMarks(WXEdge *iEdge);
249 OWXEdge FindNextWEdge(const OWXEdge &iEdge);
250 OWXEdge FindPreviousWEdge(const OWXEdge &iEdge);
251 FEdge *BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe);
252
253 // GENERAL //
255 SVertex *MakeSVertex(Vec3r &iPoint);
257 SVertex *MakeSVertex(Vec3r &iPoint, bool shared);
260
261 // oldtmp values
262 // IdHashTable _hashtable;
263 // VVIdHashTable _multivertexHashTable;
267
268 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:ViewEdgeXBuilder")
269};
270
271} /* namespace Freestyle */
unsigned long ulong
Configuration definitions.
#define _MOD
#define _MUL
Vectors and Matrices (useful type definitions).
Interface 1D and related tools definitions.
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Definition btVector3.h:263
OWXEdge & operator=(const OWXEdge &iBrother)
bool operator!=(const OWXEdge &b)
OWXEdge(WXEdge *ie, bool iOrder=true)
bool operator==(const OWXEdge &b)
OWXFaceLayer(WXFaceLayer *ifl, bool iOrder=true)
OWXFaceLayer & operator=(const OWXFaceLayer &iBrother)
bool operator==(const OWXFaceLayer &b)
bool operator!=(const OWXFaceLayer &b)
virtual void BuildViewEdges(WXShape *iWShape, ViewShape *oVShape, std::vector< ViewEdge * > &ioVEdges, std::vector< ViewVertex * > &ioVVertices, std::vector< FEdge * > &ioFEdges, std::vector< SVertex * > &ioSVertices)
int retrieveFaceMarks(WXEdge *iEdge)
SVertex * MakeSVertex(Vec3r &iPoint)
OWXEdge FindNextWEdge(const OWXEdge &iEdge)
bool stopSharpViewEdge(WXEdge *iEdge)
ViewEdge * BuildSharpViewEdge(const OWXEdge &iWEdge)
OWXEdge FindPreviousWEdge(const OWXEdge &iEdge)
FEdge * BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe)
ViewEdge * BuildSmoothViewEdge(const OWXFaceLayer &iFaceLayer)
FEdge * BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer &ifl)
OWXFaceLayer FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
ViewVertex * MakeViewVertex(SVertex *iSVertex)
OWXFaceLayer FindPreviousFaceLayer(const OWXFaceLayer &iFaceLayer)
virtual void Init(ViewShape *oVShape)
bool stopSmoothViewEdge(WXFaceLayer *iFaceLayer)
#define shared
VecMat::Vec3< real > Vec3r
Definition Geom.h:30
inherits from class Rep
Definition AppCanvas.cpp:20
map< Vec3r, SVertex * > SVertexMap
double real
Definition Precision.h:14
size_t operator()(const Vec3r &p) const
bool operator()(const Vec3r &v1, const Vec3r &v2) const