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 731d80e876b..c42203bcb9a 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 @@ -9,8 +9,6 @@ print_point_location (const typename Arrangement_::Point_2& q, typename CGAL::Arr_point_location_result::Type obj) { - CGAL_assertion(obj); - typedef Arrangement_ Arrangement_2; typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; @@ -22,13 +20,13 @@ print_point_location const Face_const_handle* f; std::cout << "The point (" << q << ") is located "; - if (f = boost::get(&(*obj))) // located inside a face + if (f = boost::get(&obj)) // located inside a face std::cout << "inside " << (((*f)->is_unbounded()) ? "the unbounded" : "a bounded") << " face." << std::endl; - else if (e = boost::get(&(*obj))) // located on an edge + else if (e = boost::get(&obj)) // located on an edge std::cout << "on an edge: " << (*e)->curve() << std::endl; - else if (v = boost::get(&(*obj))) // located on a vertex + else if (v = boost::get(&obj)) // located on a vertex std::cout << "on " << (((*v)->is_isolated()) ? "an isolated" : "a") << " vertex: " << (*v)->point() << std::endl; else CGAL_error_msg("Invalid object."); @@ -62,7 +60,6 @@ void shoot_vertical_ray(const RayShoot& vrs, // Perform the point-location query. typename Vertical_ray_shooting::result_type obj = vrs.ray_shoot_up(q); - CGAL_assertion(obj); // Print the result. typedef typename Vertical_ray_shooting::Arrangement_2 Arrangement_2; @@ -75,12 +72,12 @@ void shoot_vertical_ray(const RayShoot& vrs, const Face_const_handle* f; std::cout << "Shooting up from (" << q << ") : "; - if (v = boost::get(&(*obj))) // we hit a vertex + if (v = boost::get(&obj)) // we hit a vertex std::cout << "hit " << (((*v)->is_isolated()) ? "an isolated" : "a") << " vertex: " << (*v)->point() << std::endl; - else if (e = boost::get(&(*obj))) // we hit an edge + else if (e = boost::get(&obj)) // we hit an edge std::cout << "hit an edge: " << (*e)->curve() << std::endl; - else if (f = boost::get(&(*obj))) { // we hit nothing + else if (f = boost::get(&obj)) { // we hit nothing CGAL_assertion((*f)->is_unbounded()); std::cout << "hit nothing." << std::endl; } diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/point_location.cpp b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/point_location.cpp index c1d10345848..16a777d8770 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/point_location.cpp +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/point_location.cpp @@ -45,37 +45,39 @@ typedef Arrangement_2::Edge_const_iterator Edge_const_iterator; typedef Arrangement_2::Vertex_const_iterator Vertex_const_iterator; typedef CGAL::Arr_naive_point_location - Naive_point_location; + Naive_point_location; typedef CGAL::Arr_simple_point_location - Simple_point_location; + Simple_point_location; typedef CGAL::Arr_walk_along_line_point_location - Walk_point_location; + Walk_point_location; typedef CGAL::Arr_landmarks_point_location - Lm_point_location; + Lm_point_location; typedef CGAL::Arr_random_landmarks_generator - Random_lm_generator; + Random_lm_generator; typedef CGAL::Arr_landmarks_point_location - Lm_random_point_location; + Lm_random_point_location; typedef CGAL::Arr_grid_landmarks_generator - Grid_lm_generator; + Grid_lm_generator; typedef CGAL::Arr_landmarks_point_location - Lm_grid_point_location; + Lm_grid_point_location; typedef CGAL::Arr_halton_landmarks_generator - Halton_lm_generator; + Halton_lm_generator; typedef CGAL::Arr_landmarks_point_location - Lm_halton_point_location; + Lm_halton_point_location; typedef CGAL::Arr_middle_edges_landmarks_generator - Middle_edges_generator; -typedef CGAL::Arr_landmarks_point_location - Lm_middle_edges_point_location; + Middle_edges_generator; +typedef CGAL::Arr_landmarks_point_location + Lm_middle_edges_point_location; typedef CGAL::Arr_landmarks_specified_points_generator - Specified_points_generator; -typedef CGAL::Arr_landmarks_point_location - Lm_specified_points_point_location; + Specified_points_generator; +typedef CGAL::Arr_landmarks_point_location + Lm_specified_points_point_location; -//typedef CGAL::Arr_triangulation_point_location -// Lm_triangulation_point_location; +// typedef CGAL::Arr_triangulation_point_location +// Lm_triangulation_point_location; // ===> Add new point location type here <=== @@ -90,250 +92,234 @@ typedef Objects_vector::iterator Object_iterator; #define NUM_OF_POINT_LOCATION_STRATEGIES 9 /*! */ -int check_point_location (Arrangement_2 &arr, Points_list &plist) +template +int check_point_location(Arrangement_2& arr, + InputIterator begin, InputIterator end) { + typedef InputIterator Input_iterator; //init - all point locations - CGAL::Timer timer; + CGAL::Timer timer; - Naive_point_location naive_pl (arr); // 0 + Naive_point_location naive_pl(arr); // 0 - Simple_point_location simple_pl (arr); // 1 - Walk_point_location walk_pl (arr); // 2 + Simple_point_location simple_pl(arr); // 1 + Walk_point_location walk_pl(arr); // 2 timer.reset(); timer.start(); - Lm_point_location lm_pl (arr); // 3 + Lm_point_location lm_pl(arr); // 3 timer.stop(); - std::cout << "Lm (vert) construction took " << timer.time() < Add new point location instance here. <=== - CGAL::Object obj; - Objects_vector objs[NUM_OF_POINT_LOCATION_STRATEGIES]; - Object_iterator ob_iter[NUM_OF_POINT_LOCATION_STRATEGIES]; - Arrangement_2::Vertex_const_handle vh_ref, vh_curr; - Arrangement_2::Halfedge_const_handle hh_ref, hh_curr; - Arrangement_2::Face_const_handle fh_ref, fh_curr; + Objects_vector objs[NUM_OF_POINT_LOCATION_STRATEGIES]; + Object_iterator ob_iter[NUM_OF_POINT_LOCATION_STRATEGIES]; + Arrangement_2::Halfedge_const_handle hh_curr; - Point_2 q; - Point_iterator piter; + Input_iterator piter; - //LOCATE the points in the list using all PL strategies + // LOCATE the points in the list using all PL strategies - //std::cout << "Time in seconds" < Add a call to operate the the new point location. <=== - //END LOCATION + // END LOCATION int pls_num = NUM_OF_POINT_LOCATION_STRATEGIES; int pl_index; int result = 0; //init all obejct iterators - for (pl_index=0; pl_indexcurve() << std::endl; - for (int pl_index=1; pl_indexcurve() << std::endl; + for (int pl_index = 1; pl_index < pls_num; ++pl_index) { + if (! CGAL::assign(hh_curr, ob_iter[pl_index][qi])) { std::cout << "Error in point location number " << pl_index; + Arrangement_2::Face_const_handle fh_curr; if (CGAL::assign(fh_curr, ob_iter[pl_index][qi])) - { - std::cout << ", a face returned instead of an halfedge"<< std::endl; - } + std::cout << ", a face returned instead of an halfedge" + << std::endl; else if (CGAL::assign(hh_curr, ob_iter[pl_index][qi])) - { - std::cout << ", a vertex returned instead of an halfedge"<< std::endl; - } + std::cout << ", a vertex returned instead of an halfedge" + << std::endl; else - { - std::cout << ", an unknowen object returned instead of an halfedge"<< std::endl; - } + std::cout << ", an unknowen object returned instead of an halfedge" + << std::endl; result = -1; } - else if ((hh_curr != hh_ref) && (hh_curr->twin() != hh_ref)) - { + else if ((hh_curr != hh_ref) && (hh_curr->twin() != hh_ref)) { std::cout << "Error: point location number " - << pl_index << " return a different halfedge"<< std::endl; + << pl_index << " return a different halfedge" << std::endl; std::cout << "Halfedge (curr): "<< hh_curr->curve() << std::endl; result = -1; } } } - //assign object to a vertex - else if (CGAL::assign (vh_ref, ob_iter[0][qi])) - { - for (int pl_index=1; pl_indexpoint() << std::endl; } - - else - { + else { std::cout << "Illegal point-location result." << std::endl; result = -1; } @@ -418,12 +390,11 @@ int check_point_location (Arrangement_2 &arr, Points_list &plist) } /*! */ -int read_points(const char * points_filename, Points_list &plist) +int read_points(const char* points_filename, Points_list& plist) { //read points from file into list std::ifstream inp_pnt_file(points_filename); - if (!inp_pnt_file.is_open()) - { + if (!inp_pnt_file.is_open()) { std::cerr << "Cannot open file " << points_filename << "!" << std::endl; return (-1); } @@ -455,36 +426,34 @@ bool test(const char* curves_filename, const char* points_filename) timer.reset(); timer.start(); //START Arrangement_2 arr; - insert (arr, curve_list.begin(), curve_list.end()); + insert(arr, curve_list.begin(), curve_list.end()); timer.stop(); ///END std::cout << "Arrangement aggregate construction took " - << timer.time() <