Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoward Trickey <howard.trickey@gmail.com>2019-09-07 17:58:03 +0300
committerHoward Trickey <howard.trickey@gmail.com>2019-09-07 18:01:24 +0300
commitb380a98887b675ba6c8b238dcb470d2bf3440d91 (patch)
tree5ff5bc4abc48e964ff2c20287bc7d8640b681275 /tests/gtests
parent0b2d1badecc48b5cbff5ec088b29c6e9acc5e1d0 (diff)
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.
Diffstat (limited to 'tests/gtests')
-rw-r--r--tests/gtests/blenlib/BLI_delaunay_2d_test.cc30
1 files changed, 27 insertions, 3 deletions
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 <fstream>
#include <sstream>
-#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,