bool test_ray(Arrangement_2& arr, Face_handle f) { Segment_2 s1(Point_2(0, 0), Point_2(1, 0)); Halfedge_handle eh1 = arr.insert_in_face_interior(X_monotone_curve_2(s1), f); Vertex_handle vh = eh1->target(); Ray_2 ray(Point_2(1, 0), Point_2(2, 0)); Halfedge_handle eh2 = arr.insert_from_left_vertex(X_monotone_curve_2(ray), vh); // Remove the edges arr.remove_edge(eh2); arr.remove_edge(eh1); if (!::test(arr)) return false; return true; }
int main () { Arrangement_2 arr; Point_2 ps[N_POINTS]; Vertex_handle vhs[N_POINTS]; bool valid; int k; ps[0] = Point_2 (2, 2); ps[1] = Point_2 (2, 7); ps[2] = Point_2 (4, 9); ps[3] = Point_2 (4, 5); ps[4] = Point_2 (5, 3); ps[5] = Point_2 (7, 1); ps[6] = Point_2 (7, 5); ps[7] = Point_2 (7, 7); ps[8] = Point_2 (9, 3); ps[9] = Point_2 (9, 6); for (k = 0; k < N_POINTS; k++) { vhs[k] = insert_point (arr, ps[k]); } arr.insert_from_left_vertex (Segment_2 (Point_2 (2, 7), Point_2 (4, 7)), vhs[1]); TEST_VALIDITY(1); arr.insert_from_right_vertex (Segment_2 (Point_2 (6, 6), Point_2 (7, 5)), vhs[6]); TEST_VALIDITY(2); arr.insert_at_vertices (Segment_2 (Point_2 (7, 1), Point_2 (9, 3)), vhs[5], vhs[8]); TEST_VALIDITY(3); arr.insert_at_vertices (Segment_2 (Point_2 (7, 5), Point_2 (9, 3)), vhs[6], vhs[8]); TEST_VALIDITY(4); arr.insert_from_right_vertex (Segment_2 (Point_2 (1, 1), Point_2 (2, 7)), vhs[1]); TEST_VALIDITY(5); insert_non_intersecting_curve (arr, Segment_2 (Point_2 (1, 1), Point_2 (7, 1))); TEST_VALIDITY(6); insert_non_intersecting_curve (arr, Segment_2 (Point_2 (4, 7), Point_2 (6, 6))); TEST_VALIDITY(7); insert_non_intersecting_curve (arr, Segment_2 (Point_2 (2, 7), Point_2 (3, 3))); TEST_VALIDITY(8); insert_non_intersecting_curve (arr, Segment_2 (Point_2 (3, 3), Point_2 (7, 1))); TEST_VALIDITY(9); arr.insert_at_vertices (Segment_2 (Point_2 (7, 5), Point_2 (9, 6)), vhs[6], vhs[9]); TEST_VALIDITY(10); std::cout << "Arrangement size:" << " V = " << arr.number_of_vertices() << " (" << arr.number_of_isolated_vertices() << " isolated)" << ", E = " << arr.number_of_edges() << ", F = " << arr.number_of_faces() << std::endl; // Check the validity more thoroughly. valid = is_valid(arr); std::cout << "Arrangement is " << (valid ? "valid." : "NOT valid!") << std::endl; return (0); }