From 3cd1e01f0b0d4fdb46f49ec640c389374ca2fe70 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 22 Feb 2018 23:16:55 +0000 Subject: Fix Cech with radius distance Add a meta generation script for off_file_generator git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3256 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fb13baa124ddc97c0dc61835ab0c72595d666155 --- src/common/include/gudhi/distance_functions.h | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/common/include') diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 3a5d1fd5..3ce51ad1 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -25,6 +25,8 @@ #include +#include + #include #include // for std::sqrt @@ -68,6 +70,37 @@ class Euclidean_distance { } }; +/** @brief Compute the squared radius between Points given by a range of coordinates. The points are assumed to + * have the same dimension. */ +class Radius_distance { + public: + // boost::range_value is not SFINAE-friendly so we cannot use it in the return type + template< typename Point > + typename std::iterator_traits::type>::value_type + operator()(const Point& p1, const Point& p2) const { + return Euclidean_distance()(p1, p2) / 2.; + } + // boost::range_value is not SFINAE-friendly so we cannot use it in the return type + template< typename Point_cloud, + typename Point_iterator = typename boost::range_const_iterator::type, + typename Point= typename std::iterator_traits::value_type, + typename Coordinate_iterator = typename boost::range_const_iterator::type, + typename Coordinate = typename std::iterator_traits::value_type> + Coordinate + operator()(const Point_cloud& point_cloud) const { + using Min_sphere = Miniball::Miniball>; + + //Min_sphere ms(point_cloud.begin()->end() - point_cloud.begin()->begin(), point_cloud.begin(),point_cloud.end()); + Min_sphere ms(point_cloud.end() - point_cloud.begin(), point_cloud.begin(),point_cloud.end()); +#ifdef DEBUG_TRACES + std::cout << "Radius on " << point_cloud.end() - point_cloud.begin() << " points = " + << std::sqrt(ms.squared_radius()) << std::endl; +#endif // DEBUG_TRACES + + return std::sqrt(ms.squared_radius()); + } +}; + } // namespace Gudhi #endif // DISTANCE_FUNCTIONS_H_ -- cgit v1.2.3