diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/morpher/quadrilateral.c | 26 |
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 | */ |
22 | static void test_quadrilateral_flip_diagonal() { | 22 | static 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 | ||
56 | static 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 | |||
57 | int main(int argc, char **argv) { | 80 | int 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 | } |