TTK
Loading...
Searching...
No Matches
ImplicitPreconditions.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace ttk {
10 : public ImplicitTriangulationCRTP<ImplicitWithPreconditions> {
11 public:
13 this->setDebugMsgPrefix("ImplicitTriangulationWithPreconditions");
14 }
15
16 int preconditionVerticesInternal() override;
17 int preconditionEdgesInternal() override;
18 int preconditionTrianglesInternal() override;
20
22 return this->vertexPositions_[v];
23 }
24 inline std::array<SimplexId, 3> const &
25 getVertexCoords(const SimplexId v) const {
26 return this->vertexCoords_[v];
27 }
28 inline EdgePosition getEdgePosition(const SimplexId e) const {
29 return this->edgePositions_[e];
30 }
31 inline std::array<SimplexId, 3> const &
32 getEdgeCoords(const SimplexId e) const {
33 return this->edgeCoords_[e];
34 }
36 return this->trianglePositions_[t];
37 }
38 inline std::array<SimplexId, 3> const &
40 return this->triangleCoords_[t];
41 }
42 inline const std::array<SimplexId, 3> &
44 return this->tetrahedronCoords_[t];
45 }
46
47 inline int clear() {
48 vertexPositions_ = std::vector<VertexPosition>{};
49 vertexCoords_ = std::vector<std::array<SimplexId, 3>>{};
50 edgePositions_ = std::vector<EdgePosition>{};
51 edgeCoords_ = std::vector<std::array<SimplexId, 3>>{};
52 trianglePositions_ = std::vector<TrianglePosition>{};
53 triangleCoords_ = std::vector<std::array<SimplexId, 3>>{};
54 tetrahedronCoords_ = std::vector<std::array<SimplexId, 3>>{};
57 }
58
59 private:
60 // for every vertex, its position on the grid
61 std::vector<VertexPosition> vertexPositions_{};
62 // for every vertex, its coordinates on the grid
63 std::vector<std::array<SimplexId, 3>> vertexCoords_{};
64 // for every edge, its position on the grid
65 std::vector<EdgePosition> edgePositions_{};
66 // for every edge, its coordinates on the grid
67 std::vector<std::array<SimplexId, 3>> edgeCoords_{};
68 // for every triangle, its position on the grid
69 std::vector<TrianglePosition> trianglePositions_{};
70 // for every triangle, its coordinates on the grid
71 std::vector<std::array<SimplexId, 3>> triangleCoords_{};
72 // for every tetrahedron, its coordinates on the grid
73 std::vector<std::array<SimplexId, 3>> tetrahedronCoords_{};
74 };
75
80 : public ImplicitTriangulationCRTP<ImplicitNoPreconditions> {
81 public:
83 this->setDebugMsgPrefix("ImplicitTriangulationNoPreconditions");
84 }
85
86 inline int preconditionVerticesInternal() override {
87 return 0;
88 }
89 inline int preconditionEdgesInternal() override {
90 return 0;
91 }
92 inline int preconditionTrianglesInternal() override {
93 return 0;
94 }
95 inline int preconditionTetrahedronsInternal() override {
96 return 0;
97 }
98
100 if(this->dimensionality_ == 1) {
101 if(v == 0) {
103 } else if(v == this->vertexNumber_ - 1) {
105 }
107 } else if(this->dimensionality_ == 2) {
108 const auto p{this->getVertexCoords(v)};
109 if(0 < p[0] and p[0] < this->nbvoxels_[this->Di_]) {
110 if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_])
112 else if(p[1] == 0)
113 return VertexPosition::TOP_EDGE_2D; // ab
114 else
116 } else if(p[0] == 0) {
117 if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_])
118 return VertexPosition::LEFT_EDGE_2D; // ac
119 else if(p[1] == 0)
121 else
123 } else {
124 if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_])
126 else if(p[1] == 0)
128 else
130 }
131
132 } else if(this->dimensionality_ == 3) {
133 const auto p{this->getVertexCoords(v)};
134 if(0 < p[0] and p[0] < this->nbvoxels_[0]) {
135 if(0 < p[1] and p[1] < this->nbvoxels_[1]) {
136 if(0 < p[2] and p[2] < this->nbvoxels_[2])
138 else if(p[2] == 0)
139 return VertexPosition::FRONT_FACE_3D; // abcd
140 else
141 return VertexPosition::BACK_FACE_3D; // efgh
142 } else if(p[1] == 0) {
143 if(0 < p[2] and p[2] < this->nbvoxels_[2])
144 return VertexPosition::TOP_FACE_3D; // abef
145 else if(p[2] == 0)
147 else
149 } else {
150 if(0 < p[2] and p[2] < this->nbvoxels_[2])
151 return VertexPosition::BOTTOM_FACE_3D; // cdgh
152 else if(p[2] == 0)
154 else
156 }
157 } else if(p[0] == 0) {
158 if(0 < p[1] and p[1] < this->nbvoxels_[1]) {
159 if(0 < p[2] and p[2] < this->nbvoxels_[2])
160 return VertexPosition::LEFT_FACE_3D; // aceg
161 else if(p[2] == 0)
163 else
165 } else if(p[1] == 0) {
166 if(0 < p[2] and p[2] < this->nbvoxels_[2])
168 else if(p[2] == 0)
170 else
172 } else {
173 if(0 < p[2] and p[2] < this->nbvoxels_[2])
175 else if(p[2] == 0)
177 else
179 }
180 } else {
181 if(0 < p[1] and p[1] < this->nbvoxels_[1]) {
182 if(0 < p[2] and p[2] < this->nbvoxels_[2])
183 return VertexPosition::RIGHT_FACE_3D; // bdfh
184 else if(p[2] == 0)
186 else
188 } else if(p[1] == 0) {
189 if(0 < p[2] and p[2] < this->nbvoxels_[2])
191 else if(p[2] == 0)
193 else
195 } else {
196 if(0 < p[2] and p[2] < this->nbvoxels_[2])
198 else if(p[2] == 0)
200 else
202 }
203 }
204 }
206 }
207
208 inline std::array<SimplexId, 3> getVertexCoords(const SimplexId v) const {
209 std::array<SimplexId, 3> p{};
210 if(this->dimensionality_ == 2) {
211 this->vertexToPosition2d(v, p.data());
212 } else if(this->dimensionality_ == 3) {
213 this->vertexToPosition(v, p.data());
214 }
215 return p;
216 }
217
218 inline EdgePosition getEdgePosition(const SimplexId e) const {
219 std::array<SimplexId, 3> p{};
220 if(this->dimensionality_ == 3) {
221
222 if(e < this->esetshift_[0]) {
223 this->edgeToPosition(e, 0, p.data());
224 if(p[1] > 0 and p[1] < this->nbvoxels_[1]) {
225 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
227 else if(p[2] == 0)
229 else
231 } else if(p[1] == 0) {
232 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
234 else if(p[2] == 0)
236 else
238 } else {
239 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
241 else if(p[2] == 0)
243 else
245 }
246 } else if(e < this->esetshift_[1]) {
247 this->edgeToPosition(e, 1, p.data());
248 if(p[0] > 0 and p[0] < this->nbvoxels_[0]) {
249 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
251 else if(p[2] == 0)
253 else
255 } else if(p[0] == 0) {
256 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
258 else if(p[2] == 0)
260 else
262 } else {
263 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
265 else if(p[2] == 0)
267 else
269 }
270 } else if(e < this->esetshift_[2]) {
271 this->edgeToPosition(e, 2, p.data());
272 if(p[0] > 0 and p[0] < this->nbvoxels_[0]) {
273 if(p[1] > 0 and p[1] < this->nbvoxels_[1])
275 else if(p[1] == 0)
277 else
279 } else if(p[0] == 0) {
280 if(p[1] > 0 and p[1] < this->nbvoxels_[1])
282 else if(p[1] == 0)
284 else
286 } else {
287 if(p[1] > 0 and p[1] < this->nbvoxels_[1])
289 else if(p[1] == 0)
291 else
293 }
294 } else if(e < this->esetshift_[3]) {
295 this->edgeToPosition(e, 3, p.data());
296 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
298 else if(p[2] == 0)
300 else
302 } else if(e < this->esetshift_[4]) {
303 this->edgeToPosition(e, 4, p.data());
304 if(p[0] > 0 and p[0] < this->nbvoxels_[0])
306 else if(p[0] == 0)
308 else
310 } else if(e < this->esetshift_[5]) {
311 this->edgeToPosition(e, 5, p.data());
312 if(p[1] > 0 and p[1] < this->nbvoxels_[1])
314 else if(p[1] == 0)
316 else
318 } else if(e < this->esetshift_[6]) {
319 return EdgePosition::D4_3D;
320 }
321
322 } else if(this->dimensionality_ == 2) {
323 if(e < this->esetshift_[0]) {
324 this->edgeToPosition2d(e, 0, p.data());
325 if(p[1] > 0 and p[1] < this->nbvoxels_[this->Dj_])
327 else if(p[1] == 0)
329 else
331 } else if(e < this->esetshift_[1]) {
332 this->edgeToPosition2d(e, 1, p.data());
333 if(p[0] > 0 and p[0] < this->nbvoxels_[this->Di_])
335 else if(p[0] == 0)
337 else
339 } else if(e < this->esetshift_[2]) {
340 return EdgePosition::D1_2D;
341 }
342
343 } else if(this->dimensionality_ == 1) {
344 if(e == 0) {
346 } else if(e == this->edgeNumber_ - 1)
348 } else {
350 }
351
353 }
354
355 inline std::array<SimplexId, 3> getEdgeCoords(const SimplexId e) const {
356 std::array<SimplexId, 3> p{};
357 if(this->dimensionality_ == 3) {
358 if(e < this->esetshift_[0]) {
359 this->edgeToPosition(e, 0, p.data());
360 } else if(e < this->esetshift_[1]) {
361 this->edgeToPosition(e, 1, p.data());
362 } else if(e < this->esetshift_[2]) {
363 this->edgeToPosition(e, 2, p.data());
364 } else if(e < this->esetshift_[3]) {
365 this->edgeToPosition(e, 3, p.data());
366 } else if(e < this->esetshift_[4]) {
367 this->edgeToPosition(e, 4, p.data());
368 } else if(e < this->esetshift_[5]) {
369 this->edgeToPosition(e, 5, p.data());
370 } else if(e < this->esetshift_[6]) {
371 this->edgeToPosition(e, 6, p.data());
372 }
373
374 } else if(this->dimensionality_ == 2) {
375 if(e < this->esetshift_[0]) {
376 this->edgeToPosition2d(e, 0, p.data());
377 } else if(e < this->esetshift_[1]) {
378 this->edgeToPosition2d(e, 1, p.data());
379 } else if(e < this->esetshift_[2]) {
380 this->edgeToPosition2d(e, 2, p.data());
381 }
382 }
383 return p;
384 }
385
387 if(this->dimensionality_ == 2) {
388 if(t % 2 == 0) {
390 } else {
392 }
393 } else if(this->dimensionality_ == 3) {
394 if(t < this->tsetshift_[0]) {
396 } else if(t < this->tsetshift_[1]) {
398 } else if(t < this->tsetshift_[2]) {
400 } else if(t < this->tsetshift_[3]) {
402 } else if(t < this->tsetshift_[4]) {
404 } else if(t < this->tsetshift_[5]) {
406 }
407 }
409 }
410
411 inline std::array<SimplexId, 3> getTriangleCoords(const SimplexId t) const {
412 std::array<SimplexId, 3> p{};
413 if(this->dimensionality_ == 2) {
414 this->triangleToPosition2d(t, p.data());
415 } else if(this->dimensionality_ == 3) {
416 if(t < this->tsetshift_[0]) {
417 this->triangleToPosition(t, 0, p.data());
418 } else if(t < this->tsetshift_[1]) {
419 this->triangleToPosition(t, 1, p.data());
420 } else if(t < this->tsetshift_[2]) {
421 this->triangleToPosition(t, 2, p.data());
422 } else if(t < this->tsetshift_[3]) {
423 this->triangleToPosition(t, 3, p.data());
424 } else if(t < this->tsetshift_[4]) {
425 this->triangleToPosition(t, 4, p.data());
426 } else if(t < this->tsetshift_[5]) {
427 this->triangleToPosition(t, 5, p.data());
428 }
429 }
430 return p;
431 }
432
433 inline std::array<SimplexId, 3>
435 std::array<SimplexId, 3> p{};
436 this->tetrahedronToPosition(t, p.data());
437 return p;
438 }
439 };
440
441} // namespace ttk
void setDebugMsgPrefix(const std::string &prefix)
Definition Debug.h:364
Implicit Triangulation class without preconditioning.
VertexPosition getVertexPosition(const SimplexId v) const
std::array< SimplexId, 3 > getEdgeCoords(const SimplexId e) const
std::array< SimplexId, 3 > getTriangleCoords(const SimplexId t) const
std::array< SimplexId, 3 > getVertexCoords(const SimplexId v) const
TrianglePosition getTrianglePosition(const SimplexId t) const
std::array< SimplexId, 3 > getTetrahedronCoords(const SimplexId t) const
EdgePosition getEdgePosition(const SimplexId e) const
Implicit Triangulation class with preconditioning.
std::array< SimplexId, 3 > const & getTriangleCoords(const SimplexId t) const
EdgePosition getEdgePosition(const SimplexId e) const
std::array< SimplexId, 3 > const & getVertexCoords(const SimplexId v) const
TrianglePosition getTrianglePosition(const SimplexId t) const
VertexPosition getVertexPosition(const SimplexId v) const
const std::array< SimplexId, 3 > & getTetrahedronCoords(const SimplexId t) const
std::array< SimplexId, 3 > const & getEdgeCoords(const SimplexId e) const
virtual void tetrahedronToPosition(const SimplexId tetrahedron, SimplexId p[3]) const =0
virtual void vertexToPosition(const SimplexId vertex, SimplexId p[3]) const =0
virtual void triangleToPosition2d(const SimplexId triangle, SimplexId p[2]) const =0
virtual void vertexToPosition2d(const SimplexId vertex, SimplexId p[2]) const =0
virtual void triangleToPosition(const SimplexId triangle, const int k, SimplexId p[3]) const =0
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22