Blender V4.3
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
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#ifdef WITH_CXX_GUARDEDALLOC
33# include "MEM_guardedalloc.h"
34#endif
35
36using namespace std;
37
38namespace Freestyle {
39
40using namespace Geometry;
41
42class SVertex;
43
46#define _MUL 950706376UL
47#define _MOD 2147483647UL
48 inline size_t operator()(const Vec3r &p) const
49 {
50 size_t res = (ulong(p[0] * _MUL)) % _MOD;
51 res = ((res + ulong(p[1]) * _MUL)) % _MOD;
52 return ((res + ulong(p[2]) * _MUL)) % _MOD;
53 }
54#undef _MUL
55#undef _MOD
56};
57
58// Key_compare predicate for hash_map. In particular, return false if equal.
60 bool operator()(const Vec3r &v1, const Vec3r &v2) const
61 {
62 real norm = (v1 - v2).norm();
63 return (norm < 1.0e-06);
64 }
65};
66
67// typedef hash_map<Vec3r, SVertex*, SVertexHasher, epsilonEquals> SVertexMap;
68typedef map<Vec3r, SVertex *> SVertexMap;
69
70class WXFaceLayer;
71
74 public:
76 bool order;
77
79 {
80 fl = nullptr;
81 order = true;
82 }
83
84 OWXFaceLayer(WXFaceLayer *ifl, bool iOrder = true)
85 {
86 fl = ifl;
87 order = iOrder;
88 }
89
91 {
92 fl = iBrother.fl;
93 order = iBrother.order;
94 return *this;
95 }
96
98 {
99 return ((fl == b.fl) && (order == b.order));
100 }
101
103 {
104 return !(*this == b);
105 }
106
107#ifdef WITH_CXX_GUARDEDALLOC
108 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OWXFaceLayer")
109#endif
110};
111
112class WXEdge;
113
115class OWXEdge {
116 public:
118 bool order;
119
121 {
122 e = nullptr;
123 order = true;
124 }
125
126 OWXEdge(WXEdge *ie, bool iOrder = true)
127 {
128 e = ie;
129 order = iOrder;
130 }
131
132 OWXEdge &operator=(const OWXEdge &iBrother)
133 {
134 e = iBrother.e;
135 order = iBrother.order;
136 return *this;
137 }
138
139 bool operator==(const OWXEdge &b)
140 {
141 return ((e == b.e) && (order == b.order));
142 }
143
144 bool operator!=(const OWXEdge &b)
145 {
146 return !(*this == b);
147 }
148
149#ifdef WITH_CXX_GUARDEDALLOC
150 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OWXEdge")
151#endif
152};
153
154class WOEdge;
155class WXEdge;
156class WXShape;
157class SVertex;
158class FEdge;
159class ViewVertex;
160class ViewEdge;
161class ViewShape;
162
164 protected:
165 int _currentViewId; // Id for view edges
166 int _currentFId; // Id for FEdges
167 int _currentSVertexId; // Id for SVertex
168
169 public:
171 {
172 _currentViewId = 1;
173 _currentFId = 0;
175 }
176
177 virtual ~ViewEdgeXBuilder() {}
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 {
238 }
239
240 protected:
242 virtual void Init(ViewShape *oVShape);
243
244 // SMOOTH //
246 bool stopSmoothViewEdge(WXFaceLayer *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);
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 */
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)
local_group_size(16, 16) .push_constant(Type b
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