diff options
-rw-r--r-- | src/Cech_complex/benchmark/cech_complex_benchmark.cpp | 2 | ||||
-rw-r--r-- | src/Cech_complex/example/cech_complex_step_by_step.cpp | 2 | ||||
-rw-r--r-- | src/Cech_complex/include/gudhi/Cech_complex.h | 2 | ||||
-rw-r--r-- | src/Cech_complex/include/gudhi/Cech_complex/Cech_kernel.h | 149 | ||||
-rw-r--r-- | src/Cech_complex/test/test_cech_complex.cpp | 2 | ||||
-rw-r--r-- | src/Cech_complex/utilities/cech_persistence.cpp | 2 | ||||
-rw-r--r-- | src/common/include/gudhi/distance_functions.h | 83 |
7 files changed, 154 insertions, 88 deletions
diff --git a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp index 4a1aa06e..cfeb0725 100644 --- a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp +++ b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp @@ -9,7 +9,7 @@ */ #include <gudhi/Points_off_io.h> -#include <gudhi/distance_functions.h> +#include <gudhi/Cech_complex/Cech_kernel.h> #include <gudhi/graph_simplicial_complex.h> #include <gudhi/Clock.h> #include <gudhi/Rips_complex.h> diff --git a/src/Cech_complex/example/cech_complex_step_by_step.cpp b/src/Cech_complex/example/cech_complex_step_by_step.cpp index 44e7f945..2d8321b1 100644 --- a/src/Cech_complex/example/cech_complex_step_by_step.cpp +++ b/src/Cech_complex/example/cech_complex_step_by_step.cpp @@ -9,7 +9,7 @@ */ #include <gudhi/graph_simplicial_complex.h> -#include <gudhi/distance_functions.h> +#include <gudhi/Cech_complex/Cech_kernel.h> #include <gudhi/Simplex_tree.h> #include <gudhi/Points_off_io.h> diff --git a/src/Cech_complex/include/gudhi/Cech_complex.h b/src/Cech_complex/include/gudhi/Cech_complex.h index 32a78aec..7bbf97d1 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex.h +++ b/src/Cech_complex/include/gudhi/Cech_complex.h @@ -11,7 +11,7 @@ #ifndef CECH_COMPLEX_H_ #define CECH_COMPLEX_H_ -#include <gudhi/distance_functions.h> // for Gudhi::Minimal_enclosing_ball_radius +#include <gudhi/Cech_complex/Cech_kernel.h> // for Gudhi::Minimal_enclosing_ball_radius #include <gudhi/graph_simplicial_complex.h> // for Gudhi::Proximity_graph #include <gudhi/Debug_utils.h> // for GUDHI_CHECK #include <gudhi/Cech_complex_blocker.h> // for Gudhi::cech_complex::Cech_blocker diff --git a/src/Cech_complex/include/gudhi/Cech_complex/Cech_kernel.h b/src/Cech_complex/include/gudhi/Cech_complex/Cech_kernel.h new file mode 100644 index 00000000..93af90d2 --- /dev/null +++ b/src/Cech_complex/include/gudhi/Cech_complex/Cech_kernel.h @@ -0,0 +1,149 @@ +/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + * Author(s): Hind Montassif + * + * Copyright (C) 2021 Inria + * + * Modification(s): + * - YYYY/MM Author: Description of the modification + */ + +#ifndef CECH_KERNEL_H_ +#define CECH_KERNEL_H_ + +#include <CGAL/Epeck_d.h> + +#include <cmath> // for std::sqrt + +namespace Gudhi { + +// namespace cech_complex { + +/** @brief Compute the radius of the minimal enclosing ball between Points given by a range of coordinates. + * The points are assumed to have the same dimension. */ +class Minimal_enclosing_ball_radius { + public: + /** \brief Enclosing ball radius from two points using CGAL. + * + * @param[in] point_1 + * @param[in] point_2 + * @return Enclosing ball radius for the two points. + * \tparam Point must be a Kernel::Point_d from CGAL. + * + */ + template< typename Kernel = CGAL::Epeck_d<CGAL::Dynamic_dimension_tag>, + typename Point= typename Kernel::Point_d> + double operator()(const Point& point_1, const Point& point_2) const { + Kernel kernel_; + return std::sqrt(CGAL::to_double(kernel_.squared_distance_d_object()(point_1, point_2))) / 2.; + } + + /** \brief Minimal_enclosing_ball_radius from two points. + * + * @param[in] point_1 First point. + * @param[in] point_2 second point. + * @return The minimal enclosing ball radius for the two points (aka. Euclidean distance / 2.). + * + * \tparam Point must be a range of Cartesian coordinates. + * + */ +// template< typename Point > +// typename std::iterator_traits<typename boost::range_iterator<Point>::type>::value_type +// operator()(const Point& point_1, const Point& point_2) const { +// std::clog << "#" << *point_1.begin() << "##" << *point_2.begin() << std::endl; +// return Euclidean_distance()(point_1, point_2) / 2.; +// } + + /** \brief Enclosing ball radius from a point cloud using CGAL. + * + * @param[in] point_cloud The points. + * @return Enclosing ball radius for the points. + * \tparam Point_cloud must be a range of Kernel::Point_d points from CGAL. + * + */ + template< typename Kernel = CGAL::Epeck_d<CGAL::Dynamic_dimension_tag>, + typename Point= typename Kernel::Point_d, + typename Point_cloud = std::vector<Point>> + double operator()(const Point_cloud& point_cloud) const { + Kernel kernel_; + return std::sqrt(CGAL::to_double(kernel_.compute_squared_radius_d_object()(point_cloud.begin(), point_cloud.end()))); + } + + /** \brief Minimal_enclosing_ball_radius from a point cloud. + * + * @param[in] point_cloud The points. + * @return The minimal enclosing ball radius for the points. + * + * \tparam Point_cloud must be a range of points with Cartesian coordinates. + * Point_cloud is a range over a range of Coordinate. + * + */ +// 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(boost::size(*point_cloud.begin()), point_cloud.begin(), point_cloud.end()); +// #ifdef DEBUG_TRACES +// std::clog << "Minimal_enclosing_ball_radius = " << std::sqrt(ms.squared_radius()) << " | nb points = " +// << boost::size(point_cloud) << " | dimension = " +// << boost::size(*point_cloud.begin()) << std::endl; +// #endif // DEBUG_TRACES +// +// return std::sqrt(ms.squared_radius()); +// } +}; + +/** + * \class Cech_kernel + * \brief Cech complex kernel container. + * + * \details + * The Cech complex kernel container stores CGAL Kernel and dispatch basic computations. + */ + +// template < typename Kernel > +// class Cech_kernel<Kernel> { +// private: +// // Kernel for functions access. +// Kernel kernel_; +// public: +// using Point_d = typename Kernel::Point_d; +// // Numeric type of coordinates in the kernel +// using FT = typename Kernel::FT; +// // Sphere is a pair of point and squared radius. +// using Sphere = typename std::pair<Point_d, FT>; +// +// int get_dimension(const Point_d& p0) const { +// return kernel_.point_dimension_d_object()(p0); +// } +// +// template<class PointIterator> +// Sphere get_sphere(PointIterator begin, PointIterator end) const { +// Point_d c = kernel_.construct_circumcenter_d_object()(begin, end); +// FT r = kernel_.squared_distance_d_object()(c, *begin); +// return std::make_pair(std::move(c), std::move(r)); +// } +// +// template<class PointIterator> +// FT get_squared_radius(PointIterator begin, PointIterator end) const { +// return kernel_.compute_squared_radius_d_object()(begin, end); +// } +// +// FT get_squared_radius(const Sphere& sph) const { +// return sph.second; +// } +// }; + + +//} // namespace cech_complex + +// namespace cechcomplex = cech_complex; + +} // namespace Gudhi + +#endif // CECH_KERNEL_H_ diff --git a/src/Cech_complex/test/test_cech_complex.cpp b/src/Cech_complex/test/test_cech_complex.cpp index 51b466da..7d8c3c22 100644 --- a/src/Cech_complex/test/test_cech_complex.cpp +++ b/src/Cech_complex/test/test_cech_complex.cpp @@ -22,7 +22,7 @@ // to construct Cech_complex from a OFF file of points #include <gudhi/Points_off_io.h> #include <gudhi/Simplex_tree.h> -#include <gudhi/distance_functions.h> +#include <gudhi/Cech_complex/Cech_kernel.h> #include <gudhi/Unitary_tests_utils.h> #include <CGAL/Epeck_d.h> // For EXACT or SAFE version diff --git a/src/Cech_complex/utilities/cech_persistence.cpp b/src/Cech_complex/utilities/cech_persistence.cpp index 0c945cad..ccf63e3e 100644 --- a/src/Cech_complex/utilities/cech_persistence.cpp +++ b/src/Cech_complex/utilities/cech_persistence.cpp @@ -9,7 +9,7 @@ */ #include <gudhi/Cech_complex.h> -#include <gudhi/distance_functions.h> +#include <gudhi/Cech_complex/Cech_kernel.h> #include <gudhi/Simplex_tree.h> #include <gudhi/Persistent_cohomology.h> #include <gudhi/Points_off_io.h> diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index a8ee4a75..5e5a1e31 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -13,13 +13,9 @@ #include <gudhi/Debug_utils.h> -#include <gudhi/Miniball.hpp> - #include <boost/range/metafunctions.hpp> #include <boost/range/size.hpp> -#include <CGAL/Epeck_d.h> - #include <cmath> // for std::sqrt #include <type_traits> // for std::decay #include <iterator> // for std::begin, std::end @@ -61,85 +57,6 @@ class Euclidean_distance { } }; -/** @brief Compute the radius of the minimal enclosing ball between Points given by a range of coordinates. - * The points are assumed to have the same dimension. */ -class Minimal_enclosing_ball_radius { - public: - /** \brief Enclosing ball radius from two points using CGAL. - * - * @param[in] point_1 - * @param[in] point_2 - * @return Enclosing ball radius for the two points. - * \tparam Point must be a Kernel::Point_d from CGAL. - * - */ - template< typename Kernel = CGAL::Epeck_d<CGAL::Dynamic_dimension_tag>, - typename Point= typename Kernel::Point_d> - double operator()(const Point& point_1, const Point& point_2) const { - Kernel kernel_; - return std::sqrt(CGAL::to_double(kernel_.squared_distance_d_object()(point_1, point_2))) / 2.; - } - - /** \brief Minimal_enclosing_ball_radius from two points. - * - * @param[in] point_1 First point. - * @param[in] point_2 second point. - * @return The minimal enclosing ball radius for the two points (aka. Euclidean distance / 2.). - * - * \tparam Point must be a range of Cartesian coordinates. - * - */ - template< typename Point > - typename std::iterator_traits<typename boost::range_iterator<Point>::type>::value_type - operator()(const Point& point_1, const Point& point_2) const { - std::clog << "#" << *point_1.begin() << "##" << *point_2.begin() << std::endl; - return Euclidean_distance()(point_1, point_2) / 2.; - } - - /** \brief Enclosing ball radius from a point cloud using CGAL. - * - * @param[in] point_cloud The points. - * @return Enclosing ball radius for the points. - * \tparam Point_cloud must be a range of Kernel::Point_d points from CGAL. - * - */ - template< typename Kernel = CGAL::Epeck_d<CGAL::Dynamic_dimension_tag>, - typename Point= typename Kernel::Point_d, - typename Point_cloud = std::vector<Point>> - double operator()(const Point_cloud& point_cloud) const { - Kernel kernel_; - return std::sqrt(CGAL::to_double(kernel_.compute_squared_radius_d_object()(point_cloud.begin(), point_cloud.end()))); - } - - /** \brief Minimal_enclosing_ball_radius from a point cloud. - * - * @param[in] point_cloud The points. - * @return The minimal enclosing ball radius for the points. - * - * \tparam Point_cloud must be a range of points with Cartesian coordinates. - * Point_cloud is a range over a range of Coordinate. - * - */ - 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(boost::size(*point_cloud.begin()), point_cloud.begin(), point_cloud.end()); -#ifdef DEBUG_TRACES - std::clog << "Minimal_enclosing_ball_radius = " << std::sqrt(ms.squared_radius()) << " | nb points = " - << boost::size(point_cloud) << " | dimension = " - << boost::size(*point_cloud.begin()) << std::endl; -#endif // DEBUG_TRACES - - return std::sqrt(ms.squared_radius()); - } -}; - } // namespace Gudhi #endif // DISTANCE_FUNCTIONS_H_ |