Sphere_circumradius.h
1 /* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2  * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3  * Author(s): Hind Montassif
4  *
5  * Copyright (C) 2021 Inria
6  *
7  * Modification(s):
8  * - YYYY/MM Author: Description of the modification
9  */
10 
11 #ifndef SPHERE_CIRCUMRADIUS_H_
12 #define SPHERE_CIRCUMRADIUS_H_
13 
14 #include <CGAL/Epick_d.h> // for #include <CGAL/NT_converter.h> which is not working/compiling alone
15 #include <CGAL/Lazy_exact_nt.h> // for CGAL::exact
16 
17 #include <cmath> // for std::sqrt
18 #include <vector>
19 
20 namespace Gudhi {
21 
22 namespace cech_complex {
23 
26 template<typename Kernel, typename Filtration_value>
27 class Sphere_circumradius {
28  private:
29  Kernel kernel_;
30  const bool exact_;
31  public:
32  using FT = typename Kernel::FT;
33  using Point = typename Kernel::Point_d;
34  using Point_cloud = typename std::vector<Point>;
35 
36  CGAL::NT_converter<FT, Filtration_value> cast_to_fv;
37 
46  Filtration_value operator()(const Point& point_1, const Point& point_2) const {
47  auto squared_dist_obj = kernel_.squared_distance_d_object()(point_1, point_2);
48  if(exact_) CGAL::exact(squared_dist_obj);
49  return std::sqrt(cast_to_fv(squared_dist_obj)) / 2.;
50  }
51 
59  Filtration_value operator()(const Point_cloud& point_cloud) const {
60  auto squared_radius_obj = kernel_.compute_squared_radius_d_object()(point_cloud.begin(), point_cloud.end());
61  if(exact_) CGAL::exact(squared_radius_obj);
62  return std::sqrt(cast_to_fv(squared_radius_obj));
63  }
64 
70  Sphere_circumradius(const bool exact = false) : exact_(exact) {}
71 
72 };
73 
74 } // namespace cech_complex
75 
76 } // namespace Gudhi
77 
78 #endif // SPHERE_CIRCUMRADIUS_H_
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:20