diff options
author | Hind-M <hind.montassif@gmail.com> | 2022-01-06 11:39:05 +0100 |
---|---|---|
committer | Hind-M <hind.montassif@gmail.com> | 2022-01-06 11:39:05 +0100 |
commit | b1f40dd2c4397c1975533c54a54538160c727d55 (patch) | |
tree | 3b89f83c0d37235effc86305db35a84345ffb524 /src/Cech_complex | |
parent | 9db268b5ecf056b87ee2f66c6d3f83de93a8681f (diff) |
Make kernel a parameter of Minimal_enclosing_ball_radius class
Use Epick in cech benchmark instead of Epeck
Diffstat (limited to 'src/Cech_complex')
4 files changed, 15 insertions, 16 deletions
diff --git a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp index 06d90757..e715b513 100644 --- a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp +++ b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp @@ -17,7 +17,7 @@ #include <gudhi/Simplex_tree.h> #include <gudhi/Miniball.hpp> -#include <CGAL/Epeck_d.h> // For EXACT or SAFE version +#include <CGAL/Epick_d.h> #include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations @@ -32,7 +32,7 @@ using Point_cloud = std::vector<Point>; using Points_off_reader = Gudhi::Points_off_reader<Point>; using Proximity_graph = Gudhi::Proximity_graph<Simplex_tree>; using Rips_complex = Gudhi::rips_complex::Rips_complex<Filtration_value>; -using Kernel = CGAL::Epeck_d<CGAL::Dynamic_dimension_tag>; +using Kernel = CGAL::Epick_d<CGAL::Dimension_tag<3>>; using Point_cgal = typename Kernel::Point_d; using Point_cloud_cgal = std::vector<Point_cgal>; using Points_off_reader_cgal = Gudhi::Points_off_reader<Point_cgal>; @@ -86,7 +86,7 @@ int main(int argc, char* argv[]) { Gudhi::Clock cgal_miniball_clock("Gudhi::Minimal_enclosing_ball_radius_cgal()"); // Compute the proximity graph of the points Proximity_graph cgal_miniball_prox_graph = Gudhi::compute_proximity_graph<Simplex_tree>( - off_reader_cgal.get_point_cloud(), threshold, Gudhi::Minimal_enclosing_ball_radius()); + off_reader_cgal.get_point_cloud(), threshold, Gudhi::Minimal_enclosing_ball_radius<Kernel>()); std::clog << cgal_miniball_clock << std::endl; boost::filesystem::path full_path(boost::filesystem::current_path()); @@ -109,7 +109,7 @@ int main(int argc, char* argv[]) { std::clog << radius << ";"; Gudhi::Clock rips_clock("Rips computation"); Rips_complex rips_complex_from_points(off_reader_cgal.get_point_cloud(), radius, - Gudhi::Minimal_enclosing_ball_radius()); + Gudhi::Minimal_enclosing_ball_radius<Kernel>()); Simplex_tree rips_stree; rips_complex_from_points.create_complex(rips_stree, p0.size() - 1); // ------------------------------------------ diff --git a/src/Cech_complex/include/gudhi/Cech_complex.h b/src/Cech_complex/include/gudhi/Cech_complex.h index 7bbf97d1..0031d861 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex.h +++ b/src/Cech_complex/include/gudhi/Cech_complex.h @@ -18,7 +18,6 @@ #include <iostream> #include <stdexcept> // for exception management -#include <vector> namespace Gudhi { @@ -78,7 +77,7 @@ class Cech_complex { point_cloud_.assign(points.begin(), points.end()); cech_skeleton_graph_ = Gudhi::compute_proximity_graph<SimplicialComplexForProximityGraph>( - point_cloud_, max_radius_, Gudhi::Minimal_enclosing_ball_radius()); + point_cloud_, max_radius_, Gudhi::Minimal_enclosing_ball_radius<Kernel>()); } /** \brief Initializes the simplicial complex from the proximity graph and expands it until a given maximal diff --git a/src/Cech_complex/include/gudhi/Cech_complex/Cech_kernel.h b/src/Cech_complex/include/gudhi/Cech_complex/Cech_kernel.h index 348bb57d..89012206 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex/Cech_kernel.h +++ b/src/Cech_complex/include/gudhi/Cech_complex/Cech_kernel.h @@ -11,9 +11,10 @@ #ifndef CECH_KERNEL_H_ #define CECH_KERNEL_H_ -#include <CGAL/Epeck_d.h> +#include <CGAL/Epeck_d.h> // for #include <CGAL/NewKernel_d/KernelD_converter.h> #include <cmath> // for std::sqrt +#include <vector> namespace Gudhi { @@ -21,8 +22,14 @@ namespace Gudhi { /** @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. */ +template<typename Kernel> class Minimal_enclosing_ball_radius { + private: + Kernel kernel_; public: + using Point = typename Kernel::Point_d; + using Point_cloud = typename std::vector<Point>; + /** \brief Enclosing ball radius from two points using CGAL. * * @param[in] point_1 @@ -31,10 +38,7 @@ class Minimal_enclosing_ball_radius { * \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.; } @@ -46,11 +50,7 @@ class Minimal_enclosing_ball_radius { * \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()))); } diff --git a/src/Cech_complex/test/test_cech_complex.cpp b/src/Cech_complex/test/test_cech_complex.cpp index 7d8c3c22..ca7a9778 100644 --- a/src/Cech_complex/test/test_cech_complex.cpp +++ b/src/Cech_complex/test/test_cech_complex.cpp @@ -108,11 +108,11 @@ BOOST_AUTO_TEST_CASE(Cech_complex_for_documentation) { std::clog << vertex << ","; vp.push_back(points.at(vertex)); } - std::clog << ") - distance =" << Gudhi::Minimal_enclosing_ball_radius()(vp.at(0), vp.at(1)) + std::clog << ") - distance =" << Gudhi::Minimal_enclosing_ball_radius<Kernel>()(vp.at(0), vp.at(1)) << " - filtration =" << st.filtration(f_simplex) << std::endl; BOOST_CHECK(vp.size() == 2); GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), - Gudhi::Minimal_enclosing_ball_radius()(vp.at(0), vp.at(1))); + Gudhi::Minimal_enclosing_ball_radius<Kernel>()(vp.at(0), vp.at(1))); } } |