mirror of https://github.com/CGAL/cgal
Merge pull request #3142 from sgiraudot/Spatial_searching-Fix_disable_if-GF
Spatial Searching: bugfix disable_if
This commit is contained in:
commit
c8009c7250
|
|
@ -146,13 +146,17 @@ class Fuzzy_sphere< Search_traits_adapter<K,PM,Base_traits> >
|
||||||
public:
|
public:
|
||||||
// constructors
|
// constructors
|
||||||
Fuzzy_sphere(const SearchTraits& traits_=SearchTraits()):Base(traits_){}
|
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_) {}
|
// Constructor for any point type that is not `SearchTraits::Point_d`
|
||||||
Fuzzy_sphere(const typename SearchTraits::Point_d& center, FT radius, FT epsilon=FT(0),
|
template <typename Point> // boost::disable_if requires a template argument to work
|
||||||
const SearchTraits& traits_=SearchTraits(),
|
Fuzzy_sphere(const Point& center, FT radius, FT epsilon=FT(0),const SearchTraits& traits_=SearchTraits(),
|
||||||
typename boost::disable_if<
|
typename boost::disable_if<
|
||||||
boost::is_same<typename Base_traits::Point_d,
|
boost::is_same<typename SearchTraits::Point_d,
|
||||||
typename SearchTraits::Point_d> >::type* = 0)
|
Point> >::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_) {}
|
: Base(get(traits_.point_property_map(),center),radius,epsilon,traits_) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include <boost/mpl/has_xxx.hpp>
|
#include <boost/mpl/has_xxx.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
#include <boost/utility/enable_if.hpp>
|
||||||
|
|
||||||
namespace CGAL{
|
namespace CGAL{
|
||||||
|
|
||||||
|
|
@ -111,11 +112,23 @@ public:
|
||||||
// This is needed because of an undocumented requirement of
|
// This is needed because of an undocumented requirement of
|
||||||
// Orthogonal_k_neighbor_search and Orthogonal_incremental_neighbor_search:
|
// Orthogonal_k_neighbor_search and Orthogonal_incremental_neighbor_search:
|
||||||
// Traits::Construct_cartesian_const_iterator should be callable
|
// Traits::Construct_cartesian_const_iterator should be callable
|
||||||
// on the query point type
|
// on the query point type. If the query point type is the same as
|
||||||
typename Base_traits::Cartesian_const_iterator_d operator()(const typename Base_traits::Point_d& p) const
|
// Point_with_info, we disable it.
|
||||||
|
|
||||||
|
template <typename Point> // 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<Point_with_info,
|
||||||
|
Point> >::type* = 0
|
||||||
|
) const
|
||||||
{ return Base::operator() (p); }
|
{ return Base::operator() (p); }
|
||||||
|
|
||||||
typename Base_traits::Cartesian_const_iterator_d operator()(const typename Base_traits::Point_d& p, int) const
|
template <typename Point> // 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<Point_with_info,
|
||||||
|
Point> >::type* = 0
|
||||||
|
) const
|
||||||
{ return Base::operator() (p,0); }
|
{ return Base::operator() (p,0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include <CGAL/Simple_cartesian.h>
|
||||||
|
#include <CGAL/Kd_tree.h>
|
||||||
|
#include <CGAL/point_generators_2.h>
|
||||||
|
#include <CGAL/algorithm.h>
|
||||||
|
#include <CGAL/Fuzzy_sphere.h>
|
||||||
|
#include <CGAL/Search_traits_2.h>
|
||||||
|
#include <CGAL/property_map.h>
|
||||||
|
|
||||||
|
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||||
|
typedef Kernel::Point_2 Point_2;
|
||||||
|
typedef CGAL::Random_points_in_disc_2<Point_2> Random_points;
|
||||||
|
|
||||||
|
typedef CGAL::Identity_property_map<Point_2> Point_map;
|
||||||
|
typedef CGAL::Search_traits_2<Kernel> Search_base;
|
||||||
|
typedef CGAL::Search_traits_adapter<Point_2, Point_map, Search_base> Search_traits;
|
||||||
|
typedef CGAL::Fuzzy_sphere<Search_traits> Fuzzy_circle;
|
||||||
|
typedef CGAL::Kd_tree<Search_traits> Tree;
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
Random_points rdpts;
|
||||||
|
std::vector<Point_2> 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<Point_2> 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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue