diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-02-22 23:16:55 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-02-22 23:16:55 +0000 |
commit | 3cd1e01f0b0d4fdb46f49ec640c389374ca2fe70 (patch) | |
tree | afe2bec947f098942d021e62d62546d56b9acabd /src/common/include | |
parent | d57e3dfbf15f8aaa3afa097a4e3ed49cd23d26ea (diff) |
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
Diffstat (limited to 'src/common/include')
-rw-r--r-- | src/common/include/gudhi/distance_functions.h | 33 |
1 files changed, 33 insertions, 0 deletions
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 <gudhi/Debug_utils.h> +#include <Miniball/Miniball.hpp> + #include <boost/range/metafunctions.hpp> #include <cmath> // 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<typename boost::range_iterator<Point>::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<Point_cloud>::type, + typename Point= typename std::iterator_traits<Point_iterator>::value_type, + typename Coordinate_iterator = typename boost::range_const_iterator<Point>::type, + typename Coordinate = typename std::iterator_traits<Coordinate_iterator>::value_type> + Coordinate + operator()(const Point_cloud& point_cloud) const { + using Min_sphere = Miniball::Miniball<Miniball::CoordAccessor<Point_iterator, Coordinate_iterator>>; + + //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_ |