diff --git a/src/db/db/dbTriangles.h b/src/db/db/dbTriangles.h index 1291245a7..ee1b8f17a 100644 --- a/src/db/db/dbTriangles.h +++ b/src/db/db/dbTriangles.h @@ -82,11 +82,6 @@ public: */ void clear (); - /** - * @brief Creates a constrained Delaunay triangulation from the given Region - */ - void create_constrained_delaunay (const db::Region ®ion, double dbu = 1.0); - // exposed for testing purposes: /** @@ -180,6 +175,11 @@ public: */ void remove_outside_triangles (); + /** + * @brief Creates a constrained Delaunay triangulation from the given Region + */ + void create_constrained_delaunay (const db::Region ®ion, double dbu = 1.0); + // NOTE: these functions are SLOW and intended to test purposes only std::vector find_touching (const db::DBox &box) const; std::vector find_inside_circle (const db::DPoint ¢er, double radius) const; diff --git a/src/db/unit_tests/dbTrianglesTests.cc b/src/db/unit_tests/dbTrianglesTests.cc index 188573985..d915c2608 100644 --- a/src/db/unit_tests/dbTrianglesTests.cc +++ b/src/db/unit_tests/dbTrianglesTests.cc @@ -513,3 +513,28 @@ TEST(Triangle_test_heavy_find_point_around) tl::info << tl::endl << "done."; } + +TEST(Triangle_test_create_constrained_delaunay) +{ + db::Region r; + r.insert (db::Box (0, 0, 1000, 1000)); + + db::Region r2; + r2.insert (db::Box (200, 200, 800, 800)); + + r -= r2; + + db::Triangles tri; + tri.create_constrained_delaunay (r); + tri.remove_outside_triangles (); + + EXPECT_EQ (tri.to_string (), + "((1000, 0), (0, 0), (200, 200)), " + "((0, 1000), (200, 200), (0, 0)), " + "((1000, 0), (200, 200), (800, 200)), " + "((1000, 0), (800, 200), (1000, 1000)), " + "((800, 200), (800, 800), (1000, 1000)), " + "((0, 1000), (1000, 1000), (800, 800)), " + "((0, 1000), (800, 800), (200, 800)), " + "((0, 1000), (200, 800), (200, 200))"); +}