Skip to content

Commit

Permalink
#174 Temporary fix for the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-ogre committed May 6, 2024
1 parent 39044c3 commit 526f0a0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CDT/include/Triangulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,12 @@ void Triangulation<T, TNearPointLocator>::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;
Expand All @@ -1674,6 +1679,11 @@ void Triangulation<T, TNearPointLocator>::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);
Expand Down
30 changes: 30 additions & 0 deletions CDT/tests/cdt.test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <CDT.h>
#include <InitializeWithGrid.h>
#include <VerifyTopology.h>

#include <catch2/benchmark/catch_benchmark.hpp>
Expand Down Expand Up @@ -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<double> cdt;
CDT::initializeWithRegularGrid(0., 3., 0., 4., 3, 4, cdt);
REQUIRE(CDT::verifyTopology(cdt));
saveToOff("/tmp/grid.off", cdt);

const std::vector<CDT::V2d<double> > vv = {
{0.5, 0.5},
{0.5, 3.5},
{2.5, 3.5},
{2.5, 0.5},
};
const std::vector<CDT::Edge> 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);
}

0 comments on commit 526f0a0

Please sign in to comment.