diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/batched_point_location.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/batched_point_location.cpp index 5f3e5015f9b..87c3864616f 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/batched_point_location.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/batched_point_location.cpp @@ -10,60 +10,53 @@ #include "point_location_utils.h" -typedef CGAL::MP_Float Number_type; -typedef CGAL::Cartesian Kernel; -typedef CGAL::Arr_segment_traits_2 Traits_2; -typedef Traits_2::Point_2 Point_2; -typedef CGAL::Arrangement_2 Arrangement_2; -typedef std::pair Query_result; +typedef CGAL::MP_Float Number_type; +typedef CGAL::Cartesian Kernel; +typedef CGAL::Arr_segment_traits_2 Traits_2; +typedef Traits_2::Point_2 Point_2; +typedef CGAL::Arrangement_2 Arrangement_2; +typedef CGAL::Arr_point_location_result Point_location_result; +typedef std::pair Query_result; + +typedef Arrangement_2::Vertex_const_handle Vertex_const_handle; +typedef Arrangement_2::Halfedge_const_handle Halfedge_const_handle; +typedef Arrangement_2::Face_const_handle Face_const_handle; int main () { // Construct the arrangement. Arrangement_2 arr; - - construct_segments_arr (arr); + construct_segments_arr(arr); // Perform a batched point-location query. - std::list query_points; + std::list points; + points.push_back(Point_2(1, 4)); + points.push_back(Point_2(4, 3)); + points.push_back(Point_2(6, 3)); + points.push_back(Point_2(3, 2)); + points.push_back(Point_2(5, 2)); + points.push_back(Point_2(1, 0)); std::list results; - - query_points.push_back (Point_2 (1, 4)); - query_points.push_back (Point_2 (4, 3)); - query_points.push_back (Point_2 (6, 3)); - query_points.push_back (Point_2 (3, 2)); - query_points.push_back (Point_2 (5, 2)); - query_points.push_back (Point_2 (1, 0)); - - locate (arr, query_points.begin(), query_points.end(), - std::back_inserter (results)); + locate(arr, points.begin(), points.end(), std::back_inserter(results)); // Print the results. - std::list::const_iterator res_iter; - Arrangement_2::Vertex_const_handle v; - Arrangement_2::Halfedge_const_handle e; - Arrangement_2::Face_const_handle f; + const Vertex_const_handle* v; + const Halfedge_const_handle* e; + const Face_const_handle* f; - for (res_iter = results.begin(); res_iter != results.end(); ++res_iter) { - std::cout << "The point (" << res_iter->first << ") is located "; - if (CGAL::assign (f, res_iter->second)) { - // The current qeury point is located inside a face: - if (f->is_unbounded()) - std::cout << "inside the unbounded face." << std::endl; - else - std::cout << "inside a bounded face." << std::endl; - } - else if (CGAL::assign (e, res_iter->second)) { - // The current qeury point is located on an edge: - std::cout << "on an edge: " << e->curve() << std::endl; - } - else if (CGAL::assign (v, res_iter->second)) { - // The current qeury point is located on a vertex: - if (v->is_isolated()) - std::cout << "on an isolated vertex: " << v->point() << std::endl; - else - std::cout << "on a vertex: " << v->point() << std::endl; - } + std::list::const_iterator it; + for (it = results.begin(); it != results.end(); ++it) { + std::cout << "The point (" << it->first << ") is located "; + if (f = boost::get(&(it->second))) // inside a face + std::cout << "inside " + << (((*f)->is_unbounded()) ? "the unbounded" : "a bounded") + << " face." << std::endl; + else if (e = boost::get(&(it->second))) // on an edge + std::cout << "on an edge: " << (*e)->curve() << std::endl; + else if (v = boost::get(&(it->second))) // on a vertex + std::cout << "on " + << (((*v)->is_isolated()) ? "an isolated" : "a") + << " vertex: " << (*v)->point() << std::endl; } return 0;