From ac614289dfdba25479af6ac93cf77a8c31c7fe5b Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Thu, 26 Jan 2012 08:34:35 +0000 Subject: [PATCH] pacify some compiler & cleanup --- .../curve_history.cpp | 38 ++++---- .../edge_insertion.cpp | 24 ++--- .../edge_manipulation.cpp | 90 +++++++++---------- .../point_location_utils.h | 54 +++++------ 4 files changed, 96 insertions(+), 110 deletions(-) diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/curve_history.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/curve_history.cpp index eae236ea8b6..1eb9c50c36d 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/curve_history.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/curve_history.cpp @@ -19,24 +19,24 @@ typedef CGAL::Arrangement_with_history_2 Arr_with_hist_2; typedef Arr_with_hist_2::Curve_handle Curve_handle; typedef CGAL::Arr_simple_point_location Point_location; -int main () +int main() { Arr_with_hist_2 arr; // Insert s1, s2 and s3 incrementally: - Segment_2 s1 (Point_2 (0, 3), Point_2 (4, 3)); - Curve_handle c1 = insert (arr, s1); - Segment_2 s2 (Point_2 (3, 2), Point_2 (3, 5)); - Curve_handle c2 = insert (arr, s2); - Segment_2 s3 (Point_2 (2, 3), Point_2 (5, 3)); - Curve_handle c3 = insert (arr, s3); + Segment_2 s1(Point_2(0, 3), Point_2(4, 3)); + insert(arr, s1); + Segment_2 s2(Point_2(3, 2), Point_2(3, 5)); + insert(arr, s2); + Segment_2 s3(Point_2(2, 3), Point_2(5, 3)); + insert(arr, s3); // Insert three additional segments aggregately: - Segment_2 segs[3]; - segs[0] = Segment_2 (Point_2 (2, 6), Point_2 (7, 1)); - segs[1] = Segment_2 (Point_2 (0, 0), Point_2 (2, 6)); - segs[2] = Segment_2 (Point_2 (3, 4), Point_2 (6, 4)); - insert (arr, segs, segs + 3); + Segment_2 segs[3]; + segs[0] = Segment_2(Point_2(2, 6), Point_2(7, 1)); + segs[1] = Segment_2(Point_2(0, 0), Point_2(2, 6)); + segs[2] = Segment_2(Point_2(3, 4), Point_2(6, 4)); + insert(arr, segs, segs + 3); // Print out the curves and the number of edges each one induces. Arr_with_hist_2::Curve_iterator cit; @@ -65,14 +65,14 @@ int main () } // Perform some point-location queries: - Point_location pl (arr); + Point_location pl(arr); - Point_2 p1 (4, 6); - point_location_query (pl, p1); - Point_2 p2 (6, 2); - point_location_query (pl, p2); - Point_2 p3 (2, 4); - point_location_query (pl, p3); + Point_2 p1(4, 6); + point_location_query(pl, p1); + Point_2 p2(6, 2); + point_location_query(pl, p2); + Point_2 p3(2, 4); + point_location_query(pl, p3); return 0; } diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_insertion.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_insertion.cpp index adbc9804fd3..4b1c2ebf396 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_insertion.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_insertion.cpp @@ -16,26 +16,26 @@ typedef CGAL::Arrangement_2 Arrangement_2; typedef Arrangement_2::Vertex_handle Vertex_handle; typedef Arrangement_2::Halfedge_handle Halfedge_handle; -int main () +int main() { Arrangement_2 arr; - Segment_2 s1 (Point_2 (1, 3), Point_2 (3, 5)); - Segment_2 s2 (Point_2 (3, 5), Point_2 (5, 3)); - Segment_2 s3 (Point_2 (5, 3), Point_2 (3, 1)); - Segment_2 s4 (Point_2 (3, 1), Point_2 (1, 3)); - Segment_2 s5 (Point_2 (1, 3), Point_2 (5, 3)); + Segment_2 s1(Point_2(1, 3), Point_2(3, 5)); + Segment_2 s2(Point_2(3, 5), Point_2(5, 3)); + Segment_2 s3(Point_2(5, 3), Point_2(3, 1)); + Segment_2 s4(Point_2(3, 1), Point_2(1, 3)); + Segment_2 s5(Point_2(1, 3), Point_2(5, 3)); - Halfedge_handle e1 = arr.insert_in_face_interior (s1, arr.unbounded_face()); + Halfedge_handle e1 = arr.insert_in_face_interior(s1, arr.unbounded_face()); Vertex_handle v1 = e1->source(); Vertex_handle v2 = e1->target(); - Halfedge_handle e2 = arr.insert_from_left_vertex (s2, v2); + Halfedge_handle e2 = arr.insert_from_left_vertex(s2, v2); Vertex_handle v3 = e2->target(); - Halfedge_handle e3 = arr.insert_from_right_vertex (s3, v3); + Halfedge_handle e3 = arr.insert_from_right_vertex(s3, v3); Vertex_handle v4 = e3->target(); - Halfedge_handle e4 = arr.insert_at_vertices (s4, v4, v1); - Halfedge_handle e5 = arr.insert_at_vertices (s5, v1, v3); + arr.insert_at_vertices(s4, v4, v1); + arr.insert_at_vertices(s5, v1, v3); - print_arrangement (arr); + print_arrangement(arr); return 0; } diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_manipulation.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_manipulation.cpp index 1ec4ca61feb..67bdfbae685 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_manipulation.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/edge_manipulation.cpp @@ -3,81 +3,73 @@ #include -#ifdef CGAL_USE_GMP - #include - typedef CGAL::Gmpz Number_type; -#else - #include - typedef CGAL::MP_Float Number_type; -#endif - -#include +#include #include #include #include "arr_print.h" -typedef CGAL::Cartesian Kernel; -typedef CGAL::Arr_segment_traits_2 Traits_2; -typedef Traits_2::Point_2 Point_2; -typedef Traits_2::X_monotone_curve_2 Segment_2; -typedef CGAL::Arrangement_2 Arrangement_2; -typedef Arrangement_2::Vertex_handle Vertex_handle; -typedef Arrangement_2::Halfedge_handle Halfedge_handle; +typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; +typedef CGAL::Arr_segment_traits_2 Traits_2; +typedef Traits_2::Point_2 Point_2; +typedef Traits_2::X_monotone_curve_2 Segment_2; +typedef CGAL::Arrangement_2 Arrangement_2; +typedef Arrangement_2::Vertex_handle Vertex_handle; +typedef Arrangement_2::Halfedge_handle Halfedge_handle; -int main () +int main() { - // Step (a) - construct a triangular face. + // Step(a) - construct a triangular face. Arrangement_2 arr; - Segment_2 s1 (Point_2 (667, 1000), Point_2 (4000, 5000)); - Segment_2 s2 (Point_2 (4000, 0), Point_2 (4000, 5000)); - Segment_2 s3 (Point_2 (667, 1000), Point_2 (4000, 0)); + Segment_2 s1(Point_2(667, 1000), Point_2(4000, 5000)); + Segment_2 s2(Point_2(4000, 0), Point_2(4000, 5000)); + Segment_2 s3(Point_2(667, 1000), Point_2(4000, 0)); - Halfedge_handle e1 = arr.insert_in_face_interior (s1, arr.unbounded_face()); + Halfedge_handle e1 = arr.insert_in_face_interior(s1, arr.unbounded_face()); Vertex_handle v1 = e1->source(); Vertex_handle v2 = e1->target(); - Halfedge_handle e2 = arr.insert_from_right_vertex (s2, v2); + Halfedge_handle e2 = arr.insert_from_right_vertex(s2, v2); Vertex_handle v3 = e2->target(); - Halfedge_handle e3 = arr.insert_at_vertices (s3, v3, v1); + arr.insert_at_vertices(s3, v3, v1); // Step (b) - create additional two faces inside the triangle. - Point_2 p1 (4000, 3666), p2 (4000, 1000); - Segment_2 s4 (Point_2 (4000, 5000), p1); - Segment_2 s5 (p1, p2); - Segment_2 s6 (Point_2 (4000, 0), p2); + Point_2 p1(4000, 3666), p2(4000, 1000); + Segment_2 s4(Point_2(4000, 5000), p1); + Segment_2 s5(p1, p2); + Segment_2 s6(Point_2(4000, 0), p2); - Halfedge_handle e4 = arr.split_edge(e2, s4, Segment_2 (Point_2(4000, 0), p1)); + Halfedge_handle e4 = arr.split_edge(e2, s4, Segment_2(Point_2(4000, 0), p1)); Vertex_handle w1 = e4->target(); - Halfedge_handle e5 = arr.split_edge (e4->next(), s5, s6); + Halfedge_handle e5 = arr.split_edge(e4->next(), s5, s6); Vertex_handle w2 = e5->target(); Halfedge_handle e6 = e5->next(); - Segment_2 s7 (p1, Point_2 (3000, 2666)); - Segment_2 s8 (p2, Point_2 (3000, 1333)); - Segment_2 s9 (Point_2 (3000, 2666), Point_2 (2000, 1666)); - Segment_2 s10 (Point_2 (3000, 1333), Point_2 (2000, 1666)); - Segment_2 s11 (Point_2 (3000, 1333), Point_2 (3000, 2666)); + Segment_2 s7(p1, Point_2(3000, 2666)); + Segment_2 s8(p2, Point_2(3000, 1333)); + Segment_2 s9(Point_2(3000, 2666), Point_2(2000, 1666)); + Segment_2 s10(Point_2(3000, 1333), Point_2(2000, 1666)); + Segment_2 s11(Point_2(3000, 1333), Point_2(3000, 2666)); - Halfedge_handle e7 = arr.insert_from_right_vertex (s7, w1); + Halfedge_handle e7 = arr.insert_from_right_vertex(s7, w1); Vertex_handle v4 = e7->target(); - Halfedge_handle e8 = arr.insert_from_right_vertex (s8, w2); + Halfedge_handle e8 = arr.insert_from_right_vertex(s8, w2); Vertex_handle v5 = e8->target(); - Vertex_handle v6 = arr.insert_in_face_interior (Point_2 (2000, 1666), - e8->face()); + Vertex_handle v6 = + arr.insert_in_face_interior(Point_2(2000, 1666), e8->face()); - arr.insert_at_vertices (s9, v4, v6); - arr.insert_at_vertices (s10, v5, v6); - arr.insert_at_vertices (s11, v4, v5); + arr.insert_at_vertices(s9, v4, v6); + arr.insert_at_vertices(s10, v5, v6); + arr.insert_at_vertices(s11, v4, v5); - // Step (c) - remove and merge faces to form a single hole in the traingle. - arr.remove_edge (e7); - arr.remove_edge (e8); + // Step(c) - remove and merge faces to form a single hole in the traingle. + arr.remove_edge(e7); + arr.remove_edge(e8); - e5 = arr.merge_edge (e5, e6, Segment_2 (e5->source()->point(), - e6->target()->point())); - e2 = arr.merge_edge (e4, e5, s2); + e5 = arr.merge_edge(e5, e6, Segment_2(e5->source()->point(), + e6->target()->point())); + e2 = arr.merge_edge(e4, e5, s2); - print_arrangement (arr); + print_arrangement(arr); return 0; } diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/point_location_utils.h b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/point_location_utils.h index 9f513e9dda3..518abc8846c 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/point_location_utils.h +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/point_location_utils.h @@ -2,12 +2,12 @@ // Perform a point-location query and print the result. // template -void point_location_query - (const PointLocation& pl, - const typename PointLocation::Arrangement_2::Point_2& q) +void point_location_query(const PointLocation& pl, + const typename + PointLocation::Arrangement_2::Point_2& q) { // Perform the point-location query. - CGAL::Object obj = pl.locate (q); + CGAL::Object obj = pl.locate(q); // Print the result. typedef typename PointLocation::Arrangement_2 Arrangement_2; @@ -17,7 +17,7 @@ void point_location_query typename Arrangement_2::Face_const_handle f; std::cout << "The point (" << q << ") is located "; - if (CGAL::assign (f, obj)) + if (CGAL::assign(f, obj)) { // q is located inside a face: if (f->is_unbounded()) @@ -25,12 +25,12 @@ void point_location_query else std::cout << "inside a bounded face." << std::endl; } - else if (CGAL::assign (e, obj)) + else if (CGAL::assign(e, obj)) { // q is located on an edge: std::cout << "on an edge: " << e->curve() << std::endl; } - else if (CGAL::assign (v, obj)) + else if (CGAL::assign(v, obj)) { // q is located on a vertex: if (v->is_isolated()) @@ -42,20 +42,18 @@ void point_location_query { CGAL_error_msg( "Invalid object."); } - - return; } //----------------------------------------------------------------------------- // Perform a vertical ray-shooting query and print the result. // template -void vertical_ray_shooting_query - (const VerticalRayShoot& vrs, - const typename VerticalRayShoot::Arrangement_2::Point_2& q) +void vertical_ray_shooting_query(const VerticalRayShoot& vrs, + const typename + VerticalRayShoot::Arrangement_2::Point_2& q) { // Perform the point-location query. - CGAL::Object obj = vrs.ray_shoot_up (q); + CGAL::Object obj = vrs.ray_shoot_up(q); // Print the result. typedef typename VerticalRayShoot::Arrangement_2 Arrangement_2; @@ -65,12 +63,12 @@ void vertical_ray_shooting_query typename Arrangement_2::Face_const_handle f; std::cout << "Shooting up from (" << q << ") : "; - if (CGAL::assign (e, obj)) + if (CGAL::assign(e, obj)) { // We hit an edge: std::cout << "hit an edge: " << e->curve() << std::endl; } - else if (CGAL::assign (v, obj)) + else if (CGAL::assign(v, obj)) { // We hit a vertex: if (v->is_isolated()) @@ -78,10 +76,10 @@ void vertical_ray_shooting_query else std::cout << "hit a vertex: " << v->point() << std::endl; } - else if (CGAL::assign (f, obj)) + else if (CGAL::assign(f, obj)) { // We did not hit anything: - CGAL_assertion (f->is_unbounded()); + CGAL_assertion(f->is_unbounded()); std::cout << "hit nothing." << std::endl; } @@ -89,8 +87,6 @@ void vertical_ray_shooting_query { CGAL_error_msg( "Invalid object."); } - - return; } //----------------------------------------------------------------------------- @@ -100,22 +96,20 @@ void vertical_ray_shooting_query // coordinates. // template -void construct_segments_arr (Arrangement& arr) +void construct_segments_arr(Arrangement& arr) { typedef typename Arrangement::Point_2 Point_2; typedef typename Arrangement::X_monotone_curve_2 Segment_2; typedef typename Arrangement::Halfedge_handle Halfedge_handle; - Point_2 p0 (3,2), p1 (0,3), p2 (2,5), p3 (4,5), p4 (6,3), p5 (3,0); - Segment_2 s1 (p1, p2), s2 (p2, p3), s3 (p3, p4), s4 (p4, p5), s5 (p5, p1); + Point_2 p0(3,2), p1(0,3), p2(2,5), p3(4,5), p4(6,3), p5(3,0); + Segment_2 s1(p1, p2), s2(p2, p3), s3(p3, p4), s4(p4, p5), s5(p5, p1); - arr.insert_in_face_interior (p0, arr.unbounded_face()); + arr.insert_in_face_interior(p0, arr.unbounded_face()); - Halfedge_handle e1 = arr.insert_in_face_interior (s1, arr.unbounded_face()); - Halfedge_handle e2 = arr.insert_from_left_vertex (s2, e1->target()); - Halfedge_handle e3 = arr.insert_from_left_vertex (s3, e2->target()); - Halfedge_handle e4 = arr.insert_from_right_vertex (s4, e3->target()); - Halfedge_handle e5 = arr.insert_at_vertices (s5, e4->target(), e1->source()); - - return; + Halfedge_handle e1 = arr.insert_in_face_interior(s1, arr.unbounded_face()); + Halfedge_handle e2 = arr.insert_from_left_vertex(s2, e1->target()); + Halfedge_handle e3 = arr.insert_from_left_vertex(s3, e2->target()); + Halfedge_handle e4 = arr.insert_from_right_vertex(s4, e3->target()); + arr.insert_at_vertices(s5, e4->target(), e1->source()); }