This commit is contained in:
Matthias Koefferlein 2023-08-15 15:56:15 +02:00
parent 512cf604d0
commit 7351810e55
2 changed files with 30 additions and 5 deletions

View File

@ -82,11 +82,6 @@ public:
*/
void clear ();
/**
* @brief Creates a constrained Delaunay triangulation from the given Region
*/
void create_constrained_delaunay (const db::Region &region, 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 &region, double dbu = 1.0);
// NOTE: these functions are SLOW and intended to test purposes only
std::vector<db::Vertex *> find_touching (const db::DBox &box) const;
std::vector<db::Vertex *> find_inside_circle (const db::DPoint &center, double radius) const;

View File

@ -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))");
}