summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorpacien2017-12-24 00:07:53 +0100
committerpacien2017-12-24 00:07:53 +0100
commitcdbae7a5e7515ba50ae21f15929a086fc40fcae3 (patch)
tree492c7451e559beb35b0680cd474adaa5a0d8f0d0 /test
parent39cbe5d0d7db78f0d2808abea5562db84d03a07e (diff)
downloadmorpher-cdbae7a5e7515ba50ae21f15929a086fc40fcae3.tar.gz
Implement Delaunay propagation
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'test')
-rw-r--r--test/morpher/quadrilateral.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/morpher/quadrilateral.c b/test/morpher/quadrilateral.c
index 963d1d6..b278e2f 100644
--- a/test/morpher/quadrilateral.c
+++ b/test/morpher/quadrilateral.c
@@ -21,7 +21,6 @@ static inline bool vertices_equals(CartesianMapping maps[],
21 */ 21 */
22static void test_quadrilateral_flip_diagonal() { 22static void test_quadrilateral_flip_diagonal() {
23 CartesianMapping A = m(50, 0), B = m(0, 100), C = m(100, 100), D = m(0, 200), E = m(100, 200); 23 CartesianMapping A = m(50, 0), B = m(0, 100), C = m(100, 100), D = m(0, 200), E = m(100, 200);
24
25 TriangleMap *t = trianglemap_create(A, B, C); 24 TriangleMap *t = trianglemap_create(A, B, C);
26 TriangleMap *r = trianglemap_create(C, B, E); 25 TriangleMap *r = trianglemap_create(C, B, E);
27 TriangleMap *l = trianglemap_create(B, D, E); 26 TriangleMap *l = trianglemap_create(B, D, E);
@@ -54,9 +53,34 @@ static void test_quadrilateral_is_delaunay(CartesianMapping A, CartesianMapping
54 trianglemap_destroy(r); 53 trianglemap_destroy(r);
55} 54}
56 55
56static void test_quadrilateral_propagate_delaunay() {
57 CartesianMapping A = m(0, 0), B = m(0, 10), C = m(10, 10), D = m(10, 0), E = m(4, 6), F = m(8, 7);
58 TriangleMap *l = trianglemap_create(A, B, C);
59 TriangleMap *r = trianglemap_create(A, C, D);
60 trianglemap_set_neighbors(l, NULL, NULL, r, r);
61 trianglemap_set_neighbors(r, l, NULL, NULL, NULL);
62 trianglemap_split(l, E);
63 trianglemap_split(r, F);
64
65 trianglemap_foreach_neighbor(r, quadrilateral_propagate_delaunay);
66
67 {
68 TriangleMap *triangle;
69 int neighbor_index;
70 for (triangle = l; triangle != NULL; triangle = triangle->next)
71 for (neighbor_index = 0; neighbor_index < 3; ++neighbor_index)
72 if (triangle->neighbors[neighbor_index] != NULL)
73 assert(quadrilateral_is_delaunay(triangle, triangle->neighbors[neighbor_index]));
74 }
75
76 trianglemap_destroy(l);
77 trianglemap_destroy(r);
78}
79
57int main(int argc, char **argv) { 80int main(int argc, char **argv) {
58 test_quadrilateral_flip_diagonal(); 81 test_quadrilateral_flip_diagonal();
59 test_quadrilateral_is_delaunay(m(0, 0), m(0, 3), m(3, 3), m(2, 1), false); 82 test_quadrilateral_is_delaunay(m(0, 0), m(0, 3), m(3, 3), m(2, 1), false);
60 test_quadrilateral_is_delaunay(m(0, 0), m(0, 3), m(3, 3), m(4, -1), true); 83 test_quadrilateral_is_delaunay(m(0, 0), m(0, 3), m(3, 3), m(4, -1), true);
84 test_quadrilateral_propagate_delaunay();
61 return 0; 85 return 0;
62} 86}