From b380a98887b675ba6c8b238dcb470d2bf3440d91 Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Sat, 7 Sep 2019 20:28:03 +0530 Subject: Fix two bugs in delaunay blenlib function. Bugs were: (1) needed an epsilon test in CCW test in order to handle new costraint edge that intersects an existing point but only within epsilon; (2) the "valid bmesh" output mode sometimes left a face that included outside frame point. --- tests/gtests/blenlib/BLI_delaunay_2d_test.cc | 30 +++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'tests/gtests') diff --git a/tests/gtests/blenlib/BLI_delaunay_2d_test.cc b/tests/gtests/blenlib/BLI_delaunay_2d_test.cc index ce84baf802a..315e5804784 100644 --- a/tests/gtests/blenlib/BLI_delaunay_2d_test.cc +++ b/tests/gtests/blenlib/BLI_delaunay_2d_test.cc @@ -15,8 +15,6 @@ extern "C" { #include #include -#define DLNY_EPSILON 1e-8 - static void fill_input_verts(CDT_input *r_input, float (*vcos)[2], int nverts) { r_input->verts_len = nverts; @@ -27,7 +25,7 @@ static void fill_input_verts(CDT_input *r_input, float (*vcos)[2], int nverts) r_input->faces = NULL; r_input->faces_start_table = NULL; r_input->faces_len_table = NULL; - r_input->epsilon = 1e-6f; + r_input->epsilon = 1e-5f; } static void add_input_edges(CDT_input *r_input, int (*edges)[2], int nedges) @@ -643,6 +641,32 @@ TEST(delaunay, TwoSquaresOverlap) BLI_delaunay_2d_cdt_free(out); } +TEST(delaunay, TriCutoff) +{ + CDT_input in; + CDT_result *out; + float p[][2] = { + {-3.53009f, 1.29403f}, + {-4.11844f, -1.08375f}, + {1.56893f, 1.29403f}, + {0.621034f, 0.897734f}, + {0.549125f, 1.29403f}, + }; + int f[] = {0, 2, 1}; + int fstart[] = {0}; + int flen[] = {3}; + int e[][2] = {{3, 4}}; + + fill_input_verts(&in, p, 5); + add_input_faces(&in, f, fstart, flen, 1); + add_input_edges(&in, e, 1); + out = BLI_delaunay_2d_cdt_calc(&in, CDT_CONSTRAINTS_VALID_BMESH); + EXPECT_EQ(out->verts_len, 5); + EXPECT_EQ(out->edges_len, 6); + EXPECT_EQ(out->faces_len, 2); + BLI_delaunay_2d_cdt_free(out); +} + enum { RANDOM_PTS, RANDOM_SEGS, -- cgit v1.2.3