Skip to content

Commit b6436e6

Browse files
author
Marc Kramer
committed
Add TouchingHolesTest
1 parent 141ade3 commit b6436e6

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

unittest/main.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,38 @@ BOOST_AUTO_TEST_CASE(PolygonTest04)
223223
}
224224
}
225225

226+
BOOST_AUTO_TEST_CASE(TouchingHolesTest)
227+
{
228+
std::list<p2t::Point> points;
229+
auto point = [&points](double a, double b){
230+
points.emplace_back(a, b);
231+
return &points.back();
232+
};
233+
std::vector<p2t::Point*> polyline{
234+
point(0, 0),
235+
point(1, 0),
236+
point(0.5, 1),
237+
};
238+
auto point_02_02 = p2t::Point(0.2, 0.2);
239+
std::vector<p2t::Point*> hole0 {
240+
point(0.1, 0.1),
241+
point(0.2, 0.1),
242+
&point_02_02,
243+
};
244+
std::vector<p2t::Point*> hole1 {
245+
&point_02_02,
246+
point(0.3, 0.2),
247+
point(0.3, 0.3),
248+
};
249+
p2t::CDT cdt{ polyline };
250+
cdt.AddHole(hole0);
251+
cdt.AddHole(hole1);
252+
BOOST_CHECK_NO_THROW(cdt.Triangulate());
253+
const auto result = cdt.GetTriangles();
254+
BOOST_REQUIRE_EQUAL(result.size(), 9);
255+
BOOST_CHECK(p2t::IsDelaunay(result));
256+
}
257+
226258
BOOST_AUTO_TEST_CASE(TestbedFilesTest)
227259
{
228260
for (const auto& filename : { "custom.dat", "diamond.dat", "star.dat", "test.dat" }) {

0 commit comments

Comments
 (0)