Skip to content

Commit

Permalink
Add a test case of a polygon with hole that cause CDT to go into infi…
Browse files Browse the repository at this point in the history
…nite recursion

From issue jhasse#41
  • Loading branch information
pierre-dejoue committed Apr 20, 2022
1 parent 27042f1 commit 9f185df
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
14 changes: 14 additions & 0 deletions testbed/data/recursive.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
450 2250
450 1750
400 1700
350 1650
350 500
1050 1700
HOLE
980 1636
950 1600
650 1230
625 1247
600 1250
591 1350
550 2050
32 changes: 32 additions & 0 deletions unittest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,38 @@ BOOST_AUTO_TEST_CASE(ConcaveBoundaryTest)
}
}

BOOST_AUTO_TEST_CASE(SimpleTestCaseInfiniteLoop)
{
std::vector<p2t::Point*> polyline {
new p2t::Point(450, 2250),
new p2t::Point(450, 1750),
new p2t::Point(400, 1700),
new p2t::Point(350, 1650),
new p2t::Point(350, 500),
new p2t::Point(1050, 1700)
};

std::vector<p2t::Point*> hole = {
new p2t::Point(980, 1636),
new p2t::Point(950, 1600),
new p2t::Point(650, 1230),
new p2t::Point(625, 1247),
new p2t::Point(600, 1250),
new p2t::Point(591, 1350),
new p2t::Point(550, 2050)
};

p2t::CDT cdt(polyline);
cdt.AddHole(hole);
cdt.Triangulate();
for (const auto p : polyline) {
delete p;
}
for (const auto p : hole) {
delete p;
}
}

BOOST_AUTO_TEST_CASE(RegressionTestIssue18)
{
// This polygon is an excerpt from the test file city.dat, from issue #18
Expand Down

0 comments on commit 9f185df

Please sign in to comment.