From 7b0c4e087b502856125c7357ec8afd726539f738 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Fri, 1 Jun 2018 15:50:54 +0200 Subject: [PATCH 1/4] Bugfix: make disable_if work using template and add it to Search_traits_adapter --- Spatial_searching/include/CGAL/Fuzzy_sphere.h | 18 +++++++++++------- .../include/CGAL/Search_traits_adapter.h | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Spatial_searching/include/CGAL/Fuzzy_sphere.h b/Spatial_searching/include/CGAL/Fuzzy_sphere.h index 96e69f05a04..acdf95c2562 100644 --- a/Spatial_searching/include/CGAL/Fuzzy_sphere.h +++ b/Spatial_searching/include/CGAL/Fuzzy_sphere.h @@ -144,14 +144,18 @@ class Fuzzy_sphere< Search_traits_adapter > typedef typename Base_traits::FT FT; public: // constructors - Fuzzy_sphere(const SearchTraits& traits_=SearchTraits()):Base(traits_){} - Fuzzy_sphere(const typename Base_traits::Point_d& center, FT radius, FT epsilon=FT(0),const SearchTraits& traits_=SearchTraits()) : - Base(center,radius,epsilon,traits_) {} - Fuzzy_sphere(const typename SearchTraits::Point_d& center, FT radius, FT epsilon=FT(0), - const SearchTraits& traits_=SearchTraits(), + Fuzzy_sphere(const SearchTraits& traits_=SearchTraits()):Base(traits_){}; + + // Constructor for any point type that is not `SearchTraits::Point_d` + template // boost::disable_if requires a template argument to work + Fuzzy_sphere(const Point& center, FT radius, FT epsilon=FT(0),const SearchTraits& traits_=SearchTraits(), typename boost::disable_if< - boost::is_same >::type* = 0) + boost::is_same >::type* = 0) + : Base(center,radius,epsilon,traits_) {} + + Fuzzy_sphere(const typename SearchTraits::Point_d& center, FT radius, FT epsilon=FT(0), + const SearchTraits& traits_=SearchTraits()) : Base(get(traits_.point_property_map(),center),radius,epsilon,traits_) {} }; diff --git a/Spatial_searching/include/CGAL/Search_traits_adapter.h b/Spatial_searching/include/CGAL/Search_traits_adapter.h index 60f7703255a..ef174255ceb 100644 --- a/Spatial_searching/include/CGAL/Search_traits_adapter.h +++ b/Spatial_searching/include/CGAL/Search_traits_adapter.h @@ -109,11 +109,23 @@ public: // This is needed because of an undocumented requirement of // Orthogonal_k_neighbor_search and Orthogonal_incremental_neighbor_search: // Traits::Construct_cartesian_const_iterator should be callable - // on the query point type - typename Base_traits::Cartesian_const_iterator_d operator()(const typename Base_traits::Point_d& p) const + // on the query point type. If the query point type is the same as + // Point_with_info, we disable it. + + template // boost::disable_if requires a template argument to work + typename Base_traits::Cartesian_const_iterator_d operator()(const Point& p, + typename boost::disable_if< + boost::is_same >::type* = 0 + ) const { return Base::operator() (p); } - typename Base_traits::Cartesian_const_iterator_d operator()(const typename Base_traits::Point_d& p, int) const + template // boost::disable_if requires a template argument to work + typename Base_traits::Cartesian_const_iterator_d operator()(const Point& p, int, + typename boost::disable_if< + boost::is_same >::type* = 0 + ) const { return Base::operator() (p,0); } }; From ff5120e296c8183456100036606ddd05ab1b8f79 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 4 Jun 2018 10:36:13 +0200 Subject: [PATCH 2/4] Add test of Search traits adapter with Identity map --- ...earch_traits_adapter_with_identity_map.cpp | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Spatial_searching/test/Spatial_searching/Search_traits_adapter_with_identity_map.cpp diff --git a/Spatial_searching/test/Spatial_searching/Search_traits_adapter_with_identity_map.cpp b/Spatial_searching/test/Spatial_searching/Search_traits_adapter_with_identity_map.cpp new file mode 100644 index 00000000000..00e66ca1d0f --- /dev/null +++ b/Spatial_searching/test/Spatial_searching/Search_traits_adapter_with_identity_map.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian Kernel; +typedef Kernel::Point_2 Point_2; +typedef CGAL::Random_points_in_disc_2 Random_points; + +typedef CGAL::Identity_property_map Point_map; +typedef CGAL::Search_traits_2 Search_base; +typedef CGAL::Search_traits_adapter Search_traits; +typedef CGAL::Fuzzy_sphere Fuzzy_circle; +typedef CGAL::Kd_tree Tree; + +int main () +{ + Random_points rdpts; + std::vector pts; + for (std::size_t i = 0; i < 50; ++ i) + pts.push_back (*(rdpts ++)); + + Tree tree (pts.begin(), pts.end()); + + Point_2 center(0., 0.); + Fuzzy_circle circle (center, 0.5); + std::vector result; + tree.search(std::back_inserter(result), circle); + std::cout << "The points in the fuzzy circle centered at (0., 0.) "; + std::cout << "with fuzzy radius (0.5) are: " << std::endl; + for (std::size_t i = 0; i < result.size(); ++ i) + std::cout << " * " << result[i] << std::endl; + + return 0; +} From e5ff062052ce65184056029e18ec43812e9d5374 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 4 Jun 2018 10:48:08 +0200 Subject: [PATCH 3/4] Remove extra semicolon --- Spatial_searching/include/CGAL/Fuzzy_sphere.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spatial_searching/include/CGAL/Fuzzy_sphere.h b/Spatial_searching/include/CGAL/Fuzzy_sphere.h index acdf95c2562..b99fa011bc9 100644 --- a/Spatial_searching/include/CGAL/Fuzzy_sphere.h +++ b/Spatial_searching/include/CGAL/Fuzzy_sphere.h @@ -144,7 +144,7 @@ class Fuzzy_sphere< Search_traits_adapter > typedef typename Base_traits::FT FT; public: // constructors - Fuzzy_sphere(const SearchTraits& traits_=SearchTraits()):Base(traits_){}; + Fuzzy_sphere(const SearchTraits& traits_=SearchTraits()):Base(traits_){} // Constructor for any point type that is not `SearchTraits::Point_d` template // boost::disable_if requires a template argument to work From 45afed121c6507a12047c3df2921f81085f20f6e Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 6 Jun 2018 08:15:54 +0200 Subject: [PATCH 4/4] Include enable_if.hpp header --- Spatial_searching/include/CGAL/Search_traits_adapter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Spatial_searching/include/CGAL/Search_traits_adapter.h b/Spatial_searching/include/CGAL/Search_traits_adapter.h index ef174255ceb..1936bb5d48b 100644 --- a/Spatial_searching/include/CGAL/Search_traits_adapter.h +++ b/Spatial_searching/include/CGAL/Search_traits_adapter.h @@ -31,6 +31,7 @@ #include #include +#include namespace CGAL{