TTK
Loading...
Searching...
No Matches
PeriodicImplicitTriangulation.h
Go to the documentation of this file.
1
12
13#pragma once
14
15// base code includes
17
18#include <array>
19#include <numeric>
20
21namespace ttk {
22
24
25 public:
28
30 = default;
34 = default;
36 = default;
37
38 int getCellEdgeInternal(const SimplexId &cellId,
39 const int &id,
40 SimplexId &edgeId) const override;
41
42 SimplexId getCellEdgeNumberInternal(const SimplexId &cellId) const override;
43
44 const std::vector<std::vector<SimplexId>> *getCellEdgesInternal() override;
45
47 const SimplexId &cellId,
48 const int &localNeighborId,
49 SimplexId &neighborId) const override;
50
52 const SimplexId &cellId) const override;
53
54 const std::vector<std::vector<SimplexId>> *
56
57 int getCellTriangleInternal(const SimplexId &cellId,
58 const int &id,
59 SimplexId &triangleId) const override;
60
62 const SimplexId &ttkNotUsed(cellId)) const override {
63 // NOTE: the output is always 4 here. let's keep the function in there
64 // in case of further generalization to CW-complexes
65 return 4;
66 }
67
68 const std::vector<std::vector<SimplexId>> *
69 getCellTrianglesInternal() override;
70
72 const SimplexId &cellId,
73 const int &localVertexId,
74 SimplexId &vertexId) const override;
75
77 const SimplexId &cellId) const override;
78
80 return dimensionality_;
81 }
82
84 const SimplexId &edgeId) const override;
85
86 const std::vector<std::vector<SimplexId>> *
88
89 const std::vector<std::vector<SimplexId>> *
91
92 const std::vector<std::vector<SimplexId>> *
93 getEdgeTrianglesInternal() override;
94
95 const std::vector<std::array<SimplexId, 2>> *
97
101
103 return edgeNumber_;
104 }
105
107 return triangleNumber_;
108 }
109
113
114 virtual int getTetrahedronEdge(const SimplexId &tetId,
115 const int &id,
116 SimplexId &edgeId) const = 0;
117
118 int getTetrahedronEdges(std::vector<std::vector<SimplexId>> &edges) const;
119
120 virtual int getTetrahedronTriangle(const SimplexId &tetId,
121 const int &id,
122 SimplexId &triangleId) const = 0;
123
125 std::vector<std::vector<SimplexId>> &triangles) const;
126
127 virtual int getTetrahedronNeighbor(const SimplexId &tetId,
128 const int &localNeighborId,
129 SimplexId &neighborId) const = 0;
130
132
133 int getTetrahedronNeighbors(std::vector<std::vector<SimplexId>> &neighbors);
134
135 virtual int getTetrahedronVertex(const SimplexId &tetId,
136 const int &localVertexId,
137 SimplexId &vertexId) const = 0;
138
140 const SimplexId &ttkNotUsed(triangleId)) const override {
141 // NOTE: the output is always 3 here. let's keep the function in there
142 // in case of further generalization to CW-complexes
143 return 3;
144 }
145
146 const std::vector<std::vector<SimplexId>> *
147 getTriangleEdgesInternal() override;
148
150 std::vector<std::vector<SimplexId>> &edges) const;
151
153 const SimplexId &triangleId) const override;
154
155 const std::vector<std::vector<SimplexId>> *
157
158 virtual int getTriangleNeighbor(const SimplexId &triangleId,
159 const int &localNeighborId,
160 SimplexId &neighborId) const = 0;
161
162 SimplexId getTriangleNeighborNumber(const SimplexId &triangleId) const;
163
164 int getTriangleNeighbors(std::vector<std::vector<SimplexId>> &neighbors);
165
166 const std::vector<std::vector<SimplexId>> *
168
169 const std::vector<std::array<SimplexId, 3>> *
171
173 getVertexEdgeNumberInternal(const SimplexId &vertexId) const override;
174
175 const std::vector<std::vector<SimplexId>> *
176 getVertexEdgesInternal() override;
177
179 const SimplexId &vertexId) const override;
180
181 const std::vector<std::vector<SimplexId>> *
183
185 const SimplexId &vertexId) const override;
186
187 const std::vector<std::vector<SimplexId>> *
189
191 const SimplexId &vertexId) const override;
192
193 const std::vector<std::vector<SimplexId>> *
195
197 getVertexTriangleNumberInternal(const SimplexId &vertexId) const override;
198
199 const std::vector<std::vector<SimplexId>> *
201
203 const SimplexId &edgeId) const override;
204
205 inline bool isEmpty() const override {
206 return !vertexNumber_;
207 }
208
210 const SimplexId &triangleId) const override;
211
213 const SimplexId &vertexId) const override;
214
215 int setInputGrid(const float &xOrigin,
216 const float &yOrigin,
217 const float &zOrigin,
218 const float &xSpacing,
219 const float &ySpacing,
220 const float &zSpacing,
221 const SimplexId &xDim,
222 const SimplexId &yDim,
223 const SimplexId &zDim) override;
224
225 inline const std::array<ttk::SimplexId, 3> &
226 getGridDimensions() const override {
227 return this->dimensions_;
228 }
229
231 int preconditionEdgesInternal() override = 0;
234
236 if(dimensionality_ == 3) {
238 } else if(dimensionality_ == 2 && !hasPreconditionedTriangles_) {
240 return this->preconditionTrianglesInternal();
241 }
242 return 0;
243 }
244
250 }
251 return 0;
252 }
253
254 inline int getCellVTKIDInternal(const int &ttkId,
255 int &vtkId) const override {
256#ifndef TTK_ENABLE_KAMIKAZE
257 if(ttkId < 0) {
258 return -1;
259 }
260#endif // TTK_ENABLE_KAMIKAZE
261 const SimplexId nSimplexPerCell{this->getDimensionality() == 3 ? 6 : 2};
262 vtkId = ttkId / nSimplexPerCell;
263 return 0;
264 }
265
266 protected:
268 SimplexId nbvoxels_[3]; // nombre de voxels par axe
270
271 // Vertex helper //
272 SimplexId vshift_[2]; // VertexShift
273
274 // Edge helper //
275 SimplexId esetdims_[7]; // EdgeSetDimensions
276 SimplexId esetshift_[7]; // EdgeSetShift
277 SimplexId eshift_[14]; // EdgeShift
278
279 // Triangle helper //
280 SimplexId tsetdims_[6]; // TriangleSetDimensions
281 SimplexId tsetshift_[6]; // TriangleSetShift
282 SimplexId tshift_[12]; // TriangleShift
283
284 // Tetrahedron helper //
285 SimplexId tetshift_[2]; // TetrahedronShift
286
287 SimplexId cellNumber_; // number of cells
288 SimplexId vertexNumber_; // number of vertices
289 SimplexId edgeNumber_; // number of edges
290 SimplexId triangleNumber_; // number of triangles
291 SimplexId tetrahedronNumber_; // number of tetrahedra
292
293 // 2d helpers
296
297 // acceleration variables
301
302 enum class EdgePosition : char {
303 // e--------f
304 // /| /|
305 // / | / |
306 // a--------b |
307 // | g-----|--h
308 // | / | /
309 // |/ |/
310 // c--------d
311
312 // length (ab)
313 L_3D,
314 // height (ac)
315 H_3D,
316 // depth (ae)
317 P_3D,
318 // diagonal1 (bc)
319 D1_3D,
320 // diagonal2 (ag)
321 D2_3D,
322 // diagonal3 (be)
323 D3_3D,
324 // diagonal4 (bg)
325 D4_3D,
326
327 // length (ab)
328 L_2D,
329 // height (ac)
330 H_2D,
331 // diagonal1 (bc)
332 D1_2D,
333
336 CENTER_1D,
337 };
338
339 enum class TrianglePosition : char {
340 // e--------f
341 // /| /|
342 // / | / |
343 // a--------b |
344 // | g-----|--h
345 // | / | /
346 // |/ |/
347 // c--------d
348
349 F_3D, // face (abc, bcd)
350 C_3D, // side (abe, bef)
351 H_3D, // top (acg, aeg)
352 D1_3D, // diagonal1 (bdg, beg)
353 D2_3D, // diagonal2 (abg, bgh)
354 D3_3D, // diagonal3 (bcg, bfg)
355
356 TOP_2D, // abc
357 BOTTOM_2D, // bcd
358 };
359
361
362 // acceleration functions
363 int checkAcceleration();
364 bool isPowerOfTwo(unsigned long long int v, unsigned long long int &r);
365
366 //\cond
367 // 2D //
368 void vertexToPosition2d(const SimplexId vertex,
369 SimplexId p[2]) const override;
370 void
371 edgeToPosition2d(const SimplexId edge, const int k, SimplexId p[2]) const;
372 void triangleToPosition2d(const SimplexId triangle,
373 SimplexId p[2]) const override;
374
375 SimplexId getVertexNeighbor2d(const SimplexId p[2],
376 const SimplexId v,
377 const int id) const;
378 SimplexId getVertexEdge2d(const SimplexId p[2], const int id) const;
379 SimplexId getVertexStar2d(const SimplexId p[2], const int id) const;
380 SimplexId getVertexLink2d(const SimplexId p[2], const int id) const;
381
382 SimplexId getEdgeTriangle2dL(const SimplexId p[3], const int id) const;
383 SimplexId getEdgeTriangle2dH(const SimplexId p[3], const int id) const;
384 SimplexId getEdgeTriangle2dD1(const SimplexId p[3], const int id) const;
385
386 SimplexId getEdgeLink2dL(const SimplexId p[2], const int id) const;
387 SimplexId getEdgeLink2dH(const SimplexId p[2], const int id) const;
388 SimplexId getEdgeLink2dD1(const SimplexId p[2], const int id) const;
389
390 SimplexId getEdgeStar2dL(const SimplexId p[2], const int id) const;
391 SimplexId getEdgeStar2dH(const SimplexId p[2], const int id) const;
392
393 // 3D //
394 void vertexToPosition(const SimplexId vertex,
395 SimplexId p[3]) const override;
396 void
397 edgeToPosition(const SimplexId edge, const int k, SimplexId p[3]) const;
398 void triangleToPosition(const SimplexId triangle,
399 const int k,
400 SimplexId p[3]) const override;
401 void tetrahedronToPosition(const SimplexId tetrahedron,
402 SimplexId p[3]) const override;
403
404 SimplexId getVertexNeighbor3d(const SimplexId p[3],
405 const SimplexId v,
406 const int id) const;
407 SimplexId getVertexEdge3d(const SimplexId p[3], const int id) const;
408 SimplexId getVertexTriangle3d(const SimplexId p[3], const int id) const;
409 SimplexId getVertexLink3d(const SimplexId p[3], const int id) const;
410 SimplexId getVertexStar3d(const SimplexId p[3], const int id) const;
411
412 SimplexId getEdgeTriangle3dL(const SimplexId p[3], const int id) const;
413 SimplexId getEdgeTriangle3dH(const SimplexId p[3], const int id) const;
414 SimplexId getEdgeTriangle3dP(const SimplexId p[3], const int id) const;
415 SimplexId getEdgeTriangle3dD1(const SimplexId p[3], const int id) const;
416 SimplexId getEdgeTriangle3dD2(const SimplexId p[3], const int id) const;
417 SimplexId getEdgeTriangle3dD3(const SimplexId p[3], const int id) const;
418 SimplexId getEdgeTriangle3dD4(const SimplexId p[3], const int id) const;
419
420 SimplexId getEdgeLinkL(const SimplexId p[3], const int id) const;
421 SimplexId getEdgeLinkH(const SimplexId p[3], const int id) const;
422 SimplexId getEdgeLinkP(const SimplexId p[3], const int id) const;
423 SimplexId getEdgeLinkD1(const SimplexId p[3], const int id) const;
424 SimplexId getEdgeLinkD2(const SimplexId p[3], const int id) const;
425 SimplexId getEdgeLinkD3(const SimplexId p[3], const int id) const;
426 SimplexId getEdgeLinkD4(const SimplexId p[3], const int id) const;
427
428 SimplexId getEdgeStarL(const SimplexId p[3], const int id) const;
429 SimplexId getEdgeStarH(const SimplexId p[3], const int id) const;
430 SimplexId getEdgeStarP(const SimplexId p[3], const int id) const;
431 SimplexId getEdgeStarD1(const SimplexId p[3], const int id) const;
432 SimplexId getEdgeStarD2(const SimplexId p[3], const int id) const;
433 SimplexId getEdgeStarD3(const SimplexId p[3], const int id) const;
434
435 SimplexId getTriangleVertexF(const SimplexId p[3], const int id) const;
436 SimplexId getTriangleVertexH(const SimplexId p[3], const int id) const;
437 SimplexId getTriangleVertexC(const SimplexId p[3], const int id) const;
438 SimplexId getTriangleVertexD1(const SimplexId p[3], const int id) const;
439 SimplexId getTriangleVertexD2(const SimplexId p[3], const int id) const;
440 SimplexId getTriangleVertexD3(const SimplexId p[3], const int id) const;
441
442 SimplexId getTriangleEdgeF_0(const SimplexId p[3], const int id) const;
443 SimplexId getTriangleEdgeF_1(const SimplexId p[3], const int id) const;
444 SimplexId getTriangleEdgeH_0(const SimplexId p[3], const int id) const;
445 SimplexId getTriangleEdgeH_1(const SimplexId p[3], const int id) const;
446 SimplexId getTriangleEdgeC_0(const SimplexId p[3], const int id) const;
447 SimplexId getTriangleEdgeC_1(const SimplexId p[3], const int id) const;
448 SimplexId getTriangleEdgeD1_0(const SimplexId p[3], const int id) const;
449 SimplexId getTriangleEdgeD1_1(const SimplexId p[3], const int id) const;
450 SimplexId getTriangleEdgeD2_0(const SimplexId p[3], const int id) const;
451 SimplexId getTriangleEdgeD2_1(const SimplexId p[3], const int id) const;
452 SimplexId getTriangleEdgeD3_0(const SimplexId p[3], const int id) const;
453 SimplexId getTriangleEdgeD3_1(const SimplexId p[3], const int id) const;
454
455 SimplexId getTriangleLinkF(const SimplexId p[3], const int id) const;
456 SimplexId getTriangleLinkH(const SimplexId p[3], const int id) const;
457 SimplexId getTriangleLinkC(const SimplexId p[3], const int id) const;
458 SimplexId getTriangleLinkD1(const SimplexId p[3], const int id) const;
459 SimplexId getTriangleLinkD2(const SimplexId p[3], const int id) const;
460 SimplexId getTriangleLinkD3(const SimplexId p[3], const int id) const;
461
462 SimplexId getTriangleStarF(const SimplexId p[3], const int id) const;
463 SimplexId getTriangleStarH(const SimplexId p[3], const int id) const;
464 SimplexId getTriangleStarC(const SimplexId p[3], const int id) const;
465 SimplexId getTriangleStarD1(const SimplexId p[3], const int id) const;
466 SimplexId getTriangleStarD2(const SimplexId p[3], const int id) const;
467 SimplexId getTriangleStarD3(const SimplexId p[3], const int id) const;
468
469 SimplexId getTetrahedronVertexABCG(const SimplexId p[3],
470 const int id) const;
471 SimplexId getTetrahedronVertexBCDG(const SimplexId p[3],
472 const int id) const;
473 SimplexId getTetrahedronVertexABEG(const SimplexId p[3],
474 const int id) const;
475 SimplexId getTetrahedronVertexBEFG(const SimplexId p[3],
476 const int id) const;
477 SimplexId getTetrahedronVertexBFGH(const SimplexId p[3],
478 const int id) const;
479 SimplexId getTetrahedronVertexBDGH(const SimplexId p[3],
480 const int id) const;
481
482 SimplexId getTetrahedronEdgeABCG(const SimplexId p[3], const int id) const;
483 SimplexId getTetrahedronEdgeBCDG(const SimplexId p[3], const int id) const;
484 SimplexId getTetrahedronEdgeABEG(const SimplexId p[3], const int id) const;
485 SimplexId getTetrahedronEdgeBEFG(const SimplexId p[3], const int id) const;
486 SimplexId getTetrahedronEdgeBFGH(const SimplexId p[3], const int id) const;
487 SimplexId getTetrahedronEdgeBDGH(const SimplexId p[3], const int id) const;
488
489 SimplexId getTetrahedronTriangleABCG(const SimplexId p[3],
490 const int id) const;
491 SimplexId getTetrahedronTriangleBCDG(const SimplexId p[3],
492 const int id) const;
493 SimplexId getTetrahedronTriangleABEG(const SimplexId p[3],
494 const int id) const;
495 SimplexId getTetrahedronTriangleBEFG(const SimplexId p[3],
496 const int id) const;
497 SimplexId getTetrahedronTriangleBFGH(const SimplexId p[3],
498 const int id) const;
499 SimplexId getTetrahedronTriangleBDGH(const SimplexId p[3],
500 const int id) const;
501
502 SimplexId getTetrahedronNeighborABCG(const SimplexId t,
503 const SimplexId p[3],
504 const int id) const;
505 SimplexId getTetrahedronNeighborBCDG(const SimplexId t,
506 const SimplexId p[3],
507 const int id) const;
508 SimplexId getTetrahedronNeighborABEG(const SimplexId t,
509 const SimplexId p[3],
510 const int id) const;
511 SimplexId getTetrahedronNeighborBEFG(const SimplexId t,
512 const SimplexId p[3],
513 const int id) const;
514 SimplexId getTetrahedronNeighborBFGH(const SimplexId t,
515 const SimplexId p[3],
516 const int id) const;
517 SimplexId getTetrahedronNeighborBDGH(const SimplexId t,
518 const SimplexId p[3],
519 const int id) const;
520 //\endcond
521
522#ifdef TTK_ENABLE_MPI
523
524 protected:
525 int preconditionDistributedCells() override;
526 // std::shared_ptr<PeriodicImplicitTriangulation> metaGrid_;
527 std::array<unsigned char, 6> isBoundaryPeriodic{};
528
529 public:
530 void createMetaGrid(const double *const bounds) override;
531 void setIsBoundaryPeriodic(std::array<unsigned char, 6> boundary);
532 int getCellRankInternal(const SimplexId lcid) const override;
533
534 protected:
535 std::array<SimplexId, 3>
536 getVertGlobalCoords(const SimplexId lvid) const override;
537 std::array<SimplexId, 3>
538 getVertLocalCoords(const SimplexId gvid) const override;
539
540#endif // TTK_ENABLE_MPI
541 };
542
543 template <typename Derived>
546 inline Derived &underlying() {
547 return static_cast<Derived &>(*this);
548 }
549 inline Derived const &underlying() const {
550 return static_cast<Derived const &>(*this);
551 }
552
553 public:
555 const SimplexId &vertexId,
556 const int &localNeighborId,
557 SimplexId &neighborId) const override;
558
559 int getVertexEdgeInternal(const SimplexId &vertexId,
560 const int &id,
561 SimplexId &edgeId) const override;
562
563 int getVertexTriangleInternal(const SimplexId &vertexId,
564 const int &id,
565 SimplexId &triangleId) const override;
566
568 const SimplexId &vertexId,
569 const int &localLinkId,
570 SimplexId &linkId) const override;
571
573 const SimplexId &vertexId,
574 const int &localStarId,
575 SimplexId &starId) const override;
576
578 float &x,
579 float &y,
580 float &z) const override;
581
582 int getEdgeVertexInternal(const SimplexId &edgeId,
583 const int &localVertexId,
584 SimplexId &vertexId) const override;
585
587 getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override;
588
589 int getEdgeTriangleInternal(const SimplexId &edgeId,
590 const int &id,
591 SimplexId &triangleId) const override;
592
593 int
595 const int &localLinkId,
596 SimplexId &linkId) const override;
597
599 const SimplexId &edgeId) const override;
600
601 int
603 const int &localStarId,
604 SimplexId &starId) const override;
605
606 int getTriangleVertexInternal(const SimplexId &triangleId,
607 const int &localVertexId,
608 SimplexId &vertexId) const override;
609
610 int getTriangleEdgeInternal(const SimplexId &triangleId,
611 const int &id,
612 SimplexId &edgeId) const override;
613
615 const SimplexId &triangleId,
616 const int &localLinkId,
617 SimplexId &linkId) const override;
618
620 const SimplexId &triangleId,
621 const int &localStarId,
622 SimplexId &starId) const override;
623
625 const SimplexId &triangleId) const override;
626
627 int getTriangleNeighbor(const SimplexId &triangleId,
628 const int &localNeighborId,
629 SimplexId &neighborId) const override;
630
631 int getTetrahedronVertex(const SimplexId &tetId,
632 const int &localVertexId,
633 SimplexId &vertexId) const override;
634
635 int getTetrahedronEdge(const SimplexId &tetId,
636 const int &id,
637 SimplexId &edgeId) const override;
638
639 int getTetrahedronTriangle(const SimplexId &tetId,
640 const int &id,
641 SimplexId &triangleId) const override;
642
643 int getTetrahedronNeighbor(const SimplexId &tetId,
644 const int &localNeighborId,
645 SimplexId &neighborId) const override;
646
650 virtual int getEdgeIncenter(SimplexId edgeId, float incenter[3]) const {
651 SimplexId v0{}, v1{};
652 getEdgeVertexInternal(edgeId, 0, v0);
653 getEdgeVertexInternal(edgeId, 1, v1);
654
655 std::array<float, 3> p0{}, p1{};
656 getVertexPointInternal(v0, p0[0], p0[1], p0[2]);
657 getVertexPointInternal(v1, p1[0], p1[1], p1[2]);
658
659 const auto &ind0 = this->underlying().getVertexCoords(v0);
660 const auto &ind1 = this->underlying().getVertexCoords(v1);
661
662 for(int i = 0; i < dimensionality_; ++i) {
663 if(ind1[i] == nbvoxels_[i]) {
664 p0[i] += (ind0[i] == 0) * dimensions_[i] * spacing_[i];
665 } else if(ind0[i] == nbvoxels_[i]) {
666 p1[i] += (ind1[i] == 0) * dimensions_[i] * spacing_[i];
667 }
668 }
669
670 for(int i = 0; i < 3; ++i) {
671 incenter[i] = 0.5f * (p0[i] + p1[i]);
672 }
673
674 return 0;
675 }
676
681 virtual int getTriangleIncenter(SimplexId triangleId,
682 float incenter[3]) const {
683
684 SimplexId v0{}, v1{}, v2{};
685 getTriangleVertexInternal(triangleId, 0, v0);
686 getTriangleVertexInternal(triangleId, 1, v1);
687 getTriangleVertexInternal(triangleId, 2, v2);
688
689 std::array<float, 3> p0{}, p1{}, p2{};
690 getVertexPointInternal(v0, p0[0], p0[1], p0[2]);
691 getVertexPointInternal(v1, p1[0], p1[1], p1[2]);
692 getVertexPointInternal(v2, p2[0], p2[1], p2[2]);
693
694 const auto &ind0 = this->underlying().getVertexCoords(v0);
695 const auto &ind1 = this->underlying().getVertexCoords(v1);
696 const auto &ind2 = this->underlying().getVertexCoords(v2);
697
698 for(int i = 0; i < dimensionality_; ++i) {
699 if(ind0[i] == nbvoxels_[i]) {
700 p1[i] += (ind1[i] == 0) * dimensions_[i] * spacing_[i];
701 p2[i] += (ind2[i] == 0) * dimensions_[i] * spacing_[i];
702 } else if(ind1[i] == nbvoxels_[i]) {
703 p0[i] += (ind0[i] == 0) * dimensions_[i] * spacing_[i];
704 p2[i] += (ind2[i] == 0) * dimensions_[i] * spacing_[i];
705 } else if(ind2[i] == nbvoxels_[i]) {
706 p0[i] += (ind0[i] == 0) * dimensions_[i] * spacing_[i];
707 p1[i] += (ind1[i] == 0) * dimensions_[i] * spacing_[i];
708 }
709 }
710
711 std::array<float, 3> d{Geometry::distance(p1.data(), p2.data()),
712 Geometry::distance(p2.data(), p0.data()),
713 Geometry::distance(p0.data(), p1.data())};
714 const float sum = d[0] + d[1] + d[2];
715 for(int i = 0; i < 3; ++i) {
716 incenter[i] = (d[0] * p0[i] + d[1] * p1[i] + d[2] * p2[i]) / sum;
717 }
718
719 return 0;
720 }
721
726 virtual int getTetraIncenter(SimplexId tetraId, float incenter[3]) const {
727
728 SimplexId v0{}, v1{}, v2{}, v3{};
729 getCellVertexInternal(tetraId, 0, v0);
730 getCellVertexInternal(tetraId, 1, v1);
731 getCellVertexInternal(tetraId, 2, v2);
732 getCellVertexInternal(tetraId, 3, v3);
733
734 std::array<float, 3> p0{}, p1{}, p2{}, p3{};
735 getVertexPointInternal(v0, p0[0], p0[1], p0[2]);
736 getVertexPointInternal(v1, p1[0], p1[1], p1[2]);
737 getVertexPointInternal(v2, p2[0], p2[1], p2[2]);
738 getVertexPointInternal(v3, p3[0], p3[1], p3[2]);
739
740 const auto &ind0 = this->underlying().getVertexCoords(v0);
741 const auto &ind1 = this->underlying().getVertexCoords(v1);
742 const auto &ind2 = this->underlying().getVertexCoords(v2);
743 const auto &ind3 = this->underlying().getVertexCoords(v3);
744
745 for(int i = 0; i < dimensionality_; ++i) {
746 if(ind0[i] == nbvoxels_[i]) {
747 p1[i] += (ind1[i] == 0) * dimensions_[i] * spacing_[i];
748 p2[i] += (ind2[i] == 0) * dimensions_[i] * spacing_[i];
749 p3[i] += (ind3[i] == 0) * dimensions_[i] * spacing_[i];
750 } else if(ind1[i] == nbvoxels_[i]) {
751 p0[i] += (ind0[i] == 0) * dimensions_[i] * spacing_[i];
752 p2[i] += (ind2[i] == 0) * dimensions_[i] * spacing_[i];
753 p3[i] += (ind3[i] == 0) * dimensions_[i] * spacing_[i];
754 } else if(ind2[i] == nbvoxels_[i]) {
755 p0[i] += (ind0[i] == 0) * dimensions_[i] * spacing_[i];
756 p1[i] += (ind1[i] == 0) * dimensions_[i] * spacing_[i];
757 p3[i] += (ind3[i] == 0) * dimensions_[i] * spacing_[i];
758 } else if(ind3[i] == nbvoxels_[i]) {
759 p0[i] += (ind0[i] == 0) * dimensions_[i] * spacing_[i];
760 p1[i] += (ind1[i] == 0) * dimensions_[i] * spacing_[i];
761 p2[i] += (ind2[i] == 0) * dimensions_[i] * spacing_[i];
762 }
763 }
764
765 for(int i = 0; i < 3; ++i) {
766 incenter[i] = 0.25f * (p0[i] + p1[i] + p2[i] + p3[i]);
767 }
768 return 0;
769 }
770 };
771
772} // namespace ttk
773
775
776inline void
778 SimplexId p[2]) const {
779 if(isAccelerated_) {
780 p[0] = vertex & mod_[0];
781 p[1] = vertex >> div_[0];
782 } else {
783 p[0] = vertex % vshift_[0];
784 p[1] = vertex / vshift_[0];
785 }
786}
787
788inline void ttk::PeriodicImplicitTriangulation::edgeToPosition2d(
789 const SimplexId edge, const int k, SimplexId p[2]) const {
790 const int e = (k) ? edge - esetshift_[k - 1] : edge;
791 p[0] = e % eshift_[2 * k];
792 p[1] = e / eshift_[2 * k];
793}
794
796 const SimplexId triangle, SimplexId p[2]) const {
797 p[0] = triangle % tshift_[0];
798 p[1] = triangle / tshift_[0];
799}
800
801inline ttk::SimplexId ttk::PeriodicImplicitTriangulation::getVertexNeighbor2d(
802 const SimplexId p[2], const SimplexId v, const int id) const {
803 SimplexId wrapXLeft = 0;
804 SimplexId wrapXRight = 0;
805 SimplexId wrapYTop = 0;
806 SimplexId wrapYBottom = 0;
807 if(p[0] == 0)
808 wrapXLeft = wrap_[0];
809 if(p[0] == nbvoxels_[Di_])
810 wrapXRight = -wrap_[0];
811 if(p[1] == 0)
812 wrapYTop = wrap_[1];
813 if(p[1] == nbvoxels_[Dj_])
814 wrapYBottom = -wrap_[1];
815 switch(id) {
816 case 0:
817 return v - 1 + wrapXLeft;
818 case 1:
819 return v - vshift_[0] + wrapYTop;
820 case 2:
821 return v - vshift_[0] + 1 + wrapXRight + wrapYTop;
822 case 3:
823 return v + 1 + wrapXRight;
824 case 4:
825 return v + vshift_[0] + wrapYBottom;
826 case 5:
827 return v + vshift_[0] - 1 + wrapXLeft + wrapYBottom;
828 }
829 return -1;
830}
831
832inline ttk::SimplexId
833 ttk::PeriodicImplicitTriangulation::getVertexEdge2d(const SimplexId p[2],
834 const int id) const {
835 SimplexId wrapXLeft = 0;
836 SimplexId wrapYTop = 0;
837 if(p[0] == 0)
838 wrapXLeft = wrap_[0];
839 if(p[1] == 0)
840 wrapYTop = wrap_[1];
841 switch(id) {
842 case 0:
843 return esetshift_[0] + p[0] + (p[1] - 1) * eshift_[2] + wrapYTop;
844 case 1:
845 return p[0] + p[1] * eshift_[0] - 1 + wrapXLeft;
846 case 2:
847 return esetshift_[1] + p[0] + (p[1] - 1) * eshift_[4] + wrapYTop;
848 case 3:
849 return p[0] + p[1] * eshift_[0];
850 case 4:
851 return esetshift_[0] + p[0] + p[1] * eshift_[2];
852 case 5:
853 return esetshift_[1] + p[0] + p[1] * eshift_[4] - 1 + wrapXLeft;
854 }
855 return -1;
856}
857
858inline ttk::SimplexId
859 ttk::PeriodicImplicitTriangulation::getVertexStar2d(const SimplexId p[2],
860 const int id) const {
861 SimplexId wrapXLeft = 0;
862 SimplexId wrapYTop = 0;
863 if(p[0] == 0)
864 wrapXLeft = 2 * wrap_[0];
865 if(p[1] == 0)
866 wrapYTop = 2 * wrap_[1];
867 switch(id) {
868 case 0:
869 return (p[0] - 1) * 2 + p[1] * tshift_[0] + wrapXLeft;
870 case 1:
871 return (p[0] - 1) * 2 + p[1] * tshift_[0] + 1 + wrapXLeft;
872 case 2:
873 return p[0] * 2 + p[1] * tshift_[0];
874 case 3:
875 return p[0] * 2 + (p[1] - 1) * tshift_[0] + wrapYTop;
876 case 4:
877 return p[0] * 2 + (p[1] - 1) * tshift_[0] + 1 + wrapYTop;
878 case 5:
879 return (p[0] - 1) * 2 + (p[1] - 1) * tshift_[0] + 1 + wrapXLeft
880 + wrapYTop;
881 }
882 return -1;
883}
884
885inline ttk::SimplexId
886 ttk::PeriodicImplicitTriangulation::getVertexLink2d(const SimplexId p[2],
887 const int id) const {
888 SimplexId wrapXLeft = 0;
889 SimplexId wrapXRight = 0;
890 SimplexId wrapYTop = 0;
891 SimplexId wrapYBottom = 0;
892 if(p[0] == 0)
893 wrapXLeft = wrap_[0];
894 if(p[0] == nbvoxels_[Di_])
895 wrapXRight = -wrap_[0];
896 if(p[1] == 0)
897 wrapYTop = wrap_[1];
898 if(p[1] == nbvoxels_[Dj_])
899 wrapYBottom = -wrap_[1];
900 switch(id) {
901 case 0:
902 return esetshift_[0] + p[0] + p[1] * eshift_[2] - 1 + wrapXLeft;
903 case 1:
904 return p[0] + (p[1] + 1) * eshift_[0] - 1 + wrapXLeft + wrapYBottom;
905 case 2:
906 return esetshift_[1] + p[0] + p[1] * eshift_[4];
907 case 3:
908 return esetshift_[0] + p[0] + (p[1] - 1) * eshift_[2] + 1 + wrapXRight
909 + wrapYTop;
910 case 4:
911 return p[0] + (p[1] - 1) * eshift_[0] + wrapYTop;
912 case 5:
913 return esetshift_[1] + p[0] + (p[1] - 1) * eshift_[4] - 1 + wrapXLeft
914 + wrapYTop;
915 }
916 return -1;
917}
918
919inline ttk::SimplexId
920 ttk::PeriodicImplicitTriangulation::getEdgeTriangle2dL(const SimplexId p[3],
921 const int id) const {
922 SimplexId wrapYTop = 0;
923 if(p[1] == 0)
924 wrapYTop = 2 * wrap_[1];
925 switch(id) {
926 case 0:
927 return p[Di_] * 2 + p[Dj_] * tshift_[0];
928 case 1:
929 return p[Di_] * 2 + (p[Dj_] - 1) * tshift_[0] + 1 + wrapYTop;
930 }
931 return -1;
932}
933
934inline ttk::SimplexId
935 ttk::PeriodicImplicitTriangulation::getEdgeTriangle2dH(const SimplexId p[3],
936 const int id) const {
937 SimplexId wrapXLeft = 0;
938 if(p[0] == 0)
939 wrapXLeft = 2 * wrap_[0];
940 switch(id) {
941 case 0:
942 return p[Di_] * 2 + p[Dj_] * tshift_[0];
943 case 1:
944 return (p[Di_] - 1) * 2 + p[Dj_] * tshift_[0] + 1 + wrapXLeft;
945 }
946 return -1;
947}
948
949inline ttk::SimplexId
950 ttk::PeriodicImplicitTriangulation::getEdgeTriangle2dD1(const SimplexId p[3],
951 const int id) const {
952 switch(id) {
953 case 0:
954 return p[Di_] * 2 + p[Dj_] * tshift_[0];
955 case 1:
956 return p[Di_] * 2 + p[Dj_] * tshift_[0] + 1;
957 }
958 return -1;
959}
960
961inline ttk::SimplexId
962 ttk::PeriodicImplicitTriangulation::getEdgeLink2dL(const SimplexId p[2],
963 const int id) const {
964 if(p[1] > 0 and p[1] < nbvoxels_[Dj_]) {
965 switch(id) {
966 case 0:
967 return p[0] + (p[1] + 1) * vshift_[0];
968 case 1:
969 return ((p[0] < nbvoxels_[Di_])
970 ? (p[0] + (p[1] - 1) * vshift_[0] + 1)
971 : (p[0] + (p[1] - 1) * vshift_[0] + 1 - wrap_[0]));
972 }
973 return -1;
974 } else if(p[1] == 0) {
975 switch(id) {
976 case 0:
977 return p[0] + (p[1] + 1) * vshift_[0];
978 case 1:
979 return ((p[0] < nbvoxels_[Di_])
980 ? (p[0] + (p[1] - 1) * vshift_[0] + 1)
981 : (p[0] + (p[1] - 1) * vshift_[0] + 1 - wrap_[0]))
982 + wrap_[1];
983 }
984 return -1;
985 } else {
986 switch(id) {
987 case 0:
988 return p[0] + (p[1] + 1) * vshift_[0] - wrap_[1];
989 case 1:
990 return ((p[0] < nbvoxels_[Di_])
991 ? (p[0] + (p[1] - 1) * vshift_[0] + 1)
992 : (p[0] + (p[1] - 1) * vshift_[0] + 1 - wrap_[0]));
993 }
994 return -1;
995 }
996}
997
998inline ttk::SimplexId
999 ttk::PeriodicImplicitTriangulation::getEdgeLink2dH(const SimplexId p[2],
1000 const int id) const {
1001 if(p[0] > 0 and p[0] < nbvoxels_[Di_]) {
1002 switch(id) {
1003 case 0:
1004 return p[0] + p[1] * vshift_[0] + 1;
1005 case 1:
1006 return ((p[1] < nbvoxels_[Dj_])
1007 ? (p[0] + (p[1] + 1) * vshift_[0] - 1)
1008 : (p[0] + (p[1] + 1) * vshift_[0] - 1 - wrap_[1]));
1009 }
1010 return -1;
1011 } else if(p[0] == 0) {
1012 switch(id) {
1013 case 0:
1014 return p[0] + p[1] * vshift_[0] + 1 + wrap_[0];
1015 case 1:
1016 return ((p[1] < nbvoxels_[Dj_])
1017 ? (p[0] + (p[1] + 1) * vshift_[0] - 1)
1018 : (p[0] + (p[1] + 1) * vshift_[0] - 1 - wrap_[1]));
1019 }
1020 return -1;
1021 } else {
1022 switch(id) {
1023 case 0:
1024 return p[0] + p[1] * vshift_[0] + 1;
1025 case 1:
1026 return ((p[1] < nbvoxels_[Dj_])
1027 ? (p[0] + (p[1] + 1) * vshift_[0] - 1)
1028 : (p[0] + (p[1] + 1) * vshift_[0] - 1 - wrap_[1]))
1029 - wrap_[0];
1030 }
1031 return -1;
1032 }
1033}
1034
1035inline ttk::SimplexId
1036 ttk::PeriodicImplicitTriangulation::getEdgeLink2dD1(const SimplexId p[2],
1037 const int id) const {
1038 const SimplexId wrapX = (p[0] < nbvoxels_[Di_]) ? 0 : wrap_[0];
1039 const SimplexId wrapY = (p[1] < nbvoxels_[Dj_]) ? 0 : wrap_[1];
1040 switch(id) {
1041 case 0:
1042 return p[0] + p[1] * vshift_[0];
1043 case 1:
1044 return p[0] + (p[1] + 1) * vshift_[0] + 1 - wrapX - wrapY;
1045 }
1046 return -1;
1047}
1048
1049inline ttk::SimplexId
1050 ttk::PeriodicImplicitTriangulation::getEdgeStar2dL(const SimplexId p[2],
1051 const int id) const {
1052 if(p[1] == 0) {
1053 switch(id) {
1054 case 0:
1055 return p[0] * 2 + p[1] * tshift_[0];
1056 case 1:
1057 return p[0] * 2 + (p[1] - 1) * tshift_[0] + 1 + 2 * wrap_[1];
1058 }
1059 return -1;
1060 } else {
1061 switch(id) {
1062 case 0:
1063 return p[0] * 2 + p[1] * tshift_[0];
1064 case 1:
1065 return p[0] * 2 + (p[1] - 1) * tshift_[0] + 1;
1066 }
1067 return -1;
1068 }
1069}
1070
1071inline ttk::SimplexId
1072 ttk::PeriodicImplicitTriangulation::getEdgeStar2dH(const SimplexId p[2],
1073 const int id) const {
1074 if(p[0] == 0) {
1075 switch(id) {
1076 case 0:
1077 return p[0] * 2 + p[1] * tshift_[0];
1078 case 1:
1079 return (p[0] - 1) * 2 + p[1] * tshift_[0] + 1 + 2 * wrap_[0];
1080 }
1081 return -1;
1082 } else {
1083 switch(id) {
1084 case 0:
1085 return p[0] * 2 + p[1] * tshift_[0];
1086 case 1:
1087 return (p[0] - 1) * 2 + p[1] * tshift_[0] + 1;
1088 }
1089 return -1;
1090 }
1091}
1092
1093inline void
1095 SimplexId p[3]) const {
1096 if(isAccelerated_) {
1097 p[0] = vertex & mod_[0];
1098 p[1] = (vertex & mod_[1]) >> div_[0];
1099 p[2] = vertex >> div_[1];
1100 } else {
1101 p[0] = vertex % vshift_[0];
1102 p[1] = (vertex % vshift_[1]) / vshift_[0];
1103 p[2] = vertex / vshift_[1];
1104 }
1105}
1106
1107inline void ttk::PeriodicImplicitTriangulation::edgeToPosition(
1108 const SimplexId edge, const int k, SimplexId p[3]) const {
1109 const int e = (k) ? edge - esetshift_[k - 1] : edge;
1110 p[0] = e % eshift_[2 * k];
1111 p[1] = (e % eshift_[2 * k + 1]) / eshift_[2 * k];
1112 p[2] = e / eshift_[2 * k + 1];
1113}
1114
1116 const SimplexId triangle, const int k, SimplexId p[3]) const {
1117 const SimplexId t = (k) ? triangle - tsetshift_[k - 1] : triangle;
1118 p[0] = t % tshift_[2 * k];
1119 p[1] = (t % tshift_[2 * k + 1]) / tshift_[2 * k];
1120 p[2] = t / tshift_[2 * k + 1];
1121}
1122
1124 const SimplexId tetrahedron, SimplexId p[3]) const {
1125 p[0] = (tetrahedron % tetshift_[0]) / 6;
1126 p[1] = (tetrahedron % tetshift_[1]) / tetshift_[0];
1127 p[2] = tetrahedron / tetshift_[1];
1128}
1129
1130inline ttk::SimplexId ttk::PeriodicImplicitTriangulation::getVertexNeighbor3d(
1131 const SimplexId p[3], const SimplexId v, const int id) const {
1132 SimplexId wrapXLeft = 0;
1133 SimplexId wrapXRight = 0;
1134 SimplexId wrapYTop = 0;
1135 SimplexId wrapYBottom = 0;
1136 SimplexId wrapZBack = 0;
1137 SimplexId wrapZFront = 0;
1138 if(p[0] == 0)
1139 wrapXLeft = wrap_[0];
1140 if(p[0] == nbvoxels_[0])
1141 wrapXRight = -wrap_[0];
1142 if(p[1] == 0)
1143 wrapYTop = wrap_[1];
1144 if(p[1] == nbvoxels_[1])
1145 wrapYBottom = -wrap_[1];
1146 if(p[2] == 0)
1147 wrapZBack = wrap_[2];
1148 if(p[2] == nbvoxels_[2])
1149 wrapZFront = -wrap_[2];
1150 switch(id) {
1151 case 0:
1152 return v - vshift_[0] - vshift_[1] + wrapYTop + wrapZBack;
1153 case 1:
1154 return v + 1 - vshift_[0] - vshift_[1] + wrapXRight + wrapYTop
1155 + wrapZBack;
1156 case 2:
1157 return v - vshift_[1] + wrapZBack;
1158 case 3:
1159 return v + 1 - vshift_[1] + wrapXRight + wrapZBack;
1160 case 4:
1161 return v - vshift_[0] + wrapYTop;
1162 case 5:
1163 return v + 1 - vshift_[0] + wrapXRight + wrapYTop;
1164 case 6:
1165 return v + 1 + wrapXRight;
1166 case 7:
1167 return v - 1 + vshift_[1] + wrapXLeft + wrapZFront;
1168 case 8:
1169 return v + vshift_[1] + wrapZFront;
1170 case 9:
1171 return v - 1 + wrapXLeft;
1172 case 10:
1173 return v - 1 + vshift_[0] + wrapXLeft + wrapYBottom;
1174 case 11:
1175 return v + vshift_[0] + wrapYBottom;
1176 case 12:
1177 return v - 1 + vshift_[0] + vshift_[1] + wrapXLeft + wrapYBottom
1178 + wrapZFront;
1179 case 13:
1180 return v + vshift_[0] + vshift_[1] + wrapYBottom + wrapZFront;
1181 }
1182 return -1;
1183}
1184
1185inline ttk::SimplexId
1186 ttk::PeriodicImplicitTriangulation::getVertexEdge3d(const SimplexId p[3],
1187 const int id) const {
1188 SimplexId wrapXLeft = 0;
1189 SimplexId wrapYTop = 0;
1190 SimplexId wrapZBack = 0;
1191 if(p[0] == 0)
1192 wrapXLeft = wrap_[0];
1193 if(p[1] == 0)
1194 wrapYTop = wrap_[1];
1195 if(p[2] == 0)
1196 wrapZBack = wrap_[2];
1197 switch(id) {
1198 case 0:
1199 return esetshift_[3] + p[0] + (p[1] - 1) * eshift_[8]
1200 + (p[2] - 1) * eshift_[9] + wrapYTop + wrapZBack;
1201 case 1:
1202 return esetshift_[5] + p[0] + (p[1] - 1) * eshift_[12]
1203 + (p[2] - 1) * eshift_[13] + wrapYTop + wrapZBack;
1204 case 2:
1205 return esetshift_[1] + p[0] + p[1] * eshift_[4] + (p[2] - 1) * eshift_[5]
1206 + wrapZBack;
1207 case 3:
1208 return esetshift_[4] + p[0] + p[1] * eshift_[10]
1209 + (p[2] - 1) * eshift_[11] + wrapZBack;
1210 case 4:
1211 return esetshift_[0] + p[0] + (p[1] - 1) * eshift_[2] + p[2] * eshift_[3]
1212 + wrapYTop;
1213 case 5:
1214 return esetshift_[2] + p[0] + (p[1] - 1) * eshift_[6] + p[2] * eshift_[7]
1215 + wrapYTop;
1216 case 6:
1217 return p[0] + p[1] * eshift_[0] + p[2] * eshift_[1];
1218 case 7:
1219 return esetshift_[4] + p[0] + p[1] * eshift_[10] + p[2] * eshift_[11] - 1
1220 + wrapXLeft;
1221 case 8:
1222 return esetshift_[1] + p[0] + p[1] * eshift_[4] + p[2] * eshift_[5];
1223 case 9:
1224 return p[0] + p[1] * eshift_[0] + p[2] * eshift_[1] - 1 + wrapXLeft;
1225 case 10:
1226 return esetshift_[2] + p[0] + p[1] * eshift_[6] + p[2] * eshift_[7] - 1
1227 + wrapXLeft;
1228 case 11:
1229 return esetshift_[0] + p[0] + p[1] * eshift_[2] + p[2] * eshift_[3];
1230 case 12:
1231 return esetshift_[5] + p[0] + p[1] * eshift_[12] + p[2] * eshift_[13] - 1
1232 + wrapXLeft;
1233 case 13:
1234 return esetshift_[3] + p[0] + p[1] * eshift_[8] + p[2] * eshift_[9];
1235 }
1236 return -1;
1237}
1238
1239inline ttk::SimplexId
1240 ttk::PeriodicImplicitTriangulation::getVertexLink3d(const SimplexId p[3],
1241 const int id) const {
1242 SimplexId wrapXLeft = 0;
1243 SimplexId wrapXRight = 0;
1244 SimplexId wrapYTop = 0;
1245 SimplexId wrapYBottom = 0;
1246 SimplexId wrapZBack = 0;
1247 SimplexId wrapZFront = 0;
1248 if(p[0] == 0)
1249 wrapXLeft = 2 * wrap_[0];
1250 if(p[0] == nbvoxels_[0])
1251 wrapXRight = -2 * wrap_[0];
1252 if(p[1] == 0)
1253 wrapYTop = 2 * wrap_[1];
1254 if(p[1] == nbvoxels_[1])
1255 wrapYBottom = -2 * wrap_[1];
1256 if(p[2] == 0)
1257 wrapZBack = 2 * wrap_[2];
1258 if(p[2] == nbvoxels_[2])
1259 wrapZFront = -2 * wrap_[2];
1260 switch(id) {
1261 case 0:
1262 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10] + p[2] * tshift_[11];
1263 case 1:
1264 return tsetshift_[2] + p[0] * 2 + p[1] * tshift_[6] + p[2] * tshift_[7]
1265 + 1;
1266 case 2:
1267 return tsetshift_[1] + (p[0] - 1) * 2 + p[1] * tshift_[4]
1268 + p[2] * tshift_[5] + wrapXLeft;
1269 case 3:
1270 return tsetshift_[1] + (p[0] - 1) * 2 + p[1] * tshift_[4]
1271 + p[2] * tshift_[5] + 1 + wrapXLeft;
1272 case 4:
1273 return tsetshift_[0] + (p[0] - 1) * 2 + (p[1] + 1) * tshift_[2]
1274 + p[2] * tshift_[3] + wrapXLeft + wrapYBottom;
1275 case 5:
1276 return tsetshift_[0] + (p[0] - 1) * 2 + (p[1] + 1) * tshift_[2]
1277 + p[2] * tshift_[3] + 1 + wrapXLeft + wrapYBottom;
1278 case 6:
1279 return (p[0] - 1) * 2 + p[1] * tshift_[0] + (p[2] + 1) * tshift_[1]
1280 + wrapXLeft + wrapZFront;
1281 case 7:
1282 return (p[0] - 1) * 2 + p[1] * tshift_[0] + (p[2] + 1) * tshift_[1] + 1
1283 + wrapXLeft + wrapZFront;
1284 case 8:
1285 return tsetshift_[3] + p[0] * 2 + (p[1] - 1) * tshift_[8]
1286 + p[2] * tshift_[9] + wrapYTop;
1287 case 9:
1288 return tsetshift_[2] + p[0] * 2 + (p[1] - 1) * tshift_[6]
1289 + p[2] * tshift_[7] + wrapYTop;
1290 case 10:
1291 return tsetshift_[4] + (p[0] - 1) * 2 + (p[1] - 1) * tshift_[10]
1292 + p[2] * tshift_[11] + wrapXLeft + wrapYTop;
1293 case 11:
1294 return tsetshift_[3] + (p[0] - 1) * 2 + (p[1] - 1) * tshift_[8]
1295 + p[2] * tshift_[9] + 1 + wrapXLeft + wrapYTop;
1296 case 12:
1297 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8]
1298 + (p[2] - 1) * tshift_[9] + wrapZBack;
1299 case 13:
1300 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10]
1301 + (p[2] - 1) * tshift_[11] + 1 + wrapZBack;
1302 case 14:
1303 return tsetshift_[2] + (p[0] - 1) * 2 + p[1] * tshift_[6]
1304 + (p[2] - 1) * tshift_[7] + 1 + wrapXLeft + wrapZBack;
1305 case 15:
1306 return tsetshift_[3] + (p[0] - 1) * 2 + p[1] * tshift_[8]
1307 + (p[2] - 1) * tshift_[9] + 1 + wrapXLeft + wrapZBack;
1308 case 16:
1309 return tsetshift_[1] + (p[0] + 1) * 2 + (p[1] - 1) * tshift_[4]
1310 + (p[2] - 1) * tshift_[5] + wrapXRight + wrapYTop + wrapZBack;
1311 case 17:
1312 return tsetshift_[1] + (p[0] + 1) * 2 + (p[1] - 1) * tshift_[4]
1313 + (p[2] - 1) * tshift_[5] + 1 + wrapXRight + wrapYTop + wrapZBack;
1314 case 18:
1315 return tsetshift_[0] + p[0] * 2 + (p[1] - 1) * tshift_[2]
1316 + (p[2] - 1) * tshift_[3] + wrapYTop + wrapZBack;
1317 case 19:
1318 return tsetshift_[0] + p[0] * 2 + (p[1] - 1) * tshift_[2]
1319 + (p[2] - 1) * tshift_[3] + 1 + wrapYTop + wrapZBack;
1320 case 20:
1321 return p[0] * 2 + (p[1] - 1) * tshift_[0] + (p[2] - 1) * tshift_[1]
1322 + wrapYTop + wrapZBack;
1323 case 21:
1324 return p[0] * 2 + (p[1] - 1) * tshift_[0] + (p[2] - 1) * tshift_[1] + 1
1325 + wrapYTop + wrapZBack;
1326 case 22:
1327 return tsetshift_[4] + (p[0] - 1) * 2 + (p[1] - 1) * tshift_[10]
1328 + (p[2] - 1) * tshift_[11] + 1 + wrapXLeft + wrapYTop + wrapZBack;
1329 case 23:
1330 return tsetshift_[2] + (p[0] - 1) * 2 + (p[1] - 1) * tshift_[6]
1331 + (p[2] - 1) * tshift_[7] + wrapXLeft + wrapYTop + wrapZBack;
1332 }
1333 return -1;
1334}
1335
1336inline ttk::SimplexId
1337 ttk::PeriodicImplicitTriangulation::getVertexTriangle3d(const SimplexId p[3],
1338 const int id) const {
1339 SimplexId wrapXLeft = 0;
1340 SimplexId wrapYTop = 0;
1341 SimplexId wrapZBack = 0;
1342 if(p[0] == 0)
1343 wrapXLeft = 2 * wrap_[0];
1344 if(p[1] == 0)
1345 wrapYTop = 2 * wrap_[1];
1346 if(p[2] == 0)
1347 wrapZBack = 2 * wrap_[2];
1348 switch(id) {
1349 case 0:
1350 return (p[0] - 1) * 2 + p[1] * tshift_[0] + p[2] * tshift_[1] + 1
1351 + wrapXLeft;
1352 case 1:
1353 return tsetshift_[4] + (p[0] - 1) * 2 + p[1] * tshift_[10]
1354 + p[2] * tshift_[11] + wrapXLeft;
1355 case 2:
1356 return tsetshift_[2] + (p[0] - 1) * 2 + p[1] * tshift_[6]
1357 + p[2] * tshift_[7] + wrapXLeft;
1358 case 3:
1359 return tsetshift_[3] + (p[0] - 1) * 2 + p[1] * tshift_[8]
1360 + p[2] * tshift_[9] + 1 + wrapXLeft;
1361 case 4:
1362 return tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4] + p[2] * tshift_[5];
1363 case 5:
1364 return tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4] + p[2] * tshift_[5]
1365 + 1;
1366 case 6:
1367 return tsetshift_[4] + (p[0] - 1) * 2 + p[1] * tshift_[10]
1368 + p[2] * tshift_[11] + 1 + wrapXLeft;
1369 case 7:
1370 return tsetshift_[0] + (p[0] - 1) * 2 + p[1] * tshift_[2]
1371 + p[2] * tshift_[3] + 1 + wrapXLeft;
1372 case 8:
1373 return tsetshift_[2] + (p[0] - 1) * 2 + p[1] * tshift_[6]
1374 + p[2] * tshift_[7] + 1 + wrapXLeft;
1375 case 9:
1376 return tsetshift_[3] + (p[0] - 1) * 2 + p[1] * tshift_[8]
1377 + p[2] * tshift_[9] + wrapXLeft;
1378 case 10:
1379 return tsetshift_[0] + (p[0] - 1) * 2 + p[1] * tshift_[2]
1380 + p[2] * tshift_[3] + wrapXLeft;
1381 case 11:
1382 return (p[0] - 1) * 2 + p[1] * tshift_[0] + p[2] * tshift_[1] + wrapXLeft;
1383 case 12:
1384 return p[0] * 2 + tsetshift_[2] + (p[1] - 1) * tshift_[6]
1385 + (p[2] - 1) * tshift_[7] + wrapYTop + wrapZBack;
1386 case 13:
1387 return p[0] * 2 + tsetshift_[2] + (p[1] - 1) * tshift_[6]
1388 + (p[2] - 1) * tshift_[7] + 1 + wrapYTop + wrapZBack;
1389 case 14:
1390 return p[0] * 2 + tsetshift_[1] + (p[1] - 1) * tshift_[4]
1391 + (p[2] - 1) * tshift_[5] + wrapYTop + wrapZBack;
1392 case 15:
1393 return p[0] * 2 + tsetshift_[1] + (p[1] - 1) * tshift_[4]
1394 + (p[2] - 1) * tshift_[5] + 1 + wrapYTop + wrapZBack;
1395 case 16:
1396 return p[0] * 2 + tsetshift_[3] + (p[1] - 1) * tshift_[8]
1397 + (p[2] - 1) * tshift_[9] + wrapYTop + wrapZBack;
1398 case 17:
1399 return p[0] * 2 + tsetshift_[3] + (p[1] - 1) * tshift_[8]
1400 + (p[2] - 1) * tshift_[9] + 1 + wrapYTop + wrapZBack;
1401 case 18:
1402 return p[0] * 2 + tsetshift_[4] + (p[1] - 1) * tshift_[10]
1403 + (p[2] - 1) * tshift_[11] + wrapYTop + wrapZBack;
1404 case 19:
1405 return p[0] * 2 + tsetshift_[4] + (p[1] - 1) * tshift_[10]
1406 + (p[2] - 1) * tshift_[11] + 1 + wrapYTop + wrapZBack;
1407 case 20:
1408 return p[0] * 2 + (p[1] - 1) * tshift_[0] + p[2] * tshift_[1] + wrapYTop;
1409 case 21:
1410 return p[0] * 2 + (p[1] - 1) * tshift_[0] + p[2] * tshift_[1] + 1
1411 + wrapYTop;
1412 case 22:
1413 return p[0] * 2 + tsetshift_[0] + p[1] * tshift_[2]
1414 + (p[2] - 1) * tshift_[3] + wrapZBack;
1415 case 23:
1416 return p[0] * 2 + tsetshift_[0] + p[1] * tshift_[2]
1417 + (p[2] - 1) * tshift_[3] + 1 + wrapZBack;
1418 case 24:
1419 return (p[0] - 1) * 2 + (p[1] - 1) * tshift_[0] + p[2] * tshift_[1] + 1
1420 + wrapXLeft + wrapYTop;
1421 case 25:
1422 return tsetshift_[2] + (p[0] - 1) * 2 + (p[1] - 1) * tshift_[6]
1423 + p[2] * tshift_[7] + wrapXLeft + wrapYTop;
1424 case 26:
1425 return tsetshift_[1] + p[0] * 2 + (p[1] - 1) * tshift_[4]
1426 + p[2] * tshift_[5] + wrapYTop;
1427 case 27:
1428 return p[0] * 2 + tsetshift_[2] + p[1] * tshift_[6]
1429 + (p[2] - 1) * tshift_[7] + 1 + wrapZBack;
1430 case 28:
1431 return p[0] * 2 + tsetshift_[1] + p[1] * tshift_[4]
1432 + (p[2] - 1) * tshift_[5] + 1 + wrapZBack;
1433 case 29:
1434 return p[0] * 2 + p[1] * tshift_[0] + p[2] * tshift_[1];
1435 case 30:
1436 return tsetshift_[3] + (p[0] - 1) * 2 + (p[1] - 1) * tshift_[8]
1437 + (p[2] - 1) * tshift_[9] + 1 + wrapXLeft + wrapYTop + wrapZBack;
1438 case 31:
1439 return tsetshift_[0] + (p[0] - 1) * 2 + p[1] * tshift_[2]
1440 + (p[2] - 1) * tshift_[3] + 1 + wrapXLeft + wrapZBack;
1441 case 32:
1442 return tsetshift_[0] + p[0] * 2 + p[1] * tshift_[2] + p[2] * tshift_[3];
1443 case 33:
1444 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8] + p[2] * tshift_[9];
1445 case 34:
1446 return tsetshift_[4] + (p[0] - 1) * 2 + p[1] * tshift_[10]
1447 + (p[2] - 1) * tshift_[11] + 1 + wrapXLeft + wrapZBack;
1448 case 35:
1449 return p[0] * 2 + tsetshift_[4] + (p[1] - 1) * tshift_[10]
1450 + p[2] * tshift_[11] + wrapYTop;
1451 }
1452 return -1;
1453}
1454
1455inline ttk::SimplexId
1456 ttk::PeriodicImplicitTriangulation::getVertexStar3d(const SimplexId p[3],
1457 const int id) const {
1458 SimplexId wrapXLeft = 0;
1459 SimplexId wrapYTop = 0;
1460 SimplexId wrapZBack = 0;
1461 if(p[0] == 0)
1462 wrapXLeft = 6 * wrap_[0];
1463 if(p[1] == 0)
1464 wrapYTop = 6 * wrap_[1];
1465 if(p[2] == 0)
1466 wrapZBack = 6 * wrap_[2];
1467 switch(id) {
1468 case 0:
1469 return (p[0] - 1) * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1]
1470 + wrapXLeft;
1471 case 1:
1472 return (p[0] - 1) * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 1
1473 + wrapXLeft;
1474 case 2:
1475 return (p[0] - 1) * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 2
1476 + wrapXLeft;
1477 case 3:
1478 return (p[0] - 1) * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 3
1479 + wrapXLeft;
1480 case 4:
1481 return (p[0] - 1) * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 4
1482 + wrapXLeft;
1483 case 5:
1484 return (p[0] - 1) * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 5
1485 + wrapXLeft;
1486 case 6:
1487 return p[0] * 6 + (p[1] - 1) * tetshift_[0] + (p[2] - 1) * tetshift_[1]
1488 + wrapYTop + wrapZBack;
1489 case 7:
1490 return p[0] * 6 + (p[1] - 1) * tetshift_[0] + (p[2] - 1) * tetshift_[1]
1491 + 1 + wrapYTop + wrapZBack;
1492 case 8:
1493 return p[0] * 6 + (p[1] - 1) * tetshift_[0] + (p[2] - 1) * tetshift_[1]
1494 + 2 + wrapYTop + wrapZBack;
1495 case 9:
1496 return p[0] * 6 + (p[1] - 1) * tetshift_[0] + (p[2] - 1) * tetshift_[1]
1497 + 3 + wrapYTop + wrapZBack;
1498 case 10:
1499 return p[0] * 6 + (p[1] - 1) * tetshift_[0] + (p[2] - 1) * tetshift_[1]
1500 + 4 + wrapYTop + wrapZBack;
1501 case 11:
1502 return p[0] * 6 + (p[1] - 1) * tetshift_[0] + (p[2] - 1) * tetshift_[1]
1503 + 5 + wrapYTop + wrapZBack;
1504 case 12:
1505 return p[0] * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1];
1506 case 13:
1507 return p[0] * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 2;
1508 case 14:
1509 return p[0] * 6 + (p[1] - 1) * tetshift_[0] + p[2] * tetshift_[1]
1510 + wrapYTop;
1511 case 15:
1512 return p[0] * 6 + (p[1] - 1) * tetshift_[0] + p[2] * tetshift_[1] + 1
1513 + wrapYTop;
1514 case 16:
1515 return (p[0] - 1) * 6 + (p[1] - 1) * tetshift_[0] + p[2] * tetshift_[1]
1516 + 1 + wrapXLeft + wrapYTop;
1517 case 17:
1518 return (p[0] - 1) * 6 + (p[1] - 1) * tetshift_[0] + p[2] * tetshift_[1]
1519 + 5 + wrapXLeft + wrapYTop;
1520 case 18:
1521 return p[0] * 6 + p[1] * tetshift_[0] + (p[2] - 1) * tetshift_[1] + 2
1522 + wrapZBack;
1523 case 19:
1524 return p[0] * 6 + p[1] * tetshift_[0] + (p[2] - 1) * tetshift_[1] + 3
1525 + wrapZBack;
1526 case 20:
1527 return (p[0] - 1) * 6 + p[1] * tetshift_[0] + (p[2] - 1) * tetshift_[1]
1528 + 3 + wrapXLeft + wrapZBack;
1529 case 21:
1530 return (p[0] - 1) * 6 + p[1] * tetshift_[0] + (p[2] - 1) * tetshift_[1]
1531 + 4 + wrapXLeft + wrapZBack;
1532 case 22:
1533 return (p[0] - 1) * 6 + (p[1] - 1) * tetshift_[0]
1534 + (p[2] - 1) * tetshift_[1] + 4 + wrapXLeft + wrapYTop + wrapZBack;
1535 case 23:
1536 return (p[0] - 1) * 6 + (p[1] - 1) * tetshift_[0]
1537 + (p[2] - 1) * tetshift_[1] + 5 + wrapXLeft + wrapYTop + wrapZBack;
1538 }
1539 return -1;
1540}
1541
1542inline ttk::SimplexId
1543 ttk::PeriodicImplicitTriangulation::getEdgeTriangle3dL(const SimplexId p[3],
1544 const int id) const {
1545 SimplexId wrapYTop = 0;
1546 SimplexId wrapZBack = 0;
1547 if(p[1] == 0)
1548 wrapYTop = 2 * wrap_[1];
1549 if(p[2] == 0)
1550 wrapZBack = 2 * wrap_[2];
1551 switch(id) {
1552 case 0:
1553 return p[0] * 2 + (p[1] - 1) * tshift_[0] + p[2] * tshift_[1] + 1
1554 + wrapYTop;
1555 case 1:
1556 return tsetshift_[0] + p[0] * 2 + p[1] * tshift_[2] + p[2] * tshift_[3];
1557 case 2:
1558 return tsetshift_[0] + p[0] * 2 + p[1] * tshift_[2]
1559 + (p[2] - 1) * tshift_[3] + 1 + wrapZBack;
1560 case 3:
1561 return tsetshift_[3] + p[0] * 2 + (p[1] - 1) * tshift_[8]
1562 + (p[2] - 1) * tshift_[9] + 1 + wrapYTop + wrapZBack;
1563 case 4:
1564 return p[0] * 2 + p[1] * tshift_[0] + p[2] * tshift_[1];
1565 case 5:
1566 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8] + p[2] * tshift_[9];
1567 }
1568 return -1;
1569}
1570
1571inline ttk::SimplexId
1572 ttk::PeriodicImplicitTriangulation::getEdgeTriangle3dH(const SimplexId p[3],
1573 const int id) const {
1574 SimplexId wrapXLeft = 0;
1575 SimplexId wrapZBack = 0;
1576 if(p[0] == 0)
1577 wrapXLeft = 2 * wrap_[0];
1578 if(p[2] == 0)
1579 wrapZBack = 2 * wrap_[2];
1580 switch(id) {
1581 case 0:
1582 return (p[0] - 1) * 2 + p[1] * tshift_[0] + p[2] * tshift_[1] + 1
1583 + wrapXLeft;
1584 case 1:
1585 return tsetshift_[2] + (p[0] - 1) * 2 + p[1] * tshift_[6]
1586 + p[2] * tshift_[7] + wrapXLeft;
1587 case 2:
1588 return tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4] + p[2] * tshift_[5];
1589 case 3:
1590 return tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4]
1591 + (p[2] - 1) * tshift_[5] + 1 + wrapZBack;
1592 case 4:
1593 return tsetshift_[2] + p[0] * 2 + p[1] * tshift_[6]
1594 + (p[2] - 1) * tshift_[7] + 1 + wrapZBack;
1595 case 5:
1596 return p[0] * 2 + p[1] * tshift_[0] + p[2] * tshift_[1];
1597 }
1598 return -1;
1599}
1600
1601inline ttk::SimplexId
1602 ttk::PeriodicImplicitTriangulation::getEdgeTriangle3dP(const SimplexId p[3],
1603 const int id) const {
1604 SimplexId wrapXLeft = 0;
1605 SimplexId wrapYTop = 0;
1606 if(p[0] == 0)
1607 wrapXLeft = 2 * wrap_[0];
1608 if(p[1] == 0)
1609 wrapYTop = 2 * wrap_[1];
1610 switch(id) {
1611 case 0:
1612 return tsetshift_[0] + (p[0] - 1) * 2 + p[1] * tshift_[2]
1613 + p[2] * tshift_[3] + 1 + wrapXLeft;
1614 case 1:
1615 return tsetshift_[4] + (p[0] - 1) * 2 + p[1] * tshift_[10]
1616 + p[2] * tshift_[11] + 1 + wrapXLeft;
1617 case 2:
1618 return tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4] + p[2] * tshift_[5]
1619 + 1;
1620 case 3:
1621 return tsetshift_[0] + p[0] * 2 + p[1] * tshift_[2] + p[2] * tshift_[3];
1622 case 4:
1623 return tsetshift_[4] + p[0] * 2 + (p[1] - 1) * tshift_[10]
1624 + p[2] * tshift_[11] + wrapYTop;
1625 case 5:
1626 return tsetshift_[1] + p[0] * 2 + (p[1] - 1) * tshift_[4]
1627 + p[2] * tshift_[5] + wrapYTop;
1628 }
1629 return -1;
1630}
1631
1632inline ttk::SimplexId
1633 ttk::PeriodicImplicitTriangulation::getEdgeTriangle3dD1(const SimplexId p[3],
1634 const int id) const {
1635 SimplexId wrapZBack = 0;
1636 if(p[2] == 0)
1637 wrapZBack = 2 * wrap_[2];
1638 switch(id) {
1639 case 0:
1640 return p[0] * 2 + p[1] * tshift_[0] + p[2] * tshift_[1];
1641 case 1:
1642 return p[0] * 2 + p[1] * tshift_[0] + p[2] * tshift_[1] + 1;
1643 case 2:
1644 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10] + p[2] * tshift_[11];
1645 case 3:
1646 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10]
1647 + (p[2] - 1) * tshift_[11] + 1 + wrapZBack;
1648 }
1649 return -1;
1650}
1651
1652inline ttk::SimplexId
1653 ttk::PeriodicImplicitTriangulation::getEdgeTriangle3dD2(const SimplexId p[3],
1654 const int id) const {
1655 SimplexId wrapXLeft = 0;
1656 if(p[0] == 0)
1657 wrapXLeft = 2 * wrap_[0];
1658 switch(id) {
1659 case 0:
1660 return tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4] + p[2] * tshift_[5];
1661 case 1:
1662 return tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4] + p[2] * tshift_[5]
1663 + 1;
1664 case 2:
1665 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8] + p[2] * tshift_[9];
1666 case 3:
1667 return tsetshift_[3] + (p[0] - 1) * 2 + p[1] * tshift_[8]
1668 + p[2] * tshift_[9] + 1 + wrapXLeft;
1669 }
1670 return -1;
1671}
1672
1673inline ttk::SimplexId
1674 ttk::PeriodicImplicitTriangulation::getEdgeTriangle3dD3(const SimplexId p[3],
1675 const int id) const {
1676 SimplexId wrapYTop = 0;
1677 if(p[1] == 0)
1678 wrapYTop = 2 * wrap_[1];
1679 switch(id) {
1680 case 0:
1681 return tsetshift_[0] + p[0] * 2 + p[1] * tshift_[2] + p[2] * tshift_[3];
1682 case 1:
1683 return tsetshift_[0] + p[0] * 2 + p[1] * tshift_[2] + p[2] * tshift_[3]
1684 + 1;
1685 case 2:
1686 return tsetshift_[2] + p[0] * 2 + p[1] * tshift_[6] + p[2] * tshift_[7]
1687 + 1;
1688 case 3:
1689 return tsetshift_[2] + p[0] * 2 + (p[1] - 1) * tshift_[6]
1690 + p[2] * tshift_[7] + wrapYTop;
1691 }
1692 return -1;
1693}
1694
1695inline ttk::SimplexId
1696 ttk::PeriodicImplicitTriangulation::getEdgeTriangle3dD4(const SimplexId p[3],
1697 const int id) const {
1698 switch(id) {
1699 case 0:
1700 return tsetshift_[2] + p[0] * 2 + p[1] * tshift_[6] + p[2] * tshift_[7];
1701 case 1:
1702 return tsetshift_[2] + p[0] * 2 + p[1] * tshift_[6] + p[2] * tshift_[7]
1703 + 1;
1704 case 2:
1705 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8] + p[2] * tshift_[9];
1706 case 3:
1707 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8] + p[2] * tshift_[9]
1708 + 1;
1709 case 4:
1710 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10] + p[2] * tshift_[11];
1711 case 5:
1712 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10] + p[2] * tshift_[11]
1713 + 1;
1714 }
1715 return -1;
1716}
1717
1718inline ttk::SimplexId
1719 ttk::PeriodicImplicitTriangulation::getEdgeLinkL(const SimplexId p[3],
1720 const int id) const {
1721 SimplexId wrapXRight = 0;
1722 SimplexId wrapYTop = 0;
1723 SimplexId wrapYBottom = 0;
1724 SimplexId wrapZBack = 0;
1725 SimplexId wrapZFront = 0;
1726 if(p[0] == nbvoxels_[0])
1727 wrapXRight = -wrap_[0];
1728 if(p[1] == 0)
1729 wrapYTop = wrap_[1];
1730 if(p[1] == nbvoxels_[1])
1731 wrapYBottom = -wrap_[1];
1732 if(p[2] == 0)
1733 wrapZBack = wrap_[2];
1734 if(p[2] == nbvoxels_[2])
1735 wrapZFront = -wrap_[2];
1736 switch(id) {
1737 case 0:
1738 return esetshift_[1] + p[0] + (p[1] + 1) * eshift_[4] + p[2] * eshift_[5]
1739 + wrapYBottom;
1740 case 1:
1741 return esetshift_[0] + p[0] + p[1] * eshift_[2] + (p[2] + 1) * eshift_[3]
1742 + wrapZFront;
1743 case 2:
1744 return esetshift_[5] + p[0] + (p[1] - 1) * eshift_[12]
1745 + p[2] * eshift_[13] + wrapYTop;
1746 case 3:
1747 return esetshift_[1] + p[0] + 1 + (p[1] - 1) * eshift_[4]
1748 + (p[2] - 1) * eshift_[5] + wrapXRight + wrapYTop + wrapZBack;
1749 case 4:
1750 return esetshift_[0] + p[0] + 1 + (p[1] - 1) * eshift_[2]
1751 + (p[2] - 1) * eshift_[3] + wrapXRight + wrapYTop + wrapZBack;
1752 case 5:
1753 return esetshift_[5] + p[0] + p[1] * eshift_[12]
1754 + (p[2] - 1) * eshift_[13] + wrapZBack;
1755 }
1756 return -1;
1757}
1758
1759inline ttk::SimplexId
1760 ttk::PeriodicImplicitTriangulation::getEdgeLinkH(const SimplexId p[3],
1761 const int id) const {
1762 SimplexId wrapXLeft = 0;
1763 SimplexId wrapXRight = 0;
1764 SimplexId wrapYBottom = 0;
1765 SimplexId wrapZBack = 0;
1766 SimplexId wrapZFront = 0;
1767 if(p[0] == 0)
1768 wrapXLeft = wrap_[0];
1769 if(p[0] == nbvoxels_[0])
1770 wrapXRight = -wrap_[0];
1771 if(p[1] == nbvoxels_[1])
1772 wrapYBottom = -wrap_[1];
1773 if(p[2] == 0)
1774 wrapZBack = wrap_[2];
1775 if(p[2] == nbvoxels_[2])
1776 wrapZFront = -wrap_[2];
1777 switch(id) {
1778 case 0:
1779 return p[0] + p[1] * eshift_[0] + (p[2] - 1) * eshift_[1] + wrapZBack;
1780 case 1:
1781 return p[0] + (p[1] + 1) * eshift_[0] + (p[2] + 1) * eshift_[1] - 1
1782 + wrapXLeft + wrapYBottom + wrapZFront;
1783 case 2:
1784 return esetshift_[1] + p[0] - 1 + (p[1] + 1) * eshift_[4]
1785 + p[2] * eshift_[5] + wrapXLeft + wrapYBottom;
1786 case 3:
1787 return esetshift_[1] + p[0] + 1 + p[1] * eshift_[4]
1788 + (p[2] - 1) * eshift_[5] + wrapXRight + wrapZBack;
1789 case 4:
1790 return esetshift_[5] + (p[0] - 1) + p[1] * eshift_[12]
1791 + (p[2] - 1) * eshift_[13] + wrapXLeft + wrapZBack;
1792 case 5:
1793 return esetshift_[5] + p[0] + p[1] * eshift_[12] + p[2] * eshift_[13];
1794 }
1795 return -1;
1796}
1797
1798inline ttk::SimplexId
1799 ttk::PeriodicImplicitTriangulation::getEdgeLinkP(const SimplexId p[3],
1800 const int id) const {
1801 SimplexId wrapXLeft = 0;
1802 SimplexId wrapXRight = 0;
1803 SimplexId wrapYTop = 0;
1804 SimplexId wrapYBottom = 0;
1805 SimplexId wrapZFront = 0;
1806 if(p[0] == 0)
1807 wrapXLeft = wrap_[0];
1808 if(p[0] == nbvoxels_[0])
1809 wrapXRight = -wrap_[0];
1810 if(p[1] == 0)
1811 wrapYTop = wrap_[1];
1812 if(p[1] == nbvoxels_[1])
1813 wrapYBottom = -wrap_[1];
1814 if(p[2] == nbvoxels_[2])
1815 wrapZFront = -wrap_[2];
1816 switch(id) {
1817 case 0:
1818 return p[0] + (p[1] - 1) * eshift_[0] + p[2] * eshift_[1] + wrapYTop;
1819 case 1:
1820 return p[0] + (p[1] + 1) * eshift_[0] + (p[2] + 1) * eshift_[1] - 1
1821 + wrapXLeft + wrapYBottom + wrapZFront;
1822 case 2:
1823 return esetshift_[5] + p[0] + p[1] * eshift_[12] + p[2] * eshift_[13];
1824 case 3:
1825 return esetshift_[5] + p[0] + (p[1] - 1) * eshift_[12]
1826 + p[2] * eshift_[13] - 1 + wrapXLeft + wrapYTop;
1827 case 4:
1828 return esetshift_[0] + p[0] + p[1] * eshift_[2] + (p[2] + 1) * eshift_[3]
1829 - 1 + wrapXLeft + wrapZFront;
1830 case 5:
1831 return esetshift_[0] + p[0] + (p[1] - 1) * eshift_[2] + p[2] * eshift_[3]
1832 + 1 + wrapXRight + wrapYTop;
1833 }
1834 return -1;
1835}
1836
1837inline ttk::SimplexId
1838 ttk::PeriodicImplicitTriangulation::getEdgeLinkD1(const SimplexId p[3],
1839 const int id) const {
1840 SimplexId wrapXRight = 0;
1841 SimplexId wrapYBottom = 0;
1842 SimplexId wrapZBack = 0;
1843 if(p[0] == nbvoxels_[0])
1844 wrapXRight = -wrap_[0];
1845 if(p[1] == nbvoxels_[1])
1846 wrapYBottom = -wrap_[1];
1847 if(p[2] == 0)
1848 wrapZBack = wrap_[2];
1849 switch(id) {
1850 case 0:
1851 return esetshift_[4] + p[0] + p[1] * eshift_[10]
1852 + (p[2] - 1) * eshift_[11] + wrapZBack;
1853 case 1:
1854 return esetshift_[4] + p[0] + (p[1] + 1) * eshift_[10]
1855 + p[2] * eshift_[11] + wrapYBottom;
1856 case 2:
1857 return esetshift_[3] + p[0] + p[1] * eshift_[8] + p[2] * eshift_[9];
1858 case 3:
1859 return esetshift_[3] + p[0] + p[1] * eshift_[8] + (p[2] - 1) * eshift_[9]
1860 + 1 + wrapXRight + wrapZBack;
1861 }
1862 return -1;
1863}
1864
1865inline ttk::SimplexId
1866 ttk::PeriodicImplicitTriangulation::getEdgeLinkD2(const SimplexId p[3],
1867 const int id) const {
1868 SimplexId wrapXLeft = 0;
1869 SimplexId wrapYBottom = 0;
1870 SimplexId wrapZFront = 0;
1871 if(p[0] == 0)
1872 wrapXLeft = wrap_[0];
1873 if(p[1] == nbvoxels_[1])
1874 wrapYBottom = -wrap_[1];
1875 if(p[2] == nbvoxels_[2])
1876 wrapZFront = -wrap_[2];
1877 switch(id) {
1878 case 0:
1879 return esetshift_[4] + p[0] + p[1] * eshift_[10] + p[2] * eshift_[11];
1880 case 1:
1881 return esetshift_[4] + p[0] + (p[1] + 1) * eshift_[10]
1882 + p[2] * eshift_[11] - 1 + wrapXLeft + wrapYBottom;
1883 case 2:
1884 return esetshift_[2] + p[0] + p[1] * eshift_[6] + p[2] * eshift_[7];
1885 case 3:
1886 return esetshift_[2] + p[0] + p[1] * eshift_[6] + (p[2] + 1) * eshift_[7]
1887 - 1 + wrapXLeft + wrapZFront;
1888 }
1889 return -1;
1890}
1891
1892inline ttk::SimplexId
1893 ttk::PeriodicImplicitTriangulation::getEdgeLinkD3(const SimplexId p[3],
1894 const int id) const {
1895 SimplexId wrapXRight = 0;
1896 SimplexId wrapYTop = 0;
1897 SimplexId wrapZFront = 0;
1898 if(p[0] == nbvoxels_[0])
1899 wrapXRight = -wrap_[0];
1900 if(p[1] == 0)
1901 wrapYTop = wrap_[1];
1902 if(p[2] == nbvoxels_[2])
1903 wrapZFront = -wrap_[2];
1904 switch(id) {
1905 case 0:
1906 return esetshift_[2] + p[0] + (p[1] - 1) * eshift_[6] + p[2] * eshift_[7]
1907 + wrapYTop;
1908 case 1:
1909 return esetshift_[2] + p[0] + p[1] * eshift_[6] + (p[2] + 1) * eshift_[7]
1910 + wrapZFront;
1911 case 2:
1912 return esetshift_[3] + p[0] + p[1] * eshift_[8] + p[2] * eshift_[9];
1913 case 3:
1914 return esetshift_[3] + p[0] + (p[1] - 1) * eshift_[8] + p[2] * eshift_[9]
1915 + 1 + wrapXRight + wrapYTop;
1916 }
1917 return -1;
1918}
1919
1920inline ttk::SimplexId
1921 ttk::PeriodicImplicitTriangulation::getEdgeLinkD4(const SimplexId p[3],
1922 const int id) const {
1923 SimplexId wrapXRight = 0;
1924 SimplexId wrapYBottom = 0;
1925 SimplexId wrapZFront = 0;
1926 if(p[0] == nbvoxels_[0])
1927 wrapXRight = -wrap_[0];
1928 if(p[1] == nbvoxels_[1])
1929 wrapYBottom = -wrap_[1];
1930 if(p[2] == nbvoxels_[2])
1931 wrapZFront = -wrap_[2];
1932 switch(id) {
1933 case 0:
1934 return p[0] + (p[1] + 1) * eshift_[0] + p[2] * eshift_[1] + wrapYBottom;
1935 case 1:
1936 return p[0] + p[1] * eshift_[0] + (p[2] + 1) * eshift_[1] + wrapZFront;
1937 case 2:
1938 return esetshift_[1] + p[0] + p[1] * eshift_[4] + p[2] * eshift_[5];
1939 case 3:
1940 return esetshift_[1] + p[0] + 1 + (p[1] + 1) * eshift_[4]
1941 + p[2] * eshift_[5] + wrapXRight + wrapYBottom;
1942 case 4:
1943 return esetshift_[0] + p[0] + p[1] * eshift_[2] + p[2] * eshift_[3];
1944 case 5:
1945 return esetshift_[0] + p[0] + 1 + p[1] * eshift_[2]
1946 + (p[2] + 1) * eshift_[3] + wrapXRight + wrapZFront;
1947 }
1948 return -1;
1949}
1950
1951inline ttk::SimplexId
1952 ttk::PeriodicImplicitTriangulation::getEdgeStarL(const SimplexId p[3],
1953 const int id) const {
1954 SimplexId wrapYTop = 0;
1955 SimplexId wrapZBack = 0;
1956 if(p[1] == 0)
1957 wrapYTop = 6 * wrap_[1];
1958 if(p[2] == 0)
1959 wrapZBack = 6 * wrap_[2];
1960 switch(id) {
1961 case 0:
1962 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6;
1963 case 1:
1964 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 2;
1965 case 2:
1966 return p[2] * tetshift_[1] + (p[1] - 1) * tetshift_[0] + p[0] * 6 + 1
1967 + wrapYTop;
1968 case 3:
1969 return (p[2] - 1) * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 3
1970 + wrapZBack;
1971 case 4:
1972 return (p[2] - 1) * tetshift_[1] + (p[1] - 1) * tetshift_[0] + p[0] * 6
1973 + 4 + wrapYTop + wrapZBack;
1974 case 5:
1975 return (p[2] - 1) * tetshift_[1] + (p[1] - 1) * tetshift_[0] + p[0] * 6
1976 + 5 + wrapYTop + wrapZBack;
1977 }
1978 return -1;
1979}
1980
1981inline ttk::SimplexId
1982 ttk::PeriodicImplicitTriangulation::getEdgeStarH(const SimplexId p[3],
1983 const int id) const {
1984 SimplexId wrapXLeft = 0;
1985 SimplexId wrapZBack = 0;
1986 if(p[0] == 0)
1987 wrapXLeft = 6 * wrap_[0];
1988 if(p[2] == 0)
1989 wrapZBack = 6 * wrap_[2];
1990 switch(id) {
1991 case 0:
1992 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6;
1993 case 1:
1994 return (p[2] - 1) * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 2
1995 + wrapZBack;
1996 case 2:
1997 return (p[2] - 1) * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 3
1998 + wrapZBack;
1999 case 3:
2000 return (p[2] - 1) * tetshift_[1] + p[1] * tetshift_[0] + (p[0] - 1) * 6
2001 + 4 + wrapXLeft + wrapZBack;
2002 case 4:
2003 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + (p[0] - 1) * 6 + 1
2004 + wrapXLeft;
2005 case 5:
2006 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + (p[0] - 1) * 6 + 5
2007 + wrapXLeft;
2008 }
2009 return -1;
2010}
2011
2012inline ttk::SimplexId
2013 ttk::PeriodicImplicitTriangulation::getEdgeStarP(const SimplexId p[3],
2014 const int id) const {
2015 SimplexId wrapXLeft = 0;
2016 SimplexId wrapYTop = 0;
2017 if(p[0] == 0)
2018 wrapXLeft = 6 * wrap_[0];
2019 if(p[1] == 0)
2020 wrapYTop = 6 * wrap_[1];
2021 switch(id) {
2022 case 0:
2023 return p[2] * tetshift_[1] + (p[1] - 1) * tetshift_[0] + (p[0] - 1) * 6
2024 + 5 + wrapXLeft + wrapYTop;
2025 case 1:
2026 return p[2] * tetshift_[1] + (p[1] - 1) * tetshift_[0] + p[0] * 6
2027 + wrapYTop;
2028 case 2:
2029 return p[2] * tetshift_[1] + (p[1] - 1) * tetshift_[0] + p[0] * 6 + 1
2030 + wrapYTop;
2031 case 3:
2032 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 2;
2033 case 4:
2034 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + (p[0] - 1) * 6 + 3
2035 + wrapXLeft;
2036 case 5:
2037 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + (p[0] - 1) * 6 + 4
2038 + wrapXLeft;
2039 }
2040 return -1;
2041}
2042
2043inline ttk::SimplexId
2044 ttk::PeriodicImplicitTriangulation::getEdgeStarD1(const SimplexId p[3],
2045 const int id) const {
2046 SimplexId wrapZBack = 0;
2047 if(p[2] == 0)
2048 wrapZBack = 6 * wrap_[2];
2049 switch(id) {
2050 case 0:
2051 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6;
2052 case 1:
2053 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 1;
2054 case 2:
2055 return (p[2] - 1) * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 3
2056 + wrapZBack;
2057 case 3:
2058 return (p[2] - 1) * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 4
2059 + wrapZBack;
2060 }
2061 return -1;
2062}
2063
2064inline ttk::SimplexId
2065 ttk::PeriodicImplicitTriangulation::getEdgeStarD2(const SimplexId p[3],
2066 const int id) const {
2067 SimplexId wrapXLeft = 0;
2068 if(p[0] == 0)
2069 wrapXLeft = 6 * wrap_[0];
2070 switch(id) {
2071 case 0:
2072 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6;
2073 case 1:
2074 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 2;
2075 case 2:
2076 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + (p[0] - 1) * 6 + 5
2077 + wrapXLeft;
2078 case 3:
2079 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + (p[0] - 1) * 6 + 4
2080 + wrapXLeft;
2081 }
2082 return -1;
2083}
2084
2085inline ttk::SimplexId
2086 ttk::PeriodicImplicitTriangulation::getEdgeStarD3(const SimplexId p[3],
2087 const int id) const {
2088 SimplexId wrapYTop = 0;
2089 if(p[1] == 0)
2090 wrapYTop = 6 * wrap_[1];
2091 switch(id) {
2092 case 0:
2093 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 2;
2094 case 1:
2095 return p[2] * tetshift_[1] + p[1] * tetshift_[0] + p[0] * 6 + 3;
2096 case 2:
2097 return p[2] * tetshift_[1] + (p[1] - 1) * tetshift_[0] + p[0] * 6 + 1
2098 + wrapYTop;
2099 case 3:
2100 return p[2] * tetshift_[1] + (p[1] - 1) * tetshift_[0] + p[0] * 6 + 5
2101 + wrapYTop;
2102 }
2103 return -1;
2104}
2105
2106inline ttk::SimplexId
2107 ttk::PeriodicImplicitTriangulation::getTriangleVertexF(const SimplexId p[3],
2108 const int id) const {
2109 SimplexId wrapXRight = 0;
2110 SimplexId wrapYBottom = 0;
2111 if(p[0] / 2 == nbvoxels_[0])
2112 wrapXRight = -wrap_[0];
2113 if(p[1] == nbvoxels_[1])
2114 wrapYBottom = -wrap_[1];
2115 if(p[0] % 2) {
2116 switch(id) {
2117 case 0:
2118 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2119 + wrapXRight;
2120 case 1:
2121 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2122 + wrapYBottom;
2123 case 2:
2124 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0] + 1
2125 + wrapXRight + wrapYBottom;
2126 }
2127 } else {
2128 switch(id) {
2129 case 0:
2130 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1];
2131 case 1:
2132 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2133 + wrapXRight;
2134 case 2:
2135 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2136 + wrapYBottom;
2137 }
2138 }
2139 return -1;
2140}
2141
2142inline ttk::SimplexId
2143 ttk::PeriodicImplicitTriangulation::getTriangleVertexH(const SimplexId p[3],
2144 const int id) const {
2145 SimplexId wrapXRight = 0;
2146 SimplexId wrapZFront = 0;
2147 if(p[0] / 2 == nbvoxels_[0])
2148 wrapXRight = -wrap_[0];
2149 if(p[2] == nbvoxels_[2])
2150 wrapZFront = -wrap_[2];
2151 if(p[0] % 2) {
2152 switch(id) {
2153 case 0:
2154 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2155 + wrapXRight;
2156 case 1:
2157 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1] + 1
2158 + wrapXRight + wrapZFront;
2159 case 2:
2160 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2161 + wrapZFront;
2162 }
2163 } else {
2164 switch(id) {
2165 case 0:
2166 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1];
2167 case 1:
2168 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2169 + wrapXRight;
2170 case 2:
2171 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2172 + wrapZFront;
2173 }
2174 }
2175 return -1;
2176}
2177
2178inline ttk::SimplexId
2179 ttk::PeriodicImplicitTriangulation::getTriangleVertexC(const SimplexId p[3],
2180 const int id) const {
2181 SimplexId wrapYBottom = 0;
2182 SimplexId wrapZFront = 0;
2183 if(p[1] == nbvoxels_[1])
2184 wrapYBottom = -wrap_[1];
2185 if(p[2] == nbvoxels_[2])
2186 wrapZFront = -wrap_[2];
2187 if(p[0] % 2) {
2188 switch(id) {
2189 case 0:
2190 return (p[0] / 2) + p[1] * vshift_[0] + p[2] * vshift_[1];
2191 case 1:
2192 return (p[0] / 2) + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2193 + wrapZFront;
2194 case 2:
2195 return (p[0] / 2) + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2196 + vshift_[0] + wrapYBottom + wrapZFront;
2197 }
2198 } else {
2199 switch(id) {
2200 case 0:
2201 return (p[0] / 2) + p[1] * vshift_[0] + p[2] * vshift_[1];
2202 case 1:
2203 return (p[0] / 2) + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2204 + wrapYBottom;
2205 case 2:
2206 return (p[0] / 2) + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2207 + vshift_[0] + wrapYBottom + wrapZFront;
2208 }
2209 }
2210 return -1;
2211}
2212
2213inline ttk::SimplexId
2214 ttk::PeriodicImplicitTriangulation::getTriangleVertexD1(const SimplexId p[3],
2215 const int id) const {
2216 SimplexId wrapXRight = 0;
2217 SimplexId wrapYBottom = 0;
2218 SimplexId wrapZFront = 0;
2219 if(p[0] / 2 == nbvoxels_[0])
2220 wrapXRight = -wrap_[0];
2221 if(p[1] == nbvoxels_[1])
2222 wrapYBottom = -wrap_[1];
2223 if(p[2] == nbvoxels_[2])
2224 wrapZFront = -wrap_[2];
2225 if(p[0] % 2) {
2226 switch(id) {
2227 case 0:
2228 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2229 + wrapXRight;
2230 case 1:
2231 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2232 + wrapZFront;
2233 case 2:
2234 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2235 + vshift_[0] + wrapYBottom + wrapZFront;
2236 }
2237 } else {
2238 switch(id) {
2239 case 0:
2240 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2241 + wrapXRight;
2242 case 1:
2243 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0] + 1
2244 + wrapXRight + wrapYBottom;
2245 case 2:
2246 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2247 + vshift_[0] + wrapYBottom + wrapZFront;
2248 }
2249 }
2250 return -1;
2251}
2252
2253inline ttk::SimplexId
2254 ttk::PeriodicImplicitTriangulation::getTriangleVertexD2(const SimplexId p[3],
2255 const int id) const {
2256 SimplexId wrapXRight = 0;
2257 SimplexId wrapYBottom = 0;
2258 SimplexId wrapZFront = 0;
2259 if(p[0] / 2 == nbvoxels_[0])
2260 wrapXRight = -wrap_[0];
2261 if(p[1] == nbvoxels_[1])
2262 wrapYBottom = -wrap_[1];
2263 if(p[2] == nbvoxels_[2])
2264 wrapZFront = -wrap_[2];
2265 if(p[0] % 2) {
2266 switch(id) {
2267 case 0:
2268 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2269 + wrapXRight;
2270 case 1:
2271 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2272 + vshift_[1] + 1 + wrapXRight + wrapYBottom + wrapZFront;
2273 case 2:
2274 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2275 + vshift_[1] + wrapYBottom + wrapZFront;
2276 }
2277 } else {
2278 switch(id) {
2279 case 0:
2280 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1];
2281 case 1:
2282 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2283 + wrapXRight;
2284 case 2:
2285 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2286 + vshift_[1] + wrapYBottom + wrapZFront;
2287 }
2288 }
2289 return -1;
2290}
2291
2292inline ttk::SimplexId
2293 ttk::PeriodicImplicitTriangulation::getTriangleVertexD3(const SimplexId p[3],
2294 const int id) const {
2295 SimplexId wrapXRight = 0;
2296 SimplexId wrapYBottom = 0;
2297 SimplexId wrapZFront = 0;
2298 if(p[0] / 2 == nbvoxels_[0])
2299 wrapXRight = -wrap_[0];
2300 if(p[1] == nbvoxels_[1])
2301 wrapYBottom = -wrap_[1];
2302 if(p[2] == nbvoxels_[2])
2303 wrapZFront = -wrap_[2];
2304 if(p[0] % 2) {
2305 switch(id) {
2306 case 0:
2307 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2308 + wrapXRight;
2309 case 1:
2310 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1] + 1
2311 + wrapXRight + wrapZFront;
2312 case 2:
2313 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2314 + vshift_[1] + wrapYBottom + wrapZFront;
2315 }
2316 } else {
2317 switch(id) {
2318 case 0:
2319 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1
2320 + wrapXRight;
2321 case 1:
2322 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2323 + wrapYBottom;
2324 case 2:
2325 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2326 + vshift_[1] + wrapYBottom + wrapZFront;
2327 }
2328 }
2329 return -1;
2330}
2331
2332inline ttk::SimplexId
2333 ttk::PeriodicImplicitTriangulation::getTriangleEdgeF_0(const SimplexId p[3],
2334 const int id) const {
2335 switch(id) {
2336 case 0:
2337 return p[0] / 2 + p[1] * eshift_[0] + p[2] * eshift_[1];
2338 case 1:
2339 return esetshift_[0] + p[0] / 2 + p[1] * eshift_[2] + p[2] * eshift_[3];
2340 case 2:
2341 return esetshift_[2] + p[0] / 2 + p[1] * eshift_[6] + p[2] * eshift_[7];
2342 }
2343 return -1;
2344}
2345
2346inline ttk::SimplexId
2347 ttk::PeriodicImplicitTriangulation::getTriangleEdgeF_1(const SimplexId p[3],
2348 const int id) const {
2349 SimplexId wrapXRight = 0;
2350 if(p[0] / 2 == nbvoxels_[0])
2351 wrapXRight = -wrap_[0];
2352 SimplexId wrapYBottom = 0;
2353 if(p[1] == nbvoxels_[1])
2354 wrapYBottom = -wrap_[1];
2355 switch(id) {
2356 case 0:
2357 return p[0] / 2 + (p[1] + 1) * eshift_[0] + p[2] * eshift_[1]
2358 + wrapYBottom;
2359 case 1:
2360 return esetshift_[0] + p[0] / 2 + p[1] * eshift_[2] + p[2] * eshift_[3]
2361 + 1 + wrapXRight;
2362 case 2:
2363 return esetshift_[2] + p[0] / 2 + p[1] * eshift_[6] + p[2] * eshift_[7];
2364 }
2365 return -1;
2366}
2367
2368inline ttk::SimplexId
2369 ttk::PeriodicImplicitTriangulation::getTriangleEdgeH_0(const SimplexId p[3],
2370 const int id) const {
2371 switch(id) {
2372 case 0:
2373 return p[0] / 2 + p[1] * eshift_[0] + p[2] * eshift_[1];
2374 case 1:
2375 return esetshift_[1] + p[0] / 2 + p[1] * eshift_[4] + p[2] * eshift_[5];
2376 case 2:
2377 return esetshift_[4] + p[0] / 2 + p[1] * eshift_[10] + p[2] * eshift_[11];
2378 }
2379 return -1;
2380}
2381
2382inline ttk::SimplexId
2383 ttk::PeriodicImplicitTriangulation::getTriangleEdgeH_1(const SimplexId p[3],
2384 const int id) const {
2385 SimplexId wrapXRight = 0;
2386 if(p[0] / 2 == nbvoxels_[0])
2387 wrapXRight = -wrap_[0];
2388 SimplexId wrapZFront = 0;
2389 if(p[2] == nbvoxels_[2])
2390 wrapZFront = -wrap_[2];
2391 switch(id) {
2392 case 0:
2393 return p[0] / 2 + p[1] * eshift_[0] + (p[2] + 1) * eshift_[1]
2394 + wrapZFront;
2395 case 1:
2396 return esetshift_[1] + p[0] / 2 + p[1] * eshift_[4] + p[2] * eshift_[5]
2397 + 1 + wrapXRight;
2398 case 2:
2399 return esetshift_[4] + p[0] / 2 + p[1] * eshift_[10] + p[2] * eshift_[11];
2400 }
2401 return -1;
2402}
2403
2404inline ttk::SimplexId
2405 ttk::PeriodicImplicitTriangulation::getTriangleEdgeC_0(const SimplexId p[3],
2406 const int id) const {
2407 SimplexId wrapYBottom = 0;
2408 if(p[1] == nbvoxels_[1])
2409 wrapYBottom = -wrap_[1];
2410 switch(id) {
2411 case 0:
2412 return esetshift_[0] + p[0] / 2 + p[1] * eshift_[2] + p[2] * eshift_[3];
2413 case 1:
2414 return esetshift_[1] + p[0] / 2 + (p[1] + 1) * eshift_[4]
2415 + p[2] * eshift_[5] + wrapYBottom;
2416 case 2:
2417 return esetshift_[3] + p[0] / 2 + p[1] * eshift_[8] + p[2] * eshift_[9];
2418 }
2419 return -1;
2420}
2421
2422inline ttk::SimplexId
2423 ttk::PeriodicImplicitTriangulation::getTriangleEdgeC_1(const SimplexId p[3],
2424 const int id) const {
2425 SimplexId wrapZFront = 0;
2426 if(p[2] == nbvoxels_[2])
2427 wrapZFront = -wrap_[2];
2428 switch(id) {
2429 case 0:
2430 return esetshift_[0] + p[0] / 2 + p[1] * eshift_[2]
2431 + (p[2] + 1) * eshift_[3] + wrapZFront;
2432 case 1:
2433 return esetshift_[1] + p[0] / 2 + p[1] * eshift_[4] + p[2] * eshift_[5];
2434 case 2:
2435 return esetshift_[3] + p[0] / 2 + p[1] * eshift_[8] + p[2] * eshift_[9];
2436 }
2437 return -1;
2438}
2439
2440inline ttk::SimplexId
2441 ttk::PeriodicImplicitTriangulation::getTriangleEdgeD1_0(const SimplexId p[3],
2442 const int id) const {
2443 SimplexId wrapXRight = 0;
2444 if(p[0] / 2 == nbvoxels_[0])
2445 wrapXRight = -wrap_[0];
2446 SimplexId wrapYBottom = 0;
2447 if(p[1] == nbvoxels_[1])
2448 wrapYBottom = -wrap_[1];
2449 switch(id) {
2450 case 0:
2451 return esetshift_[0] + p[0] / 2 + p[1] * eshift_[2] + p[2] * eshift_[3]
2452 + 1 + wrapXRight;
2453 case 1:
2454 return esetshift_[4] + p[0] / 2 + (p[1] + 1) * eshift_[10]
2455 + p[2] * eshift_[11] + wrapYBottom;
2456 case 2:
2457 return esetshift_[5] + p[0] / 2 + p[1] * eshift_[12] + p[2] * eshift_[13];
2458 }
2459 return -1;
2460}
2461
2462inline ttk::SimplexId
2463 ttk::PeriodicImplicitTriangulation::getTriangleEdgeD1_1(const SimplexId p[3],
2464 const int id) const {
2465 SimplexId wrapZFront = 0;
2466 if(p[2] == nbvoxels_[2])
2467 wrapZFront = -wrap_[2];
2468 switch(id) {
2469 case 0:
2470 return esetshift_[0] + p[0] / 2 + p[1] * eshift_[2]
2471 + (p[2] + 1) * eshift_[3] + wrapZFront;
2472 case 1:
2473 return esetshift_[4] + p[0] / 2 + p[1] * eshift_[10] + p[2] * eshift_[11];
2474 case 2:
2475 return esetshift_[5] + p[0] / 2 + p[1] * eshift_[12] + p[2] * eshift_[13];
2476 }
2477 return -1;
2478}
2479
2480inline ttk::SimplexId
2481 ttk::PeriodicImplicitTriangulation::getTriangleEdgeD2_0(const SimplexId p[3],
2482 const int id) const {
2483 switch(id) {
2484 case 0:
2485 return p[0] / 2 + p[1] * eshift_[0] + p[2] * eshift_[1];
2486 case 1:
2487 return esetshift_[3] + p[0] / 2 + p[1] * eshift_[8] + p[2] * eshift_[9];
2488 case 2:
2489 return esetshift_[5] + p[0] / 2 + p[1] * eshift_[12] + p[2] * eshift_[13];
2490 }
2491 return -1;
2492}
2493
2494inline ttk::SimplexId
2495 ttk::PeriodicImplicitTriangulation::getTriangleEdgeD2_1(const SimplexId p[3],
2496 const int id) const {
2497 SimplexId wrapXRight = 0;
2498 SimplexId wrapYBottom = 0;
2499 SimplexId wrapZFront = 0;
2500 if(p[0] / 2 == nbvoxels_[0])
2501 wrapXRight = -wrap_[0];
2502 if(p[1] == nbvoxels_[1])
2503 wrapYBottom = -wrap_[1];
2504 if(p[2] == nbvoxels_[2])
2505 wrapZFront = -wrap_[2];
2506 switch(id) {
2507 case 0:
2508 return p[0] / 2 + (p[1] + 1) * eshift_[0] + (p[2] + 1) * eshift_[1]
2509 + wrapYBottom + wrapZFront;
2510 case 1:
2511 return esetshift_[3] + p[0] / 2 + p[1] * eshift_[8] + p[2] * eshift_[9]
2512 + 1 + wrapXRight;
2513 case 2:
2514 return esetshift_[5] + p[0] / 2 + p[1] * eshift_[12] + p[2] * eshift_[13];
2515 }
2516 return -1;
2517}
2518
2519inline ttk::SimplexId
2520 ttk::PeriodicImplicitTriangulation::getTriangleEdgeD3_0(const SimplexId p[3],
2521 const int id) const {
2522 SimplexId wrapYBottom = 0;
2523 if(p[1] == nbvoxels_[1])
2524 wrapYBottom = -wrap_[1];
2525 switch(id) {
2526 case 0:
2527 return esetshift_[1] + p[0] / 2 + (p[1] + 1) * eshift_[4]
2528 + p[2] * eshift_[5] + wrapYBottom;
2529 case 1:
2530 return esetshift_[2] + p[0] / 2 + p[1] * eshift_[6] + p[2] * eshift_[7];
2531 case 2:
2532 return esetshift_[5] + p[0] / 2 + p[1] * eshift_[12] + p[2] * eshift_[13];
2533 }
2534 return -1;
2535}
2536
2537inline ttk::SimplexId
2538 ttk::PeriodicImplicitTriangulation::getTriangleEdgeD3_1(const SimplexId p[3],
2539 const int id) const {
2540 SimplexId wrapXRight = 0;
2541 SimplexId wrapZFront = 0;
2542 if(p[0] / 2 == nbvoxels_[0])
2543 wrapXRight = -wrap_[0];
2544 if(p[2] == nbvoxels_[2])
2545 wrapZFront = -wrap_[2];
2546 switch(id) {
2547 case 0:
2548 return esetshift_[1] + p[0] / 2 + p[1] * eshift_[4] + p[2] * eshift_[5]
2549 + 1 + wrapXRight;
2550 case 1:
2551 return esetshift_[2] + p[0] / 2 + p[1] * eshift_[6]
2552 + (p[2] + 1) * eshift_[7] + wrapZFront;
2553 case 2:
2554 return esetshift_[5] + p[0] / 2 + p[1] * eshift_[12] + p[2] * eshift_[13];
2555 }
2556 return -1;
2557}
2558
2559inline ttk::SimplexId
2560 ttk::PeriodicImplicitTriangulation::getTriangleLinkF(const SimplexId p[3],
2561 const int id) const {
2562 SimplexId wrapXRight = 0;
2563 SimplexId wrapYBottom = 0;
2564 SimplexId wrapZBack = 0;
2565 SimplexId wrapZFront = 0;
2566 if(p[0] / 2 == nbvoxels_[0])
2567 wrapXRight = -wrap_[0];
2568 if(p[1] == nbvoxels_[1])
2569 wrapYBottom = -wrap_[1];
2570 if(p[2] == 0)
2571 wrapZBack = wrap_[2];
2572 if(p[2] == nbvoxels_[2])
2573 wrapZFront = -wrap_[2];
2574 switch(id) {
2575 case 0:
2576 return p[0] / 2 + (p[1] + 1) * vshift_[0] + (p[2] + 1) * vshift_[1]
2577 + wrapYBottom + wrapZFront;
2578 case 1:
2579 return p[0] / 2 + p[1] * vshift_[0] + (p[2] - 1) * vshift_[1] + 1
2580 + wrapXRight + wrapZBack;
2581 }
2582 return -1;
2583}
2584
2585inline ttk::SimplexId
2586 ttk::PeriodicImplicitTriangulation::getTriangleLinkH(const SimplexId p[3],
2587 const int id) const {
2588 SimplexId wrapXRight = 0;
2589 SimplexId wrapYTop = 0;
2590 SimplexId wrapYBottom = 0;
2591 SimplexId wrapZFront = 0;
2592 if(p[0] / 2 == nbvoxels_[0])
2593 wrapXRight = -wrap_[0];
2594 if(p[1] == 0)
2595 wrapYTop = wrap_[1];
2596 if(p[1] == nbvoxels_[1])
2597 wrapYBottom = -wrap_[1];
2598 if(p[2] == nbvoxels_[2])
2599 wrapZFront = -wrap_[2];
2600 switch(id) {
2601 case 0:
2602 return p[0] / 2 + (p[1] + 1) * vshift_[0] + (p[2] + 1) * vshift_[1]
2603 + wrapYBottom + wrapZFront;
2604 case 1:
2605 return p[0] / 2 + (p[1] - 1) * vshift_[0] + p[2] * vshift_[1] + 1
2606 + wrapXRight + wrapYTop;
2607 }
2608 return -1;
2609}
2610
2611inline ttk::SimplexId
2612 ttk::PeriodicImplicitTriangulation::getTriangleLinkC(const SimplexId p[3],
2613 const int id) const {
2614 SimplexId wrapXLeft = 0;
2615 SimplexId wrapXRight = 0;
2616 SimplexId wrapYBottom = 0;
2617 SimplexId wrapZFront = 0;
2618 if(p[0] / 2 == 0)
2619 wrapXLeft = wrap_[0];
2620 if(p[0] / 2 == nbvoxels_[0])
2621 wrapXRight = -wrap_[0];
2622 if(p[1] == nbvoxels_[1])
2623 wrapYBottom = -wrap_[1];
2624 if(p[2] == nbvoxels_[2])
2625 wrapZFront = -wrap_[2];
2626 switch(id) {
2627 case 0:
2628 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1] + 1 + wrapXRight;
2629 case 1:
2630 return p[0] / 2 + (p[1] + 1) * vshift_[0] + (p[2] + 1) * vshift_[1] - 1
2631 + wrapXLeft + wrapYBottom + wrapZFront;
2632 }
2633 return -1;
2634}
2635
2636inline ttk::SimplexId
2637 ttk::PeriodicImplicitTriangulation::getTriangleLinkD1(const SimplexId p[3],
2638 const int id) const {
2639 SimplexId wrapXRight = 0;
2640 SimplexId wrapYBottom = 0;
2641 SimplexId wrapZFront = 0;
2642 if(p[0] / 2 == nbvoxels_[0])
2643 wrapXRight = -wrap_[0];
2644 if(p[1] == nbvoxels_[1])
2645 wrapYBottom = -wrap_[1];
2646 if(p[2] == nbvoxels_[2])
2647 wrapZFront = -wrap_[2];
2648 if(p[0] % 2) {
2649 switch(id) {
2650 case 0:
2651 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1];
2652 case 1:
2653 return p[0] / 2 + p[1] * vshift_[0] + (p[2] + 1) * vshift_[1] + 1
2654 + wrapXRight + wrapZFront;
2655 }
2656 } else {
2657 switch(id) {
2658 case 0:
2659 return p[0] / 2 + (p[1] + 1) * vshift_[0] + p[2] * vshift_[1]
2660 + wrapYBottom;
2661 case 1:
2662 return p[0] / 2 + (p[1] + 1) * vshift_[0] + (p[2] + 1) * vshift_[1] + 1
2663 + wrapXRight + wrapYBottom + wrapZFront;
2664 }
2665 }
2666 return -1;
2667}
2668
2669inline ttk::SimplexId
2670 ttk::PeriodicImplicitTriangulation::getTriangleLinkD2(const SimplexId p[3],
2671 const int id) const {
2672 SimplexId wrapXRight = 0;
2673 SimplexId wrapYBottom = 0;
2674 SimplexId wrapZFront = 0;
2675 if(p[0] / 2 == nbvoxels_[0])
2676 wrapXRight = -wrap_[0];
2677 if(p[1] == nbvoxels_[1])
2678 wrapYBottom = -wrap_[1];
2679 if(p[2] == nbvoxels_[2])
2680 wrapZFront = -wrap_[2];
2681 if(p[0] % 2) {
2682 switch(id) {
2683 case 0:
2684 return p[0] / 2 + (p[1] + 1) * vshift_[0] + p[2] * vshift_[1] + 1
2685 + wrapXRight + wrapYBottom;
2686 case 1:
2687 return p[0] / 2 + p[1] * vshift_[0] + (p[2] + 1) * vshift_[1] + 1
2688 + wrapXRight + wrapZFront;
2689 }
2690 } else {
2691 switch(id) {
2692 case 0:
2693 return p[0] / 2 + (p[1] + 1) * vshift_[0] + p[2] * vshift_[1]
2694 + wrapYBottom;
2695 case 1:
2696 return p[0] / 2 + p[1] * vshift_[0] + (p[2] + 1) * vshift_[1]
2697 + wrapZFront;
2698 }
2699 }
2700 return -1;
2701}
2702
2703inline ttk::SimplexId
2704 ttk::PeriodicImplicitTriangulation::getTriangleLinkD3(const SimplexId p[3],
2705 const int id) const {
2706 SimplexId wrapXRight = 0;
2707 SimplexId wrapYBottom = 0;
2708 SimplexId wrapZFront = 0;
2709 if(p[0] / 2 == nbvoxels_[0])
2710 wrapXRight = -wrap_[0];
2711 if(p[1] == nbvoxels_[1])
2712 wrapYBottom = -wrap_[1];
2713 if(p[2] == nbvoxels_[2])
2714 wrapZFront = -wrap_[2];
2715 if(p[0] % 2) {
2716 switch(id) {
2717 case 0:
2718 return p[0] / 2 + p[1] * vshift_[0] + (p[2] + 1) * vshift_[1]
2719 + wrapZFront;
2720 case 1:
2721 return p[0] / 2 + (p[1] + 1) * vshift_[0] + (p[2] + 1) * vshift_[1] + 1
2722 + wrapXRight + wrapYBottom + wrapZFront;
2723 }
2724 } else {
2725 switch(id) {
2726 case 0:
2727 return p[0] / 2 + p[1] * vshift_[0] + p[2] * vshift_[1];
2728 case 1:
2729 return p[0] / 2 + (p[1] + 1) * vshift_[0] + p[2] * vshift_[1] + 1
2730 + wrapXRight + wrapYBottom;
2731 }
2732 }
2733 return -1;
2734}
2735
2736inline ttk::SimplexId
2737 ttk::PeriodicImplicitTriangulation::getTriangleStarF(const SimplexId p[3],
2738 const int id) const {
2739 SimplexId wrapZBack = 0;
2740 if(p[2] == 0)
2741 wrapZBack = 6 * wrap_[2];
2742 if(p[0] % 2) {
2743 switch(id) {
2744 case 0:
2745 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 1;
2746 case 1:
2747 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + (p[2] - 1) * tetshift_[1]
2748 + 4 + wrapZBack;
2749 }
2750 } else {
2751 switch(id) {
2752 case 0:
2753 return p[0] * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1];
2754 case 1:
2755 return p[0] * 3 + p[1] * tetshift_[0] + (p[2] - 1) * tetshift_[1] + 3
2756 + wrapZBack;
2757 }
2758 }
2759 return -1;
2760}
2761
2762inline ttk::SimplexId
2763 ttk::PeriodicImplicitTriangulation::getTriangleStarH(const SimplexId p[3],
2764 const int id) const {
2765 SimplexId wrapYTop = 0;
2766 if(p[1] == 0)
2767 wrapYTop = 6 * wrap_[1];
2768 if(p[0] % 2) {
2769 switch(id) {
2770 case 0:
2771 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 3;
2772 case 1:
2773 return (p[0] - 1) * 3 + (p[1] - 1) * tetshift_[0] + p[2] * tetshift_[1]
2774 + 5 + wrapYTop;
2775 }
2776 } else {
2777 switch(id) {
2778 case 0:
2779 return p[0] * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 2;
2780 case 1:
2781 return p[0] * 3 + (p[1] - 1) * tetshift_[0] + p[2] * tetshift_[1] + 1
2782 + wrapYTop;
2783 }
2784 }
2785 return -1;
2786}
2787
2788inline ttk::SimplexId
2789 ttk::PeriodicImplicitTriangulation::getTriangleStarC(const SimplexId p[3],
2790 const int id) const {
2791 SimplexId wrapXLeft = 0;
2792 if(p[0] < 2)
2793 wrapXLeft = 6 * wrap_[0];
2794 if(p[0] % 2) {
2795 switch(id) {
2796 case 0:
2797 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 2;
2798 case 1:
2799 return (p[0] / 2 - 1) * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1]
2800 + 4 + wrapXLeft;
2801 }
2802 } else {
2803 switch(id) {
2804 case 0:
2805 return p[0] * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1];
2806 case 1:
2807 return (p[0] / 2 - 1) * 6 + p[1] * tetshift_[0] + p[2] * tetshift_[1]
2808 + 5 + wrapXLeft;
2809 }
2810 }
2811 return -1;
2812}
2813
2814inline ttk::SimplexId
2815 ttk::PeriodicImplicitTriangulation::getTriangleStarD1(const SimplexId p[3],
2816 const int id) const {
2817 if(p[0] % 2) {
2818 switch(id) {
2819 case 0:
2820 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 2;
2821 case 1:
2822 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 3;
2823 }
2824 } else {
2825 switch(id) {
2826 case 0:
2827 return p[0] * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 1;
2828 case 1:
2829 return p[0] * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 5;
2830 }
2831 }
2832 return -1;
2833}
2834
2835inline ttk::SimplexId
2836 ttk::PeriodicImplicitTriangulation::getTriangleStarD2(const SimplexId p[3],
2837 const int id) const {
2838 if(p[0] % 2) {
2839 switch(id) {
2840 case 0:
2841 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 5;
2842 case 1:
2843 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 4;
2844 }
2845 } else {
2846 switch(id) {
2847 case 0:
2848 return p[0] * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1];
2849 case 1:
2850 return p[0] * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 2;
2851 }
2852 }
2853 return -1;
2854}
2855
2856inline ttk::SimplexId
2857 ttk::PeriodicImplicitTriangulation::getTriangleStarD3(const SimplexId p[3],
2858 const int id) const {
2859 if(p[0] % 2) {
2860 switch(id) {
2861 case 0:
2862 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 3;
2863 case 1:
2864 return (p[0] - 1) * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 4;
2865 }
2866 } else {
2867 switch(id) {
2868 case 0:
2869 return p[0] * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1];
2870 case 1:
2871 return p[0] * 3 + p[1] * tetshift_[0] + p[2] * tetshift_[1] + 1;
2872 }
2873 }
2874 return -1;
2875}
2876
2877inline ttk::SimplexId
2878 ttk::PeriodicImplicitTriangulation::getTetrahedronVertexABCG(
2879 const SimplexId p[3], const int id) const {
2880 SimplexId wrapXRight = 0;
2881 SimplexId wrapYBottom = 0;
2882 SimplexId wrapZFront = 0;
2883 if(p[0] == nbvoxels_[0])
2884 wrapXRight = -wrap_[0];
2885 if(p[1] == nbvoxels_[1])
2886 wrapYBottom = -wrap_[1];
2887 if(p[2] == nbvoxels_[2])
2888 wrapZFront = -wrap_[2];
2889 switch(id) {
2890 case 0:
2891 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1];
2892 case 1:
2893 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + 1 + wrapXRight;
2894 case 2:
2895 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2896 + wrapYBottom;
2897 case 3:
2898 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2899 + vshift_[1] + wrapYBottom + wrapZFront;
2900 }
2901 return -1;
2902}
2903
2904inline ttk::SimplexId
2905 ttk::PeriodicImplicitTriangulation::getTetrahedronVertexBCDG(
2906 const SimplexId p[3], const int id) const {
2907 SimplexId wrapXRight = 0;
2908 SimplexId wrapYBottom = 0;
2909 SimplexId wrapZFront = 0;
2910 if(p[0] == nbvoxels_[0])
2911 wrapXRight = -wrap_[0];
2912 if(p[1] == nbvoxels_[1])
2913 wrapYBottom = -wrap_[1];
2914 if(p[2] == nbvoxels_[2])
2915 wrapZFront = -wrap_[2];
2916 switch(id) {
2917 case 0:
2918 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + 1 + wrapXRight;
2919 case 1:
2920 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2921 + wrapYBottom;
2922 case 2:
2923 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0] + 1
2924 + wrapXRight + wrapYBottom;
2925 case 3:
2926 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2927 + vshift_[1] + wrapYBottom + wrapZFront;
2928 }
2929 return -1;
2930}
2931
2932inline ttk::SimplexId
2933 ttk::PeriodicImplicitTriangulation::getTetrahedronVertexABEG(
2934 const SimplexId p[3], const int id) const {
2935 SimplexId wrapXRight = 0;
2936 SimplexId wrapYBottom = 0;
2937 SimplexId wrapZFront = 0;
2938 if(p[0] == nbvoxels_[0])
2939 wrapXRight = -wrap_[0];
2940 if(p[1] == nbvoxels_[1])
2941 wrapYBottom = -wrap_[1];
2942 if(p[2] == nbvoxels_[2])
2943 wrapZFront = -wrap_[2];
2944 switch(id) {
2945 case 0:
2946 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1];
2947 case 1:
2948 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + 1 + wrapXRight;
2949 case 2:
2950 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2951 + wrapZFront;
2952 case 3:
2953 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2954 + vshift_[1] + wrapYBottom + wrapZFront;
2955 }
2956 return -1;
2957}
2958
2959inline ttk::SimplexId
2960 ttk::PeriodicImplicitTriangulation::getTetrahedronVertexBEFG(
2961 const SimplexId p[3], const int id) const {
2962 SimplexId wrapXRight = 0;
2963 SimplexId wrapYBottom = 0;
2964 SimplexId wrapZFront = 0;
2965 if(p[0] == nbvoxels_[0])
2966 wrapXRight = -wrap_[0];
2967 if(p[1] == nbvoxels_[1])
2968 wrapYBottom = -wrap_[1];
2969 if(p[2] == nbvoxels_[2])
2970 wrapZFront = -wrap_[2];
2971 switch(id) {
2972 case 0:
2973 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + 1 + wrapXRight;
2974 case 1:
2975 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1]
2976 + wrapZFront;
2977 case 2:
2978 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1] + 1
2979 + wrapXRight + wrapZFront;
2980 case 3:
2981 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
2982 + vshift_[1] + wrapYBottom + wrapZFront;
2983 }
2984 return -1;
2985}
2986
2987inline ttk::SimplexId
2988 ttk::PeriodicImplicitTriangulation::getTetrahedronVertexBFGH(
2989 const SimplexId p[3], const int id) const {
2990 SimplexId wrapXRight = 0;
2991 SimplexId wrapYBottom = 0;
2992 SimplexId wrapZFront = 0;
2993 if(p[0] == nbvoxels_[0])
2994 wrapXRight = -wrap_[0];
2995 if(p[1] == nbvoxels_[1])
2996 wrapYBottom = -wrap_[1];
2997 if(p[2] == nbvoxels_[2])
2998 wrapZFront = -wrap_[2];
2999 switch(id) {
3000 case 0:
3001 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + 1 + wrapXRight;
3002 case 1:
3003 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[1] + 1
3004 + wrapXRight + wrapZFront;
3005 case 2:
3006 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
3007 + vshift_[1] + wrapYBottom + wrapZFront;
3008 case 3:
3009 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
3010 + vshift_[1] + 1 + wrapXRight + wrapYBottom + wrapZFront;
3011 }
3012 return -1;
3013}
3014
3015inline ttk::SimplexId
3016 ttk::PeriodicImplicitTriangulation::getTetrahedronVertexBDGH(
3017 const SimplexId p[3], const int id) const {
3018 SimplexId wrapXRight = 0;
3019 SimplexId wrapYBottom = 0;
3020 SimplexId wrapZFront = 0;
3021 if(p[0] == nbvoxels_[0])
3022 wrapXRight = -wrap_[0];
3023 if(p[1] == nbvoxels_[1])
3024 wrapYBottom = -wrap_[1];
3025 if(p[2] == nbvoxels_[2])
3026 wrapZFront = -wrap_[2];
3027 switch(id) {
3028 case 0:
3029 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + 1 + wrapXRight;
3030 case 1:
3031 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0] + 1
3032 + wrapXRight + wrapYBottom;
3033 case 2:
3034 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
3035 + vshift_[1] + wrapYBottom + wrapZFront;
3036 case 3:
3037 return p[0] + p[1] * vshift_[0] + p[2] * vshift_[1] + vshift_[0]
3038 + vshift_[1] + 1 + wrapXRight + wrapYBottom + wrapZFront;
3039 }
3040 return -1;
3041}
3042
3043inline ttk::SimplexId
3044 ttk::PeriodicImplicitTriangulation::getTetrahedronEdgeABCG(
3045 const SimplexId p[3], const int id) const {
3046 SimplexId wrapYBottom = 0;
3047 if(p[1] == nbvoxels_[1])
3048 wrapYBottom = -wrap_[1];
3049 switch(id) {
3050 case 0:
3051 return p[0] + p[1] * eshift_[0] + p[2] * eshift_[1];
3052 case 1:
3053 return esetshift_[0] + p[0] + p[1] * eshift_[2] + p[2] * eshift_[3];
3054 case 2:
3055 return esetshift_[1] + p[0] + (p[1] + 1) * eshift_[4] + p[2] * eshift_[5]
3056 + wrapYBottom;
3057 case 3:
3058 return esetshift_[2] + p[0] + p[1] * eshift_[6] + p[2] * eshift_[7];
3059 case 4:
3060 return esetshift_[3] + p[0] + p[1] * eshift_[8] + p[2] * eshift_[9];
3061 case 5:
3062 return esetshift_[5] + p[0] + p[1] * eshift_[12] + p[2] * eshift_[13];
3063 }
3064 return -1;
3065}
3066
3067inline ttk::SimplexId
3068 ttk::PeriodicImplicitTriangulation::getTetrahedronEdgeBCDG(
3069 const SimplexId p[3], const int id) const {
3070 SimplexId wrapXRight = 0;
3071 SimplexId wrapYBottom = 0;
3072 if(p[0] == nbvoxels_[0])
3073 wrapXRight = -wrap_[0];
3074 if(p[1] == nbvoxels_[1])
3075 wrapYBottom = -wrap_[1];
3076 switch(id) {
3077 case 0:
3078 return p[0] + (p[1] + 1) * eshift_[0] + p[2] * eshift_[1] + wrapYBottom;
3079 case 1:
3080 return esetshift_[0] + (p[0] + 1) + p[1] * eshift_[2] + p[2] * eshift_[3]
3081 + wrapXRight;
3082 case 2:
3083 return esetshift_[1] + p[0] + (p[1] + 1) * eshift_[4] + p[2] * eshift_[5]
3084 + wrapYBottom;
3085 case 3:
3086 return esetshift_[2] + p[0] + p[1] * eshift_[6] + p[2] * eshift_[7];
3087 case 4:
3088 return esetshift_[4] + p[0] + (p[1] + 1) * eshift_[10]
3089 + p[2] * eshift_[11] + wrapYBottom;
3090 case 5:
3091 return esetshift_[5] + p[0] + p[1] * eshift_[12] + p[2] * eshift_[13];
3092 }
3093 return -1;
3094}
3095
3096inline ttk::SimplexId
3097 ttk::PeriodicImplicitTriangulation::getTetrahedronEdgeABEG(
3098 const SimplexId p[3], const int id) const {
3099 SimplexId wrapZFront = 0;
3100 if(p[2] == nbvoxels_[2])
3101 wrapZFront = -wrap_[2];
3102 switch(id) {
3103 case 0:
3104 return p[0] + p[1] * eshift_[0] + p[2] * eshift_[1];
3105 case 1:
3106 return esetshift_[0] + p[0] + p[1] * eshift_[2] + (p[2] + 1) * eshift_[3]
3107 + wrapZFront;
3108 case 2:
3109 return esetshift_[1] + p[0] + p[1] * eshift_[4] + p[2] * eshift_[5];
3110 case 3:
3111 return esetshift_[3] + p[0] + p[1] * eshift_[8] + p[2] * eshift_[9];
3112 case 4:
3113 return esetshift_[4] + p[0] + p[1] * eshift_[10] + p[2] * eshift_[11];
3114 case 5:
3115 return esetshift_[5] + p[0] + p[1] * eshift_[12] + p[2] * eshift_[13];
3116 }
3117 return -1;
3118}
3119
3120inline ttk::SimplexId
3121 ttk::PeriodicImplicitTriangulation::getTetrahedronEdgeBEFG(
3122 const SimplexId p[3], const int id) const {
3123 SimplexId wrapXRight = 0;
3124 SimplexId wrapZFront = 0;
3125 if(p[0] == nbvoxels_[0])
3126 wrapXRight = -wrap_[0];
3127 if(p[2] == nbvoxels_[2])
3128 wrapZFront = -wrap_[2];
3129 switch(id) {
3130 case 0:
3131 return p[0] + p[1] * eshift_[0] + (p[2] + 1) * eshift_[1] + wrapZFront;
3132 case 1:
3133 return esetshift_[0] + p[0] + p[1] * eshift_[2] + (p[2] + 1) * eshift_[3]
3134 + wrapZFront;
3135 case 2:
3136 return esetshift_[1] + (p[0] + 1) + p[1] * eshift_[4] + p[2] * eshift_[5]
3137 + wrapXRight;
3138 case 3:
3139 return esetshift_[2] + p[0] + p[1] * eshift_[6] + (p[2] + 1) * eshift_[7]
3140 + wrapZFront;
3141 case 4:
3142 return esetshift_[4] + p[0] + p[1] * eshift_[10] + p[2] * eshift_[11];
3143 case 5:
3144 return esetshift_[5] + p[0] + p[1] * eshift_[12] + p[2] * eshift_[13];
3145 }
3146 return -1;
3147}
3148
3149inline ttk::SimplexId
3150 ttk::PeriodicImplicitTriangulation::getTetrahedronEdgeBFGH(
3151 const SimplexId p[3], const int id) const {
3152 SimplexId wrapXRight = 0;
3153 SimplexId wrapYBottom = 0;
3154 SimplexId wrapZFront = 0;
3155 if(p[0] == nbvoxels_[0])
3156 wrapXRight = -wrap_[0];
3157 if(p[1] == nbvoxels_[1])
3158 wrapYBottom = -wrap_[1];
3159 if(p[2] == nbvoxels_[2])
3160 wrapZFront = -wrap_[2];
3161 switch(id) {
3162 case 0:
3163 return p[0] + (p[1] + 1) * eshift_[0] + (p[2] + 1) * eshift_[1]
3164 + wrapYBottom + wrapZFront;
3165 case 1:
3166 return esetshift_[0] + (p[0] + 1) + p[1] * eshift_[2]
3167 + (p[2] + 1) * eshift_[3] + wrapXRight + wrapZFront;
3168 case 2:
3169 return esetshift_[1] + (p[0] + 1) + p[1] * eshift_[4] + p[2] * eshift_[5]
3170 + wrapXRight;
3171 case 3:
3172 return esetshift_[2] + p[0] + p[1] * eshift_[6] + (p[2] + 1) * eshift_[7]
3173 + wrapZFront;
3174 case 4:
3175 return esetshift_[3] + (p[0] + 1) + p[1] * eshift_[8] + p[2] * eshift_[9]
3176 + wrapXRight;
3177 case 5:
3178 return esetshift_[5] + p[0] + p[1] * eshift_[12] + p[2] * eshift_[13];
3179 }
3180 return -1;
3181}
3182
3183inline ttk::SimplexId
3184 ttk::PeriodicImplicitTriangulation::getTetrahedronEdgeBDGH(
3185 const SimplexId p[3], const int id) const {
3186 SimplexId wrapXRight = 0;
3187 SimplexId wrapYBottom = 0;
3188 SimplexId wrapZFront = 0;
3189 if(p[0] == nbvoxels_[0])
3190 wrapXRight = -wrap_[0];
3191 if(p[1] == nbvoxels_[1])
3192 wrapYBottom = -wrap_[1];
3193 if(p[2] == nbvoxels_[2])
3194 wrapZFront = -wrap_[2];
3195 switch(id) {
3196 case 0:
3197 return p[0] + (p[1] + 1) * eshift_[0] + (p[2] + 1) * eshift_[1]
3198 + wrapYBottom + wrapZFront;
3199 case 1:
3200 return esetshift_[0] + (p[0] + 1) + p[1] * eshift_[2] + p[2] * eshift_[3]
3201 + wrapXRight;
3202 case 2:
3203 return esetshift_[1] + (p[0] + 1) + (p[1] + 1) * eshift_[4]
3204 + p[2] * eshift_[5] + wrapXRight + wrapYBottom;
3205 case 3:
3206 return esetshift_[3] + (p[0] + 1) + p[1] * eshift_[8] + p[2] * eshift_[9]
3207 + wrapXRight;
3208 case 4:
3209 return esetshift_[4] + p[0] + (p[1] + 1) * eshift_[10]
3210 + p[2] * eshift_[11] + wrapYBottom;
3211 case 5:
3212 return esetshift_[5] + p[0] + p[1] * eshift_[12] + p[2] * eshift_[13];
3213 }
3214 return -1;
3215}
3216
3217inline ttk::SimplexId
3218 ttk::PeriodicImplicitTriangulation::getTetrahedronTriangleABCG(
3219 const SimplexId p[3], const int id) const {
3220 switch(id) {
3221 case 0:
3222 return p[0] * 2 + p[1] * tshift_[0] + p[2] * tshift_[1];
3223 case 1:
3224 return tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4] + p[2] * tshift_[5];
3225 case 2:
3226 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8] + p[2] * tshift_[9];
3227 case 3:
3228 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10] + p[2] * tshift_[11];
3229 }
3230 return -1;
3231}
3232
3233inline ttk::SimplexId
3234 ttk::PeriodicImplicitTriangulation::getTetrahedronTriangleBCDG(
3235 const SimplexId p[3], const int id) const {
3236 switch(id) {
3237 case 0:
3238 return p[0] * 2 + p[1] * tshift_[0] + p[2] * tshift_[1] + 1;
3239 case 1:
3240 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10] + p[2] * tshift_[11];
3241 case 2:
3242 return tsetshift_[2] + p[0] * 2 + p[1] * tshift_[6] + p[2] * tshift_[7];
3243 case 3:
3244 return (p[1] < nbvoxels_[1])
3245 ? tsetshift_[0] + p[0] * 2 + (p[1] + 1) * tshift_[2]
3246 + p[2] * tshift_[3]
3247 : tsetshift_[0] + p[0] * 2 + (p[1] + 1) * tshift_[2]
3248 + p[2] * tshift_[3] - wrap_[1] * 2;
3249 }
3250 return -1;
3251}
3252
3253inline ttk::SimplexId
3254 ttk::PeriodicImplicitTriangulation::getTetrahedronTriangleABEG(
3255 const SimplexId p[3], const int id) const {
3256 switch(id) {
3257 case 0:
3258 return tsetshift_[0] + p[0] * 2 + p[1] * tshift_[2] + p[2] * tshift_[3];
3259 case 1:
3260 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8] + p[2] * tshift_[9];
3261 case 2:
3262 return tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4] + p[2] * tshift_[5]
3263 + 1;
3264 case 3:
3265 return tsetshift_[2] + p[0] * 2 + p[1] * tshift_[6] + p[2] * tshift_[7]
3266 + 1;
3267 }
3268 return -1;
3269}
3270
3271inline ttk::SimplexId
3272 ttk::PeriodicImplicitTriangulation::getTetrahedronTriangleBEFG(
3273 const SimplexId p[3], const int id) const {
3274 switch(id) {
3275 case 0:
3276 return tsetshift_[2] + p[0] * 2 + p[1] * tshift_[6] + p[2] * tshift_[7]
3277 + 1;
3278 case 1:
3279 return tsetshift_[0] + p[0] * 2 + p[1] * tshift_[2] + p[2] * tshift_[3]
3280 + 1;
3281 case 2:
3282 return (p[2] < nbvoxels_[2])
3283 ? p[0] * 2 + p[1] * tshift_[0] + (p[2] + 1) * tshift_[1]
3284 : p[0] * 2 + p[1] * tshift_[0] + (p[2] + 1) * tshift_[1]
3285 - wrap_[2] * 2;
3286 case 3:
3287 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10] + p[2] * tshift_[11]
3288 + 1;
3289 }
3290 return -1;
3291}
3292
3293inline ttk::SimplexId
3294 ttk::PeriodicImplicitTriangulation::getTetrahedronTriangleBFGH(
3295 const SimplexId p[3], const int id) const {
3296 switch(id) {
3297 case 0:
3298 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8] + p[2] * tshift_[9]
3299 + 1;
3300 case 1:
3301 return tsetshift_[4] + p[0] * 2 + p[1] * tshift_[10] + p[2] * tshift_[11]
3302 + 1;
3303 case 2:
3304 return (p[0] < nbvoxels_[0])
3305 ? tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4]
3306 + p[2] * tshift_[5] + 3
3307 : tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4]
3308 + p[2] * tshift_[5] + 3 - wrap_[0] * 2;
3309 case 3:
3310 return (p[2] < nbvoxels_[2])
3311 ? p[0] * 2 + p[1] * tshift_[0] + (p[2] + 1) * tshift_[1] + 1
3312 : p[0] * 2 + p[1] * tshift_[0] + (p[2] + 1) * tshift_[1] + 1
3313 - wrap_[2] * 2;
3314 }
3315 return -1;
3316}
3317
3318inline ttk::SimplexId
3319 ttk::PeriodicImplicitTriangulation::getTetrahedronTriangleBDGH(
3320 const SimplexId p[3], const int id) const {
3321 switch(id) {
3322 case 0:
3323 return (p[0] < nbvoxels_[0])
3324 ? tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4]
3325 + p[2] * tshift_[5] + 2
3326 : tsetshift_[1] + p[0] * 2 + p[1] * tshift_[4]
3327 + p[2] * tshift_[5] + 2 - wrap_[0] * 2;
3328 case 1:
3329 return tsetshift_[2] + p[0] * 2 + p[1] * tshift_[6] + p[2] * tshift_[7];
3330 case 2:
3331 return tsetshift_[3] + p[0] * 2 + p[1] * tshift_[8] + p[2] * tshift_[9]
3332 + 1;
3333 case 3:
3334 return (p[1] < nbvoxels_[1])
3335 ? tsetshift_[0] + p[0] * 2 + (p[1] + 1) * tshift_[2]
3336 + p[2] * tshift_[3] + 1
3337 : tsetshift_[0] + p[0] * 2 + (p[1] + 1) * tshift_[2]
3338 + p[2] * tshift_[3] + 1 - wrap_[1] * 2;
3339 }
3340 return -1;
3341}
3342
3343inline ttk::SimplexId
3344 ttk::PeriodicImplicitTriangulation::getTetrahedronNeighborABCG(
3345 const SimplexId t, const SimplexId p[3], const int id) const {
3346 switch(id) {
3347 case 0:
3348 return t + 1;
3349 case 1:
3350 return t + 2;
3351 case 2:
3352 return p[0] > 0 ? t - 1 : t - 1 + wrap_[0] * 6;
3353 case 3:
3354 return p[2] > 0 ? t - tetshift_[1] + 3
3355 : t - tetshift_[1] + 3 + wrap_[2] * 6;
3356 }
3357 return -1;
3358}
3359
3360inline ttk::SimplexId
3361 ttk::PeriodicImplicitTriangulation::getTetrahedronNeighborBCDG(
3362 const SimplexId t, const SimplexId p[3], const int id) const {
3363 switch(id) {
3364 case 0:
3365 return t - 1;
3366 case 1:
3367 return t + 4;
3368 case 2:
3369 return p[2] > 0 ? t - tetshift_[1] + 3
3370 : t - tetshift_[1] + 3 + wrap_[2] * 6;
3371 case 3:
3372 return p[1] < nbvoxels_[1] ? t + tetshift_[0] + 1
3373 : t + tetshift_[0] + 1 - wrap_[1] * 6;
3374 }
3375 return -1;
3376}
3377
3378inline ttk::SimplexId
3379 ttk::PeriodicImplicitTriangulation::getTetrahedronNeighborABEG(
3380 const SimplexId t, const SimplexId p[3], const int id) const {
3381 switch(id) {
3382 case 0:
3383 return t - 2;
3384 case 1:
3385 return t + 1;
3386 case 2:
3387 return p[0] > 0 ? t - 4 : t - 4 + wrap_[0] * 6;
3388 case 3:
3389 return p[1] > 0 ? t - tetshift_[0] - 1
3390 : t - tetshift_[0] - 1 + wrap_[1] * 6;
3391 }
3392 return -1;
3393}
3394
3395inline ttk::SimplexId
3396 ttk::PeriodicImplicitTriangulation::getTetrahedronNeighborBEFG(
3397 const SimplexId t, const SimplexId p[3], const int id) const {
3398 switch(id) {
3399 case 0:
3400 return t - 1;
3401 case 1:
3402 return t + 1;
3403 case 2:
3404 return p[1] > 0 ? t - tetshift_[0] + 2
3405 : t - tetshift_[0] + 2 + wrap_[1] * 6;
3406 case 3:
3407 return p[2] < nbvoxels_[2] ? t + tetshift_[1] - 3
3408 : t + tetshift_[1] - 3 - wrap_[2] * 6;
3409 }
3410 return -1;
3411}
3412
3413inline ttk::SimplexId
3414 ttk::PeriodicImplicitTriangulation::getTetrahedronNeighborBFGH(
3415 const SimplexId t, const SimplexId p[3], const int id) const {
3416 switch(id) {
3417 case 0:
3418 return t - 1;
3419 case 1:
3420 return t + 1;
3421 case 2:
3422 return p[0] < nbvoxels_[0] ? t + 4 : t + 4 - wrap_[0] * 6;
3423 case 3:
3424 return p[2] < nbvoxels_[2] ? t + tetshift_[1] - 3
3425 : t + tetshift_[1] - 3 - wrap_[2] * 6;
3426 }
3427 return -1;
3428}
3429
3430inline ttk::SimplexId
3431 ttk::PeriodicImplicitTriangulation::getTetrahedronNeighborBDGH(
3432 const SimplexId t, const SimplexId p[3], const int id) const {
3433 switch(id) {
3434 case 0:
3435 return t - 1;
3436 case 1:
3437 return t - 4;
3438 case 2:
3439 return p[0] < nbvoxels_[0] ? t + 1 : t + 1 - wrap_[0] * 6;
3440 case 3:
3441 return p[1] < nbvoxels_[1] ? t + tetshift_[0] - 2
3442 : t + tetshift_[0] - 2 - wrap_[1] * 6;
3443 }
3444 return -1;
3445}
3446
3447#include <PeriodicPreconditions.h>
3448
#define TTK_TRIANGULATION_INTERNAL(NAME)
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
Definition BaseClass.h:47
virtual int getVertexPointInternal(const SimplexId &ttkNotUsed(vertexId), float &ttkNotUsed(x), float &ttkNotUsed(y), float &ttkNotUsed(z)) const
virtual int getCellVertexInternal(const SimplexId &ttkNotUsed(cellId), const int &ttkNotUsed(localVertexId), SimplexId &ttkNotUsed(vertexId)) const
virtual int getEdgeIncenter(SimplexId edgeId, float incenter[3]) const
SimplexId TTK_TRIANGULATION_INTERNAL() getEdgeStarNumber(const SimplexId &edgeId) const override
int TTK_TRIANGULATION_INTERNAL() getVertexStar(const SimplexId &vertexId, const int &localStarId, SimplexId &starId) const override
int getTetrahedronVertex(const SimplexId &tetId, const int &localVertexId, SimplexId &vertexId) const override
int getTetrahedronTriangle(const SimplexId &tetId, const int &id, SimplexId &triangleId) const override
int getTriangleVertexInternal(const SimplexId &triangleId, const int &localVertexId, SimplexId &vertexId) const override
int getEdgeVertexInternal(const SimplexId &edgeId, const int &localVertexId, SimplexId &vertexId) const override
virtual int getTetraIncenter(SimplexId tetraId, float incenter[3]) const
int TTK_TRIANGULATION_INTERNAL() getEdgeStar(const SimplexId &edgeId, const int &localStarId, SimplexId &starId) const override
int TTK_TRIANGULATION_INTERNAL() getVertexLink(const SimplexId &vertexId, const int &localLinkId, SimplexId &linkId) const override
int TTK_TRIANGULATION_INTERNAL() getVertexNeighbor(const SimplexId &vertexId, const int &localNeighborId, SimplexId &neighborId) const override
virtual int getTriangleIncenter(SimplexId triangleId, float incenter[3]) const
int getVertexTriangleInternal(const SimplexId &vertexId, const int &id, SimplexId &triangleId) const override
int getTriangleEdgeInternal(const SimplexId &triangleId, const int &id, SimplexId &edgeId) const override
int getTetrahedronNeighbor(const SimplexId &tetId, const int &localNeighborId, SimplexId &neighborId) const override
int getVertexEdgeInternal(const SimplexId &vertexId, const int &id, SimplexId &edgeId) const override
int TTK_TRIANGULATION_INTERNAL() getTriangleLink(const SimplexId &triangleId, const int &localLinkId, SimplexId &linkId) const override
SimplexId TTK_TRIANGULATION_INTERNAL() getTriangleStarNumber(const SimplexId &triangleId) const override
int TTK_TRIANGULATION_INTERNAL() getTriangleStar(const SimplexId &triangleId, const int &localStarId, SimplexId &starId) const override
int TTK_TRIANGULATION_INTERNAL() getVertexPoint(const SimplexId &vertexId, float &x, float &y, float &z) const override
SimplexId getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override
int getEdgeTriangleInternal(const SimplexId &edgeId, const int &id, SimplexId &triangleId) const override
int TTK_TRIANGULATION_INTERNAL() getEdgeLink(const SimplexId &edgeId, const int &localLinkId, SimplexId &linkId) const override
int getTetrahedronEdge(const SimplexId &tetId, const int &id, SimplexId &edgeId) const override
int getTriangleNeighbor(const SimplexId &triangleId, const int &localNeighborId, SimplexId &neighborId) const override
TTK triangulation class for grids with periodic boundary conditions implemented in all directions.
virtual int preconditionTetrahedronsInternal()=0
SimplexId TTK_TRIANGULATION_INTERNAL() getTriangleLinkNumber(const SimplexId &triangleId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getEdgeLinks() override
int getTriangleNeighbors(std::vector< std::vector< SimplexId > > &neighbors)
virtual int getTetrahedronNeighbor(const SimplexId &tetId, const int &localNeighborId, SimplexId &neighborId) const =0
int TTK_TRIANGULATION_INTERNAL() getCellVertex(const SimplexId &cellId, const int &localVertexId, SimplexId &vertexId) const override
int getCellTriangleInternal(const SimplexId &cellId, const int &id, SimplexId &triangleId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getTriangleLinks() override
int setInputGrid(const float &xOrigin, const float &yOrigin, const float &zOrigin, const float &xSpacing, const float &ySpacing, const float &zSpacing, const SimplexId &xDim, const SimplexId &yDim, const SimplexId &zDim) override
const std::vector< std::vector< SimplexId > > * getTriangleEdgesInternal() override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getTriangleStars() override
SimplexId TTK_TRIANGULATION_INTERNAL() getEdgeLinkNumber(const SimplexId &edgeId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getVertexLinks() override
int getTetrahedronNeighbors(std::vector< std::vector< SimplexId > > &neighbors)
SimplexId getVertexEdgeNumberInternal(const SimplexId &vertexId) const override
SimplexId getCellEdgeNumberInternal(const SimplexId &cellId) const override
const std::vector< std::array< SimplexId, 2 > > *TTK_TRIANGULATION_INTERNAL() getEdges() override
bool TTK_TRIANGULATION_INTERNAL() isTriangleOnBoundary(const SimplexId &triangleId) const override
int TTK_TRIANGULATION_INTERNAL() getDimensionality() const override
int getTetrahedronEdges(std::vector< std::vector< SimplexId > > &edges) const
bool TTK_TRIANGULATION_INTERNAL() isEdgeOnBoundary(const SimplexId &edgeId) const override
SimplexId getTriangleNeighborNumber(const SimplexId &triangleId) const
const std::array< ttk::SimplexId, 3 > & getGridDimensions() const override
virtual int getTetrahedronVertex(const SimplexId &tetId, const int &localVertexId, SimplexId &vertexId) const =0
const std::vector< std::vector< SimplexId > > * getEdgeTrianglesInternal() override
SimplexId TTK_TRIANGULATION_INTERNAL() getNumberOfVertices() const override
int preconditionTrianglesInternal() override=0
SimplexId TTK_TRIANGULATION_INTERNAL() getCellVertexNumber(const SimplexId &cellId) const override
int preconditionEdgesInternal() override=0
virtual int getTriangleNeighbor(const SimplexId &triangleId, const int &localNeighborId, SimplexId &neighborId) const =0
SimplexId TTK_TRIANGULATION_INTERNAL() getVertexStarNumber(const SimplexId &vertexId) const override
SimplexId TTK_TRIANGULATION_INTERNAL() getCellNeighborNumber(const SimplexId &cellId) const override
bool isPowerOfTwo(unsigned long long int v, unsigned long long int &r)
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getVertexStars() override
PeriodicImplicitTriangulation(const PeriodicImplicitTriangulation &)=default
virtual int getTetrahedronEdge(const SimplexId &tetId, const int &id, SimplexId &edgeId) const =0
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getEdgeStars() override
virtual int getTetrahedronTriangle(const SimplexId &tetId, const int &id, SimplexId &triangleId) const =0
PeriodicImplicitTriangulation & operator=(const PeriodicImplicitTriangulation &)=default
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getCellNeighbors() override
const std::vector< std::vector< SimplexId > > * getVertexEdgesInternal() override
SimplexId getTriangleEdgeNumberInternal(const SimplexId &ttkNotUsed(triangleId)) const override
PeriodicImplicitTriangulation & operator=(PeriodicImplicitTriangulation &&)=default
SimplexId getCellTriangleNumberInternal(const SimplexId &ttkNotUsed(cellId)) const override
const std::vector< std::array< SimplexId, 3 > > *TTK_TRIANGULATION_INTERNAL() getTriangles() override
SimplexId getVertexTriangleNumberInternal(const SimplexId &vertexId) const override
SimplexId TTK_TRIANGULATION_INTERNAL() getVertexLinkNumber(const SimplexId &vertexId) const override
int getTetrahedronTriangles(std::vector< std::vector< SimplexId > > &triangles) const
const std::vector< std::vector< SimplexId > > * getCellEdgesInternal() override
virtual int preconditionVerticesInternal()=0
int getCellEdgeInternal(const SimplexId &cellId, const int &id, SimplexId &edgeId) const override
SimplexId getNumberOfTrianglesInternal() const override
bool TTK_TRIANGULATION_INTERNAL() isVertexOnBoundary(const SimplexId &vertexId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getVertexNeighbors() override
SimplexId getTetrahedronNeighborNumber(const SimplexId &tetId) const
SimplexId TTK_TRIANGULATION_INTERNAL() getNumberOfCells() const override
SimplexId TTK_TRIANGULATION_INTERNAL() getVertexNeighborNumber(const SimplexId &vertexId) const override
int TTK_TRIANGULATION_INTERNAL() getCellNeighbor(const SimplexId &cellId, const int &localNeighborId, SimplexId &neighborId) const override
PeriodicImplicitTriangulation(PeriodicImplicitTriangulation &&)=default
const std::vector< std::vector< SimplexId > > * getCellTrianglesInternal() override
const std::vector< std::vector< SimplexId > > * getVertexTrianglesInternal() override
int getCellVTKIDInternal(const int &ttkId, int &vtkId) const override
RegularGridTriangulation is an abstract subclass of ttk::AbstractTriangulation that exposes a common ...
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
std::array< SimplexId, 3 > dimensions_
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
T distance(const T *p0, const T *p1, const int &dimension=3)
Definition Geometry.cpp:362
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22