#include #include #include #include #include #include #include #include #include #include #include "Point_with_info.h" #ifdef TWO typedef CGAL::Simple_cartesian K; typedef K::Point_2 Point; typedef CGAL::Creator_uniform_2 Creator; typedef CGAL::Random_points_in_disc_2 Random_points; typedef CGAL::Search_traits_2 TreeTraits; typedef CGAL::Euclidean_distance Distance; #else typedef CGAL::Simple_cartesian K; typedef K::Point_3 Point; typedef CGAL::Creator_uniform_3 Creator; typedef CGAL::Random_points_in_sphere_3 Random_points; typedef CGAL::Search_traits_3 TreeTraits; typedef CGAL::Euclidean_distance Distance; #endif typedef Point_with_info_helper::type Point_with_info; typedef Point_property_map Ppmap; typedef CGAL::Search_traits_adapter Traits_with_info; typedef CGAL::Distance_adapter Distance_adapter; typedef std::vector Vector; template struct Splitter_test { typedef CGAL::Orthogonal_incremental_neighbor_search Orthogonal_incremental_neighbor_search; typedef typename Orthogonal_incremental_neighbor_search::iterator NN_iterator; typedef typename Orthogonal_incremental_neighbor_search::Tree Tree; typedef typename Orthogonal_incremental_neighbor_search::Point_with_transformed_distance Point_with_transformed_distance; bool operator()(Vector points, Point query) { Vector points2; Tree t( boost::make_transform_iterator(points.begin(),Create_point_with_info()), boost::make_transform_iterator(points.end(),Create_point_with_info()) ); Orthogonal_incremental_neighbor_search oins(t, query, 0.0, true); typename Orthogonal_incremental_neighbor_search::iterator it = oins.begin(); Point_with_transformed_distance pd = *it; points2.push_back(get_point(pd.first)); if(CGAL::squared_distance(query,get_point(pd.first)) != pd.second){ std::cout << CGAL::squared_distance(query,get_point(pd.first)) << " != " << pd.second << std::endl; } assert(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) == pd.second); it++; for(; it != oins.end();it++){ Point_with_transformed_distance qd = *it; assert(pd.second <= qd.second); pd = qd; points2.push_back(get_point(pd.first)); if(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) != pd.second){ std::cout << CGAL::squared_distance(query,get_point(pd.first)) << " != " << pd.second << std::endl; } assert(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) == pd.second); } std::sort(points.begin(),points.end()); std::sort(points2.begin(),points2.end()); assert(points.size() == points2.size()); assert(points == points2); return true; } }; int main() { // We enforce IEEE double precision as we compare a distance // in a register with a distance in memory CGAL::Set_ieee_double_precision pfr; Vector points; Random_points g( 150.0); CGAL::cpp11::copy_n( g, 1000, std::back_inserter(points)); g++; Point query = *g; { std::cout << "Testing Sliding_midpoint" << std::endl; Splitter_test,Distance > st; st(points,query); Splitter_test,Distance_adapter > sti; sti(points,query); } { std::cout << "Testing Sliding_fair" << std::endl; Splitter_test,Distance > st; st(points,query); Splitter_test,Distance_adapter > sti; sti(points,query); } { std::cout << "Testing Fair" << std::endl; Splitter_test,Distance > st; st(points,query); Splitter_test,Distance_adapter > sti; sti(points,query); } { std::cout << "Testing Median_of_rectangle" << std::endl; Splitter_test,Distance > st; st(points,query); Splitter_test,Distance_adapter > sti; sti(points,query); } { std::cout << "Testing Midpoint_of_rectangle" << std::endl; Splitter_test,Distance > st; st(points,query); Splitter_test,Distance_adapter > sti; sti(points,query); } { std::cout << "Testing Midpoint_of_max_spread" << std::endl; Splitter_test,Distance > st; st(points,query); Splitter_test,Distance_adapter > sti; sti(points,query); } { std::cout << "Testing Median_of_max_spread" << std::endl; Splitter_test,Distance > st; st(points,query); Splitter_test,Distance_adapter > sti; sti(points,query); } std::cout << "done" << std::endl; return 0; }