From 526f0a052a840c9468c0eeb99529c485bebeae8e Mon Sep 17 00:00:00 2001 From: artem-ogre Date: Mon, 6 May 2024 13:52:05 +0200 Subject: [PATCH] #174 Temporary fix for the issue --- CDT/include/Triangulation.hpp | 12 +++++++++++- CDT/tests/cdt.test.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CDT/include/Triangulation.hpp b/CDT/include/Triangulation.hpp index 4b0a8a1..ebd62fe 100644 --- a/CDT/include/Triangulation.hpp +++ b/CDT/include/Triangulation.hpp @@ -1655,7 +1655,12 @@ void Triangulation::triangulatePseudoPolygonIteration( { const Edge outerEdge(b, c); const TriInd outerTri = outerTris.at(outerEdge); - if(outerTri != noNeighbor) + if(outerEdge.v2() <= m_nTargetVerts && outerTri == noNeighbor) + { + assert(outerTri != iT); + t.neighbors[1] = outerTri; + } + else if(outerTri != noNeighbor) { assert(outerTri != iT); t.neighbors[1] = outerTri; @@ -1674,6 +1679,11 @@ void Triangulation::triangulatePseudoPolygonIteration( { // pseudo-poly is reduced to a single outer edge const Edge outerEdge(c, a); const TriInd outerTri = outerTris.at(outerEdge); + if(outerEdge.v2() <= m_nTargetVerts && outerTri == noNeighbor) + { + assert(outerTri != iT); + t.neighbors[2] = outerTri; + } if(outerTri != noNeighbor) { assert(outerTri != iT); diff --git a/CDT/tests/cdt.test.cpp b/CDT/tests/cdt.test.cpp index d073124..1d43eef 100644 --- a/CDT/tests/cdt.test.cpp +++ b/CDT/tests/cdt.test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -958,4 +959,33 @@ TEST_CASE("Regression test #174: super-triangle of tiny bounding box", "") REQUIRE(CDT::verifyTopology(cdt)); cdt.eraseSuperTriangle(); REQUIRE(cdt.triangles.size() == std::size_t(1)); +} + +TEST_CASE("Regression test #175", "") +{ + CDT::Triangulation cdt; + CDT::initializeWithRegularGrid(0., 3., 0., 4., 3, 4, cdt); + REQUIRE(CDT::verifyTopology(cdt)); + saveToOff("/tmp/grid.off", cdt); + + const std::vector > vv = { + {0.5, 0.5}, + {0.5, 3.5}, + {2.5, 3.5}, + {2.5, 0.5}, + }; + const std::vector ee = { + CDT::Edge(0, 1), + CDT::Edge(1, 2), + CDT::Edge(2, 3), + CDT::Edge(0, 3), + }; + + cdt.insertVertices(vv); + REQUIRE(CDT::verifyTopology(cdt)); + cdt.insertEdges(ee); + REQUIRE(CDT::verifyTopology(cdt)); + cdt.eraseOuterTriangles(); + REQUIRE(cdt.triangles.size() == std::size_t(14)); + saveToOff("/tmp/after.off", cdt); } \ No newline at end of file