58 std::array<double, 3>
p_{};
60 std::pair<double, double>
uv_{};
70#ifdef TTK_ENABLE_FIBER_SURFACE_WITH_RANGE_OCTREE
71 template <
class dataTypeU,
class dataTypeV,
typename triangulationType>
72 inline int buildOctree(
const triangulationType *
const triangulation);
75 template <
class dataTypeU,
class dataTypeV,
typename triangulationType>
76 inline int computeContour(
const std::pair<double, double> &rangePoint0,
77 const std::pair<double, double> &rangePoint1,
78 const std::vector<SimplexId> &seedTetList,
79 const triangulationType *
const triangulation,
80 const SimplexId &polygonEdgeId = 0)
const;
82 template <
class dataTypeU,
class dataTypeV>
84 const std::vector<std::pair<std::pair<double, double>,
85 std::pair<double, double>>> &edgeList,
86 const std::vector<SimplexId> &seedTetList,
87 const std::vector<SimplexId> *edgeIdList =
nullptr)
const;
89 template <
class dataTypeU,
class dataTypeV,
typename triangulationType>
90 inline int computeSurface(
const std::pair<double, double> &rangePoint0,
91 const std::pair<double, double> &rangePoint1,
92 const triangulationType *
const triangulation,
93 const SimplexId &polygonEdgeId = 0)
const;
95 template <
class dataTypeU,
class dataTypeV,
typename triangulationType>
96 inline int computeSurface(
const triangulationType *
const triangulation);
98#ifdef TTK_ENABLE_FIBER_SURFACE_WITH_RANGE_OCTREE
99 template <
class dataTypeU,
class dataTypeV,
typename triangulationType>
101 computeSurfaceWithOctree(
const std::pair<double, double> &rangePoint0,
102 const std::pair<double, double> &rangePoint1,
103 const triangulationType *
const triangulation,
107 template <
class dataTypeU,
class dataTypeV>
108 inline int finalize(
const bool &mergeDuplicatedVertices =
false,
109 const bool &removeSmallEdges =
false,
110 const bool &edgeFlips =
false,
111 const bool &intersectionRemesh =
false);
113#ifdef TTK_ENABLE_FIBER_SURFACE_WITH_RANGE_OCTREE
114 inline void flushOctree() {
119 template <
class dataTypeU,
class dataTypeV,
typename triangulationType>
121 const std::pair<double, double> &rangePoint0,
122 const std::pair<double, double> &rangePoint1,
123 const triangulationType *
const triangulation,
124 const SimplexId &polygonEdgeId = 0)
const;
160 const std::vector<std::pair<std::pair<double, double>,
161 std::pair<double, double>>> *polygon) {
190 std::vector<Triangle> *triangleList) {
192#ifndef TTK_ENABLE_KAMIKAZE
193 if((polygonEdgeId >= 0)
204 if(triangulation !=
nullptr) {
210 std::vector<Vertex> *vertexList) {
212#ifndef TTK_ENABLE_KAMIKAZE
213 if((polygonEdgeId >= 0)
229 std::array<std::pair<double, double>, 3>
uv_{};
230 std::array<double, 3>
t_{};
231 std::array<std::array<double, 3>, 3>
p_{};
235 template <
class dataTypeU,
class dataTypeV,
typename triangulationType>
250 std::array<std::array<double, 3>, 3> &basePoints,
251 std::array<std::pair<double, double>, 3> &basePointProjections,
252 std::array<double, 3> &basePointParameterization,
253 std::array<std::pair<SimplexId, SimplexId>, 3> &baseEdges,
254 const triangulationType *
const triangulation)
const;
256 template <
class dataTypeU,
class dataTYpeV,
typename triangulationType>
271 const triangulationType *
const triangulation)
const;
273 template <
class dataTypeU,
class dataTYpeV,
typename triangulationType>
288 const triangulationType *
const triangulation)
const;
290 template <
class dataTypeU,
class dataTYpeV,
typename triangulationType>
305 const triangulationType *
const triangulation)
const;
307 template <
class dataTypeU,
class dataTYpeV,
typename triangulationType>
322 const triangulationType *
const triangulation)
const;
324 template <
class dataTypeU,
class dataTYpeV,
typename triangulationType>
339 const triangulationType *
const triangulation)
const;
344 const std::pair<double, double> &intersection,
345 const std::vector<std::vector<IntersectionTriangle>> &tetIntersections,
346 std::array<double, 3> &pA,
347 std::array<double, 3> &pB,
349 bool &edgeFiber)
const;
357 const std::pair<double, double> &intersection,
360 std::vector<std::vector<IntersectionTriangle>> &tetIntersections,
361 std::vector<std::vector<Vertex>> &tetNewVertices)
const;
367 const std::pair<double, double> &intersection,
368 const std::array<double, 3> &pA,
369 const std::array<double, 3> &pB,
373 std::vector<std::vector<IntersectionTriangle>> &tetIntersections,
374 std::vector<std::vector<Vertex>> &tetNewVertices)
const;
382 const std::vector<std::vector<Vertex>> &tetNewVertices,
384 std::vector<std::vector<IntersectionTriangle>> &tetIntersections,
385 const std::pair<double, double> *intersection =
nullptr)
const;
390 flipEdges(std::vector<std::pair<SimplexId, SimplexId>> &triangles)
const;
396 const std::vector<std::vector<IntersectionTriangle>> &tetIntersections)
402 const std::vector<std::vector<IntersectionTriangle>> &tetIntersections,
403 std::pair<double, double> &extremity0,
404 std::pair<double, double> &extremity1)
const;
408 const double *p2)
const;
411 const std::pair<double, double> &uv0,
413 const std::array<double, 3> &p1,
414 const std::pair<double, double> &uv1,
423 const std::vector<std::pair<SimplexId, SimplexId>> &starNeighbors)
const;
433 const std::vector<std::vector<IntersectionTriangle>> &tetIntersections,
434 const std::vector<std::vector<Vertex>> &tetNewVertices,
439 std::array<std::array<double, 3>, 3> points{};
440 for(
int i = 0; i < 3; i++) {
443 vertexId = vertexId1;
445 vertexId = vertexId2;
448 for(
int j = 0; j < 3; j++) {
449 points[i][j] = tetIntersections[tetId][triangleId].p_[vertexId][j];
452 for(
int j = 0; j < 3; j++) {
453 points[i][j] = tetNewVertices[tetId][(-vertexId) - 1].p_[j];
459 points[0].data(), points[1].data(), points[2].data());
462 int mergeEdges(
const double &distanceThreshold)
const;
466 template <
class dataTypeU,
class dataTypeV>
469 int snapToBasePoint(
const std::vector<std::vector<double>> &basePoints,
470 const std::vector<std::pair<double, double>> &uv,
471 const std::vector<double> &t,
478 const std::vector<std::pair<SimplexId, SimplexId>> &triangles)
const;
488 0, 1, 0, 2, 0, 3, 3, 1, 2, 1, 2, 3};
493 const std::vector<std::pair<std::pair<double, double>,
500#ifdef TTK_ENABLE_FIBER_SURFACE_WITH_RANGE_OCTREE
550 std::array<std::array<double, 3>, 3> &basePoints,
551 std::array<std::pair<double, double>, 3> &basePointProjections,
552 std::array<double, 3> &basePointParameterization,
553 std::array<std::pair<SimplexId, SimplexId>, 3> &baseEdges,
554 const triangulationType *
const triangulation)
const {
556 for(
int i = 0; i < 3; i++) {
565 = tetList_[5 * tetId + 1 + edgeImplicitEncoding_[2 * localEdgeId0]];
566 vertexId1 = tetList_[5 * tetId + 1
567 + edgeImplicitEncoding_[2 * localEdgeId0 + 1]];
569 triangulation->getCellVertex(
570 tetId, edgeImplicitEncoding_[2 * localEdgeId0], vertexId0);
571 triangulation->getCellVertex(
572 tetId, edgeImplicitEncoding_[2 * localEdgeId0 + 1], vertexId1);
574 basePointProjections[i].first = u0;
575 basePointProjections[i].second = v0;
576 basePointParameterization[i] = t0;
582 = tetList_[5 * tetId + 1 + edgeImplicitEncoding_[2 * localEdgeId1]];
583 vertexId1 = tetList_[5 * tetId + 1
584 + edgeImplicitEncoding_[2 * localEdgeId1 + 1]];
586 triangulation->getCellVertex(
587 tetId, edgeImplicitEncoding_[2 * localEdgeId1], vertexId0);
588 triangulation->getCellVertex(
589 tetId, edgeImplicitEncoding_[2 * localEdgeId1 + 1], vertexId1);
591 basePointProjections[i].first = u1;
592 basePointProjections[i].second = v1;
593 basePointParameterization[i] = t1;
599 = tetList_[5 * tetId + 1 + edgeImplicitEncoding_[2 * localEdgeId2]];
600 vertexId1 = tetList_[5 * tetId + 1
601 + edgeImplicitEncoding_[2 * localEdgeId2 + 1]];
603 triangulation->getCellVertex(
604 tetId, edgeImplicitEncoding_[2 * localEdgeId2], vertexId0);
605 triangulation->getCellVertex(
606 tetId, edgeImplicitEncoding_[2 * localEdgeId2 + 1], vertexId1);
608 basePointProjections[i].first = u2;
609 basePointProjections[i].second = v2;
610 basePointParameterization[i] = t2;
614 std::array<double, 2> baryCentrics{};
615 std::array<double, 2> p0{}, p1{}, p{};
616 p0[0] = ((
const dataTypeU *)uField_)[vertexId0];
617 p0[1] = ((
const dataTypeV *)vField_)[vertexId0];
618 p1[0] = ((
const dataTypeU *)uField_)[vertexId1];
619 p1[1] = ((
const dataTypeV *)vField_)[vertexId1];
620 p[0] = basePointProjections[i].first;
621 p[1] = basePointProjections[i].second;
623 p0.data(), p1.data(), p.data(), baryCentrics, 2);
625 std::array<float, 3> pA{}, pB{};
627 triangulation->getVertexPoint(vertexId0, pA[0], pA[1], pA[2]);
628 triangulation->getVertexPoint(vertexId1, pB[0], pB[1], pB[2]);
631 for(
int j = 0; j < 3; j++) {
635 c0 = pointSet_[3 * vertexId0 + j];
636 c1 = pointSet_[3 * vertexId1 + j];
642 basePoints[i][j] = baryCentrics[0] * c0 + baryCentrics[1] * c1;
645 if(vertexId0 < vertexId1) {
646 baseEdges[i] = std::pair<SimplexId, SimplexId>(vertexId0, vertexId1);
648 baseEdges[i] = std::pair<SimplexId, SimplexId>(vertexId1, vertexId0);
671 const triangulationType *
const triangulation)
const {
674 SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size();
677 (*polygonEdgeTriangleLists_[polygonEdgeId])
678 .resize((*polygonEdgeTriangleLists_[polygonEdgeId]).size() + 1);
679 (*polygonEdgeTriangleLists_[polygonEdgeId]).back().tetId_ = tetId;
680 (*polygonEdgeTriangleLists_[polygonEdgeId]).back().caseId_ = 0;
681 (*polygonEdgeTriangleLists_[polygonEdgeId]).back().polygonEdgeId_
684 (*polygonEdgeTriangleLists_[polygonEdgeId]).back().vertexIds_[0] = vertexId;
685 (*polygonEdgeTriangleLists_[polygonEdgeId]).back().vertexIds_[1]
687 (*polygonEdgeTriangleLists_[polygonEdgeId]).back().vertexIds_[2]
691 (*polygonEdgeVertexLists_[polygonEdgeId]).resize(vertexId + 3);
692 for(
int i = 0; i < 3; i++) {
693 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isBasePoint_ =
true;
694 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isIntersectionPoint_
699 for(
int i = 0; i < 3; i++) {
707 = tetList_[5 * tetId + 1 + edgeImplicitEncoding_[2 * localEdgeId0]];
708 vertexId1 = tetList_[5 * tetId + 1
709 + edgeImplicitEncoding_[2 * localEdgeId0 + 1]];
711 triangulation->getCellVertex(
712 tetId, edgeImplicitEncoding_[2 * localEdgeId0], vertexId0);
713 triangulation->getCellVertex(
714 tetId, edgeImplicitEncoding_[2 * localEdgeId0 + 1], vertexId1);
716 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_.first = u0;
717 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_.second = v0;
718 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].t_ = t0;
724 = tetList_[5 * tetId + 1 + edgeImplicitEncoding_[2 * localEdgeId1]];
725 vertexId1 = tetList_[5 * tetId + 1
726 + edgeImplicitEncoding_[2 * localEdgeId1 + 1]];
728 triangulation->getCellVertex(
729 tetId, edgeImplicitEncoding_[2 * localEdgeId1], vertexId0);
730 triangulation->getCellVertex(
731 tetId, edgeImplicitEncoding_[2 * localEdgeId1 + 1], vertexId1);
733 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_.first = u1;
734 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_.second = v1;
735 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].t_ = t1;
741 = tetList_[5 * tetId + 1 + edgeImplicitEncoding_[2 * localEdgeId2]];
742 vertexId1 = tetList_[5 * tetId + 1
743 + edgeImplicitEncoding_[2 * localEdgeId2 + 1]];
745 triangulation->getCellVertex(
746 tetId, edgeImplicitEncoding_[2 * localEdgeId2], vertexId0);
747 triangulation->getCellVertex(
748 tetId, edgeImplicitEncoding_[2 * localEdgeId2 + 1], vertexId1);
750 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_.first = u2;
751 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_.second = v2;
752 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].t_ = t2;
756 std::array<double, 2> baryCentrics{};
757 std::array<double, 2> p0{}, p1{}, p{};
758 p0[0] = ((
const dataTypeU *)uField_)[vertexId0];
759 p0[1] = ((
const dataTypeV *)vField_)[vertexId0];
760 p1[0] = ((
const dataTypeU *)uField_)[vertexId1];
761 p1[1] = ((
const dataTypeV *)vField_)[vertexId1];
762 p[0] = (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_.first;
763 p[1] = (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_.second;
765 p0.data(), p1.data(), p.data(), baryCentrics, 2);
769 triangulation->getVertexPoint(vertexId0, pA[0], pA[1], pA[2]);
770 triangulation->getVertexPoint(vertexId1, pB[0], pB[1], pB[2]);
773 for(
int j = 0; j < 3; j++) {
777 c0 = pointSet_[3 * vertexId0 + j];
778 c1 = pointSet_[3 * vertexId1 + j];
784 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].p_[j]
785 = baryCentrics[0] * c0 + baryCentrics[1] * c1;
788 if(vertexId0 < vertexId1)
789 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].meshEdge_
790 = std::pair<SimplexId, SimplexId>(vertexId0, vertexId1);
792 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].meshEdge_
793 = std::pair<SimplexId, SimplexId>(vertexId1, vertexId0);
816 const triangulationType *
const triangulation)
const {
818 SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size();
821 (*polygonEdgeVertexLists_[polygonEdgeId]).resize(vertexId + 5);
822 for(
int i = 0; i < 5; i++) {
823 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isBasePoint_ =
true;
824 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isIntersectionPoint_
826 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].meshEdge_
827 = std::pair<SimplexId, SimplexId>(-1, -1);
832 = (*polygonEdgeTriangleLists_[polygonEdgeId]).size();
833 (*polygonEdgeTriangleLists_[polygonEdgeId]).resize(triangleId + 3);
835 for(
int i = 0; i < 3; i++) {
837 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].tetId_ = tetId;
838 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].caseId_ = 1;
839 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].polygonEdgeId_
844 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i]
847 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i]
850 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i]
855 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i]
858 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i]
861 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i]
866 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i]
869 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i]
872 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i]
880 std::array<std::array<double, 3>, 3> basePoints{};
881 std::array<std::pair<double, double>, 3> basePointProjections{};
882 std::array<double, 3> basePointParameterization{};
883 std::array<std::pair<SimplexId, SimplexId>, 3> baseEdges{};
885 computeBaseTriangle<dataTypeU, dataTypeV>(
886 tetId, localEdgeId0, t0, u0, v0, localEdgeId1, t1, u1, v1, localEdgeId2, t2,
887 u2, v2, basePoints, basePointProjections, basePointParameterization,
888 baseEdges, triangulation);
893 if((t0 >= 0) && (t0 <= 1)) {
896 if((t1 >= 0) && (t1 <= 1)) {
899 if((t2 >= 0) && (t2 <= 1)) {
904 for(
int i = 0; i < 5; i++) {
906 SimplexId vertexId0 = -1, vertexId1 = -1;
911 for(
int j = 0; j < 3; j++) {
912 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId].p_[j]
913 = basePoints[pivotVertexId][j];
916 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId].t_
917 = basePointParameterization[pivotVertexId];
918 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId].uv_
919 = basePointProjections[pivotVertexId];
920 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId].meshEdge_
921 = baseEdges[pivotVertexId];
930 vertexId0 = pivotVertexId;
931 vertexId1 = (pivotVertexId + 2) % 3;
932 if(basePointParameterization[(pivotVertexId + 2) % 3] > 1) {
943 vertexId0 = pivotVertexId;
944 vertexId1 = (pivotVertexId + 1) % 3;
945 if(basePointParameterization[(pivotVertexId + 1) % 3] > 1) {
953 vertexId0 = (pivotVertexId + 2) % 3;
954 vertexId1 = (pivotVertexId + 1) % 3;
955 if(basePointParameterization[(pivotVertexId + 2) % 3] < 0) {
963 vertexId0 = (pivotVertexId + 2) % 3;
964 vertexId1 = (pivotVertexId + 1) % 3;
965 if(basePointParameterization[(pivotVertexId + 2) % 3] < 0) {
973 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].t_ = t;
975 interpolateBasePoints(
976 basePoints[vertexId0], basePointProjections[vertexId0],
977 basePointParameterization[vertexId0], basePoints[vertexId1],
978 basePointProjections[vertexId1], basePointParameterization[vertexId1],
979 t, (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i]);
1006 const triangulationType *
const triangulation)
const {
1008 SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size();
1011 (*polygonEdgeVertexLists_[polygonEdgeId]).resize(vertexId + 4);
1012 for(
int i = 0; i < 4; i++) {
1013 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isBasePoint_ =
true;
1014 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isIntersectionPoint_
1016 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].meshEdge_
1017 = std::pair<SimplexId, SimplexId>(-1, -1);
1022 = (*polygonEdgeTriangleLists_[polygonEdgeId]).size();
1023 (*polygonEdgeTriangleLists_[polygonEdgeId]).resize(triangleId + 2);
1025 for(
int i = 0; i < 2; i++) {
1027 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].tetId_ = tetId;
1028 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].caseId_ = 2;
1029 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].polygonEdgeId_
1033 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[0]
1035 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[1]
1037 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[2]
1040 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[0]
1042 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[1]
1044 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[2]
1050 std::array<std::array<double, 3>, 3> basePoints{};
1051 std::array<std::pair<double, double>, 3> basePointProjections{};
1052 std::array<double, 3> basePointParameterization{};
1053 std::array<std::pair<SimplexId, SimplexId>, 3> baseEdges{};
1055 computeBaseTriangle<dataTypeU, dataTypeV>(
1056 tetId, localEdgeId0, t0, u0, v0, localEdgeId1, t1, u1, v1, localEdgeId2, t2,
1057 u2, v2, basePoints, basePointProjections, basePointParameterization,
1058 baseEdges, triangulation);
1061 bool isPivotPositive =
false;
1064 if(((t0 < 0) && ((t1 < 0) || (t2 < 0)))
1065 || ((t1 < 0) && ((t0 < 0) || (t2 < 0)))
1066 || ((t2 < 0) && ((t1 < 0) || (t0 < 0)))) {
1067 isPivotPositive =
true;
1069 if(isPivotPositive) {
1076 if(isPivotPositive) {
1083 if(isPivotPositive) {
1092 for(
int i = 0; i < 4; i++) {
1094 SimplexId vertexId0 = -1, vertexId1 = -1;
1103 vertexId0 = pivotVertexId;
1104 vertexId1 = (pivotVertexId + 2) % 3;
1115 vertexId0 = pivotVertexId;
1116 vertexId1 = (pivotVertexId + 1) % 3;
1127 vertexId0 = pivotVertexId;
1128 vertexId1 = (pivotVertexId + 2) % 3;
1139 vertexId0 = pivotVertexId;
1140 vertexId1 = (pivotVertexId + 1) % 3;
1148 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].t_ = t;
1150 interpolateBasePoints(
1151 basePoints[vertexId0], basePointProjections[vertexId0],
1152 basePointParameterization[vertexId0], basePoints[vertexId1],
1153 basePointProjections[vertexId1], basePointParameterization[vertexId1], t,
1154 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i]);
1180 const triangulationType *
const triangulation)
const {
1182 SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size();
1185 (*polygonEdgeVertexLists_[polygonEdgeId]).resize(vertexId + 3);
1186 for(
int i = 0; i < 3; i++) {
1187 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isBasePoint_ =
true;
1188 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isIntersectionPoint_
1190 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].meshEdge_
1191 = std::pair<SimplexId, SimplexId>(-1, -1);
1196 = (*polygonEdgeTriangleLists_[polygonEdgeId]).size();
1197 (*polygonEdgeTriangleLists_[polygonEdgeId]).resize(triangleId + 1);
1199 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId].tetId_ = tetId;
1200 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId].caseId_ = 3;
1201 (*polygonEdgeTriangleLists_[polygonEdgeId]).back().polygonEdgeId_
1204 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId].vertexIds_[0]
1206 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId].vertexIds_[1]
1208 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId].vertexIds_[2]
1212 std::array<std::array<double, 3>, 3> basePoints{};
1213 std::array<std::pair<double, double>, 3> basePointProjections{};
1214 std::array<double, 3> basePointParameterization{};
1215 std::array<std::pair<SimplexId, SimplexId>, 3> baseEdges{};
1217 computeBaseTriangle<dataTypeU, dataTypeV>(
1218 tetId, localEdgeId0, t0, u0, v0, localEdgeId1, t1, u1, v1, localEdgeId2, t2,
1219 u2, v2, basePoints, basePointProjections, basePointParameterization,
1220 baseEdges, triangulation);
1223 bool isPivotPositive =
false;
1226 if((t0 <= 1) && (t0 >= 0)) {
1230 isPivotPositive =
true;
1232 if((t1 <= 1) && (t1 >= 0)) {
1236 isPivotPositive =
true;
1238 if((t2 <= 1) && (t2 >= 0)) {
1242 isPivotPositive =
true;
1246 for(
int i = 0; i < 3; i++) {
1248 SimplexId vertexId0 = -1, vertexId1 = -1;
1253 for(
int j = 0; j < 3; j++) {
1254 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId].p_[j]
1255 = basePoints[pivotVertexId][j];
1258 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId].t_
1259 = basePointParameterization[pivotVertexId];
1260 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId].uv_
1261 = basePointProjections[pivotVertexId];
1262 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId].meshEdge_
1263 = baseEdges[pivotVertexId];
1269 vertexId0 = pivotVertexId;
1270 vertexId1 = (pivotVertexId + 1) % 3;
1280 vertexId0 = pivotVertexId;
1281 vertexId1 = (pivotVertexId + 2) % 3;
1288 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].t_ = t;
1290 interpolateBasePoints(
1291 basePoints[vertexId0], basePointProjections[vertexId0],
1292 basePointParameterization[vertexId0], basePoints[vertexId1],
1293 basePointProjections[vertexId1], basePointParameterization[vertexId1],
1294 t, (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i]);
1321 const triangulationType *
const triangulation)
const {
1323 SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size();
1326 (*polygonEdgeVertexLists_[polygonEdgeId]).resize(vertexId + 4);
1327 for(
int i = 0; i < 4; i++) {
1328 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isBasePoint_ =
true;
1329 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].isIntersectionPoint_
1331 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].meshEdge_
1332 = std::pair<SimplexId, SimplexId>(-1, -1);
1337 = (*polygonEdgeTriangleLists_[polygonEdgeId]).size();
1338 (*polygonEdgeTriangleLists_[polygonEdgeId]).resize(triangleId + 2);
1340 for(
int i = 0; i < 2; i++) {
1342 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].tetId_ = tetId;
1343 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].caseId_ = 4;
1344 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].polygonEdgeId_
1348 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[0]
1350 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[1]
1352 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[2]
1355 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[0]
1357 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[1]
1359 (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId + i].vertexIds_[2]
1365 std::array<std::array<double, 3>, 3> basePoints{};
1366 std::array<std::pair<double, double>, 3> basePointProjections{};
1367 std::array<double, 3> basePointParameterization{};
1368 std::array<std::pair<SimplexId, SimplexId>, 3> baseEdges{};
1370 computeBaseTriangle<dataTypeU, dataTypeV>(
1371 tetId, localEdgeId0, t0, u0, v0, localEdgeId1, t1, u1, v1, localEdgeId2, t2,
1372 u2, v2, basePoints, basePointProjections, basePointParameterization,
1373 baseEdges, triangulation);
1376 bool isPivotPositive =
false;
1381 isPivotPositive =
true;
1384 isPivotPositive =
false;
1389 isPivotPositive =
true;
1392 isPivotPositive =
false;
1396 isPivotPositive =
true;
1399 isPivotPositive =
false;
1403 for(
int i = 0; i < 4; i++) {
1405 SimplexId vertexId0 = -1, vertexId1 = -1;
1413 vertexId0 = pivotVertexId;
1414 vertexId1 = (pivotVertexId + 2) % 3;
1423 vertexId0 = pivotVertexId;
1424 vertexId1 = (pivotVertexId + 1) % 3;
1431 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].t_ = t;
1433 interpolateBasePoints(
1434 basePoints[vertexId0], basePointProjections[vertexId0],
1435 basePointParameterization[vertexId0], basePoints[vertexId1],
1436 basePointProjections[vertexId1], basePointParameterization[vertexId1],
1437 t, (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i]);
1445 for(
int j = 0; j < 3; j++) {
1446 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].p_[j]
1447 = basePoints[(pivotVertexId + 2) % 3][j];
1450 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].t_
1451 = basePointParameterization[(pivotVertexId + 2) % 3];
1452 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_
1453 = basePointProjections[(pivotVertexId + 2) % 3];
1454 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].meshEdge_
1455 = baseEdges[(pivotVertexId + 2) % 3];
1458 for(
int j = 0; j < 3; j++) {
1459 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].p_[j]
1460 = basePoints[(pivotVertexId + 1) % 3][j];
1462 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].t_
1463 = basePointParameterization[(pivotVertexId + 1) % 3];
1464 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].uv_
1465 = basePointProjections[(pivotVertexId + 1) % 3];
1466 (*polygonEdgeVertexLists_[polygonEdgeId])[vertexId + i].meshEdge_
1467 = baseEdges[(pivotVertexId + 1) % 3];
1838 const std::pair<double, double> &rangePoint0,
1839 const std::pair<double, double> &rangePoint1,
1840 const triangulationType *
const triangulation,
1843 double rangeEdge[2];
1844 rangeEdge[0] = rangePoint0.first - rangePoint1.first;
1845 rangeEdge[1] = rangePoint0.second - rangePoint1.second;
1847 double rangeNormal[2];
1848 rangeNormal[0] = -rangeEdge[1];
1849 rangeNormal[1] = rangeEdge[0];
1858 for(
int i = 0; i < 4; i++) {
1861 if(!triangulation) {
1862 vertexId = tetList_[5 * tetId + 1 + i];
1864 triangulation->getCellVertex(tetId, i, vertexId);
1867 double projectedVertex[2];
1868 projectedVertex[0] = ((
const dataTypeU *)uField_)[vertexId];
1869 projectedVertex[1] = ((
const dataTypeV *)vField_)[vertexId];
1871 double vertexRangeEdge[2];
1872 vertexRangeEdge[0] = projectedVertex[0] - rangePoint0.first;
1873 vertexRangeEdge[1] = projectedVertex[1] - rangePoint0.second;
1875 d[i] = vertexRangeEdge[0] * rangeNormal[0]
1876 + vertexRangeEdge[1] * rangeNormal[1];
1878 if(fabs(d[i]) < prec_dbl)
1887 equalVertexLocalId = i;
1892 if(!((upperNumber == 0) || (lowerNumber == 0))) {
1895 std::array<SimplexId, 2> triangleEdgeNumbers{};
1896 std::array<std::array<SimplexId, 3>, 2> triangleEdges{
1897 {{-1, -1, -1}, {-1, -1, -1}}};
1907 for(
int i = 0; i < 4; i++) {
1922 for(
SimplexId j = jStart; j != jEnd; j += jStep) {
1924 if(((d[i] > 0) && (d[j] < 0)) || ((d[i] < 0) && (d[j] > 0))) {
1927 if(triangleEdgeNumbers[0] == 3) {
1928 triangleEdges[1][triangleEdgeNumbers[1]] = edgeCounter;
1929 triangleEdgeNumbers[1]++;
1931 triangleEdges[0][triangleEdgeNumbers[0]] = edgeCounter;
1932 triangleEdgeNumbers[0]++;
1936 if((d[i] == 0) && (d[j] == 0)) {
1942 triangleEdges[0][triangleEdgeNumbers[0]] = edgeCounter;
1943 triangleEdgeNumbers[0]++;
1945 triangleEdges[0][triangleEdgeNumbers[0]] = edgeCounter;
1946 triangleEdgeNumbers[0]++;
1954 if(triangleEdges[1][0] != -1) {
1955 if(triangleEdges[1][1] == -1) {
1964 switch(triangleEdges[1][0]) {
1985 if(triangleEdges[0][i] != forbiddenEdge) {
1986 if(triangleEdges[1][1] != -1) {
1987 triangleEdges[1][2] = triangleEdges[0][i];
1990 triangleEdges[1][1] = triangleEdges[0][i];
1998 for(
int i = 0; i < 2; i++) {
1999 if(triangleEdges[i][0] != -1) {
2001 if(triangleEdges[i][2] == -1) {
2003 switch(equalVertexLocalId) {
2006 triangleEdges[i][2] = 0;
2010 triangleEdges[i][2] = 5;
2024 std::pair<double, double> uv0, uv1;
2025 std::array<std::pair<double, double>, 3> uv{};
2026 std::array<double, 3> t{};
2030 for(
int i = 0; i < 2; i++) {
2031 if(triangleEdges[i][0] != -1) {
2042 triangulation->getCellVertex(
2043 tetId, edgeImplicitEncoding_[2 * triangleEdges[i][j]], vertexId0);
2044 triangulation->getCellVertex(
2045 tetId, edgeImplicitEncoding_[2 * triangleEdges[i][j] + 1],
2049 = tetList_[5 * tetId + 1
2050 + edgeImplicitEncoding_[2 * triangleEdges[i][j]]];
2052 = tetList_[5 * tetId + 1
2053 + edgeImplicitEncoding_[2 * triangleEdges[i][j] + 1]];
2056 if((j < (
SimplexId)triangleEdges[i].size() - 1)
2057 && (triangleEdges[i][j] == triangleEdges[i][j + 1])) {
2060 uv[j].first = ((
const dataTypeU *)uField_)[vertexId0];
2061 uv[j].second = ((
const dataTypeV *)vField_)[vertexId0];
2063 uv[j + 1].first = ((
const dataTypeU *)uField_)[vertexId1];
2064 uv[j + 1].second = ((
const dataTypeV *)vField_)[vertexId1];
2068 && (triangleEdges[i][j] != triangleEdges[i][j - 1]))) {
2071 d0 = d[edgeImplicitEncoding_[2 * triangleEdges[i][j]]];
2072 uv0.first = ((
const dataTypeU *)uField_)[vertexId0];
2073 uv0.second = ((
const dataTypeV *)vField_)[vertexId0];
2075 d1 = d[edgeImplicitEncoding_[2 * triangleEdges[i][j] + 1]];
2076 uv1.first = ((
const dataTypeU *)uField_)[vertexId1];
2077 uv1.second = ((
const dataTypeV *)vField_)[vertexId1];
2080 = uv0.first + (d0 / (d0 - d1)) * (uv1.first - uv0.first);
2082 = uv0.second + (d0 / (d0 - d1)) * (uv1.second - uv0.second);
2087 if(fabs(rangePoint1.first - rangePoint0.first)
2088 > fabs(rangePoint1.second - rangePoint0.second)) {
2089 t[j] = (uv[j].first - rangePoint0.first)
2090 / (rangePoint1.first - rangePoint0.first);
2092 t[j] = (uv[j].second - rangePoint0.second)
2093 / (rangePoint1.second - rangePoint0.second);
2096 if((t[j] <= 1) && (t[j] >= 0))
2099 lowerVertexNumber++;
2101 upperVertexNumber++;
2108 if(greyVertexNumber == 3) {
2109 createdVertices += computeCase0<dataTypeU, dataTypeV>(
2110 polygonEdgeId, tetId, triangleEdges[i][0], t[0], uv[0].first,
2111 uv[0].second, triangleEdges[i][1], t[1], uv[1].first, uv[1].second,
2112 triangleEdges[i][2], t[2], uv[2].first, uv[2].second,
2114 }
else if(lowerVertexNumber == 3 || upperVertexNumber == 3) {
2116 }
else if((lowerVertexNumber == 1) && (upperVertexNumber == 1)
2117 && (greyVertexNumber == 1)) {
2118 createdVertices += computeCase1<dataTypeU, dataTypeV>(
2119 polygonEdgeId, tetId, triangleEdges[i][0], t[0], uv[0].first,
2120 uv[0].second, triangleEdges[i][1], t[1], uv[1].first, uv[1].second,
2121 triangleEdges[i][2], t[2], uv[2].first, uv[2].second,
2123 }
else if(((lowerVertexNumber == 2) && (upperVertexNumber == 1))
2124 || ((lowerVertexNumber == 1) && (upperVertexNumber == 2))) {
2125 createdVertices += computeCase2<dataTypeU, dataTypeV>(
2126 polygonEdgeId, tetId, triangleEdges[i][0], t[0], uv[0].first,
2127 uv[0].second, triangleEdges[i][1], t[1], uv[1].first, uv[1].second,
2128 triangleEdges[i][2], t[2], uv[2].first, uv[2].second,
2130 }
else if((greyVertexNumber == 1)
2131 && ((lowerVertexNumber == 2) || (upperVertexNumber == 2))) {
2132 createdVertices += computeCase3<dataTypeU, dataTypeV>(
2133 polygonEdgeId, tetId, triangleEdges[i][0], t[0], uv[0].first,
2134 uv[0].second, triangleEdges[i][1], t[1], uv[1].first, uv[1].second,
2135 triangleEdges[i][2], t[2], uv[2].first, uv[2].second,
2137 }
else if(((greyVertexNumber == 2))
2138 && ((lowerVertexNumber == 1) || (upperVertexNumber == 1))) {
2139 createdVertices += computeCase4<dataTypeU, dataTypeV>(
2140 polygonEdgeId, tetId, triangleEdges[i][0], t[0], uv[0].first,
2141 uv[0].second, triangleEdges[i][1], t[1], uv[1].first, uv[1].second,
2142 triangleEdges[i][2], t[2], uv[2].first, uv[2].second,
2152 if((triangleEdges[1][0] != -1) && (createdVertices > 3)) {
2154 std::vector<SimplexId> createdVertexList(createdVertices);
2156 createdVertexList[i]
2157 = polygonEdgeVertexLists_[polygonEdgeId]->size() - 1 - i;
2160 std::vector<bool> snappedVertices(createdVertices,
false);
2161 std::vector<SimplexId> colinearVertices;
2162 colinearVertices.reserve(createdVertices);
2164 for(
SimplexId i = 0; i < createdVertices; i++) {
2165 colinearVertices.clear();
2167 if(!snappedVertices[i]) {
2168 colinearVertices.push_back(i);
2169 for(
SimplexId j = 0; j < createdVertices; j++) {
2170 if((i != j) && (!snappedVertices[j])) {
2174 if((*polygonEdgeVertexLists_[polygonEdgeId])[createdVertexList[i]]
2176 == (*polygonEdgeVertexLists_[polygonEdgeId])
2177 [createdVertexList[j]]
2179 colinearVertices.push_back(j);
2185 if((colinearVertices.size() == 4) || (colinearVertices.size() == 3)) {
2190 std::pair<SimplexId, SimplexId> minPair;
2191 double minDistance = -1;
2197 (*polygonEdgeVertexLists_[polygonEdgeId])
2198 [createdVertexList[colinearVertices[j]]]
2200 (*polygonEdgeVertexLists_[polygonEdgeId])
2201 [createdVertexList[colinearVertices[k]]]
2217 if((minDistance < 0) || (distance < minDistance)) {
2218 minDistance = distance;
2226 if((minDistance != -1) && (minDistance < prec_dbl)) {
2231 if((j != minPair.first) && (j != minPair.second)) {
2234 for(
int k = 0; k < 3; k++) {
2235 (*polygonEdgeVertexLists_[polygonEdgeId])
2236 [createdVertexList[colinearVertices[minPair.first]]]
2238 = (*polygonEdgeVertexLists_[polygonEdgeId])
2239 [createdVertexList[colinearVertices[j]]]
2242 (*polygonEdgeVertexLists_[polygonEdgeId])
2243 [createdVertexList[colinearVertices[minPair.first]]]
2245 = (*polygonEdgeVertexLists_[polygonEdgeId])
2246 [createdVertexList[colinearVertices[j]]]
2249 (*polygonEdgeVertexLists_[polygonEdgeId])
2250 [createdVertexList[colinearVertices[minPair.first]]]
2252 = (*polygonEdgeVertexLists_[polygonEdgeId])
2253 [createdVertexList[colinearVertices[j]]]
2256 (*polygonEdgeVertexLists_[polygonEdgeId])
2257 [createdVertexList[colinearVertices[minPair.first]]]
2259 = (*polygonEdgeVertexLists_[polygonEdgeId])
2260 [createdVertexList[colinearVertices[j]]]
2263 (*polygonEdgeVertexLists_[polygonEdgeId])
2264 [createdVertexList[colinearVertices[minPair.first]]]
2265 .isIntersectionPoint_
2266 = (*polygonEdgeVertexLists_[polygonEdgeId])
2267 [createdVertexList[colinearVertices[j]]]
2268 .isIntersectionPoint_;
2269 if((*polygonEdgeVertexLists_[polygonEdgeId])
2270 [createdVertexList[colinearVertices[j]]]
2273 (*polygonEdgeVertexLists_[polygonEdgeId])
2274 [createdVertexList[colinearVertices[minPair.first]]]
2276 = (*polygonEdgeVertexLists_[polygonEdgeId])
2277 [createdVertexList[colinearVertices[j]]]
2282 for(
int k = 0; k < 3; k++) {
2283 (*polygonEdgeVertexLists_[polygonEdgeId])
2284 [createdVertexList[colinearVertices[minPair.second]]]
2286 = (*polygonEdgeVertexLists_[polygonEdgeId])
2287 [createdVertexList[colinearVertices[j]]]
2290 (*polygonEdgeVertexLists_[polygonEdgeId])
2291 [createdVertexList[colinearVertices[minPair.second]]]
2293 = (*polygonEdgeVertexLists_[polygonEdgeId])
2294 [createdVertexList[colinearVertices[j]]]
2297 (*polygonEdgeVertexLists_[polygonEdgeId])
2298 [createdVertexList[colinearVertices[minPair.second]]]
2300 = (*polygonEdgeVertexLists_[polygonEdgeId])
2301 [createdVertexList[colinearVertices[j]]]
2304 (*polygonEdgeVertexLists_[polygonEdgeId])
2305 [createdVertexList[colinearVertices[minPair.second]]]
2307 = (*polygonEdgeVertexLists_[polygonEdgeId])
2308 [createdVertexList[colinearVertices[j]]]
2311 (*polygonEdgeVertexLists_[polygonEdgeId])
2312 [createdVertexList[colinearVertices[minPair.second]]]
2313 .isIntersectionPoint_
2314 = (*polygonEdgeVertexLists_[polygonEdgeId])
2315 [createdVertexList[colinearVertices[j]]]
2316 .isIntersectionPoint_;
2317 if((*polygonEdgeVertexLists_[polygonEdgeId])
2318 [createdVertexList[colinearVertices[j]]]
2321 (*polygonEdgeVertexLists_[polygonEdgeId])
2322 [createdVertexList[colinearVertices[minPair.second]]]
2324 = (*polygonEdgeVertexLists_[polygonEdgeId])
2325 [createdVertexList[colinearVertices[j]]]
2329 snappedVertices[colinearVertices[minPair.first]] =
true;
2330 snappedVertices[colinearVertices[minPair.second]] =
true;
2341 return createdVertices;
2350#ifndef TTK_ENABLE_KAMIKAZE
2370 std::vector<std::vector<IntersectionTriangle>> tetIntersections(tetNumber_);
2371 std::vector<std::vector<Vertex>> tetNewVertices(tetNumber_);
2378 SimplexId const tetId = (*polygonEdgeTriangleLists_[i])[j].tetId_;
2380 tetIntersections[tetId].emplace_back();
2382 tetIntersections[tetId].back().caseId_
2383 = (*polygonEdgeTriangleLists_[i])[j].caseId_;
2384 tetIntersections[tetId].back().polygonEdgeId_ = i;
2385 tetIntersections[tetId].back().triangleId_ = j;
2386 for(
int k = 0; k < 3; k++) {
2387 tetIntersections[tetId].back().vertexIds_[k]
2388 = (*polygonEdgeTriangleLists_[i])[j].vertexIds_[k];
2389 tetIntersections[tetId].back().uv_[k]
2390 = (*globalVertexList_)[tetIntersections[tetId].back().vertexIds_[k]]
2392 tetIntersections[tetId].back().t_[k]
2393 = (*globalVertexList_)[tetIntersections[tetId].back().vertexIds_[k]]
2395 for(
int l = 0; l < 3; l++) {
2396 tetIntersections[tetId].back().p_[k][l]
2397 = (*globalVertexList_)[tetIntersections[tetId].back().vertexIds_[k]]
2401 tetIntersections[tetId].back().intersection_.first = -DBL_MAX;
2402 tetIntersections[tetId].back().intersection_.second = -DBL_MAX;
2406 std::vector<SimplexId> tetList;
2408 if(tetIntersections[i].size() > 1)
2409 tetList.push_back(i);
2412#ifdef TTK_ENABLE_OPENMP
2413#pragma omp parallel for num_threads(threadNumber_)
2426 this->printWrn(
"Preventing an infinite loop!");
2427 this->printWrn(
"More than 1000 re-meshed triangles in tet #"
2428 + std::to_string(tetId));
2429 this->printWrn(
"Extra-thin triangles keep on intersecting?!");
2436 = (
SimplexId)tetIntersections[tetId].size();
2438 for(
SimplexId k = 0; k < originalTriangleNumber; k++) {
2441 = tetIntersections[tetId][j].polygonEdgeId_;
2443 = tetIntersections[tetId][k].polygonEdgeId_;
2445 if((j != k) && (polygonEdgeId0 != polygonEdgeId1)) {
2450 std::pair<double, double> edge0point0, edge0point1;
2452 getTriangleRangeExtremities(
2453 tetId, j, tetIntersections, edge0point0, edge0point1);
2456 std::pair<double, double> edge1point0, edge1point1;
2458 getTriangleRangeExtremities(
2459 tetId, k, tetIntersections, edge1point0, edge1point1);
2462 std::pair<double, double> intersection;
2464 edge0point0.first, edge0point0.second, edge0point1.first,
2465 edge0point1.second, edge1point0.first, edge1point0.second,
2466 edge1point1.first, edge1point1.second, intersection.first,
2467 intersection.second);
2469 if((hasIntersection)
2481 computeTriangleIntersection(tetId, j, k, polygonEdgeId0,
2482 polygonEdgeId1, intersection,
2483 newVertexNumber, newTriangleNumber,
2484 tetIntersections, tetNewVertices);
2495 SimplexId const localId = (*globalVertexList_).size();
2496 tetNewVertices[i][j].localId_ = localId;
2497 (*globalVertexList_).push_back(tetNewVertices[i][j]);
2504 if(((tetIntersections[i][j].intersection_.first != -DBL_MAX)
2505 && (tetIntersections[i][j].intersection_.second != -DBL_MAX))
2506 || (tetIntersections[i][j].triangleId_ < 0)) {
2508 SimplexId triangleId = tetIntersections[i][j].triangleId_;
2510 if(triangleId < 0) {
2513 triangleId = (*polygonEdgeTriangleLists_[tetIntersections[i][j]
2516 (*polygonEdgeTriangleLists_[tetIntersections[i][j].polygonEdgeId_])
2517 .resize(triangleId + 1);
2518 (*polygonEdgeTriangleLists_[tetIntersections[i][j].polygonEdgeId_])
2522 (*polygonEdgeTriangleLists_[tetIntersections[i][j].polygonEdgeId_])
2525 = tetIntersections[i][j].caseId_;
2528 for(
int k = 0; k < 3; k++) {
2530 SimplexId vertexId = tetIntersections[i][j].vertexIds_[k];
2534 vertexId = tetNewVertices[i][-(vertexId + 1)].localId_;
2536 (*polygonEdgeTriangleLists_[tetIntersections[i][j]
2537 .polygonEdgeId_])[triangleId]