Cech_complex.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): Vincent Rouvreau, Hind Montassif
4  *
5  * Copyright (C) 2018 Inria
6  *
7  * Modification(s):
8  * - YYYY/MM Author: Description of the modification
9  * - 2022/02 Hind Montassif : Replace MiniBall with Sphere_circumradius
10  */
11 
12 #ifndef CECH_COMPLEX_H_
13 #define CECH_COMPLEX_H_
14 
15 #include <gudhi/Sphere_circumradius.h> // for Gudhi::cech_complex::Sphere_circumradius
16 #include <gudhi/graph_simplicial_complex.h> // for Gudhi::Proximity_graph
17 #include <gudhi/Debug_utils.h> // for GUDHI_CHECK
18 #include <gudhi/Cech_complex_blocker.h> // for Gudhi::cech_complex::Cech_blocker
19 
20 #include <iostream>
21 #include <stdexcept> // for exception management
22 
23 namespace Gudhi {
24 
25 namespace cech_complex {
26 
43 template <typename Kernel, typename SimplicialComplexForCechComplex>
44 class Cech_complex {
45  private:
46  // Required by compute_proximity_graph
47  using Vertex_handle = typename SimplicialComplexForCechComplex::Vertex_handle;
48  using Filtration_value = typename SimplicialComplexForCechComplex::Filtration_value;
50 
51  using cech_blocker = Cech_blocker<SimplicialComplexForCechComplex, Cech_complex, Kernel>;
52 
53  using Point_d = typename cech_blocker::Point_d;
54  using Point_cloud = std::vector<Point_d>;
55 
56  // Numeric type of coordinates in the kernel
57  using FT = typename cech_blocker::FT;
58  // Sphere is a pair of point and squared radius.
59  using Sphere = typename cech_blocker::Sphere;
60 
61  public:
71  template<typename InputPointRange >
72  Cech_complex(const InputPointRange & points, Filtration_value max_radius, const bool exact = false) : max_radius_(max_radius), exact_(exact) {
73 
74  point_cloud_.assign(std::begin(points), std::end(points));
75 
76  cech_skeleton_graph_ = Gudhi::compute_proximity_graph<SimplicialComplexForCechComplex>(
77  point_cloud_, max_radius_, Sphere_circumradius<Kernel, Filtration_value>(exact));
78  }
79 
88  void create_complex(SimplicialComplexForCechComplex& complex, int dim_max) {
89  GUDHI_CHECK(complex.num_vertices() == 0,
90  std::invalid_argument("Cech_complex::create_complex - simplicial complex is not empty"));
91 
92  // insert the proximity graph in the simplicial complex
93  complex.insert_graph(cech_skeleton_graph_);
94  // expand the graph until dimension dim_max
95  complex.expansion_with_blockers(dim_max, cech_blocker(&complex, this));
96  }
97 
99  Filtration_value max_radius() const { return max_radius_; }
100 
104  const Point_d& get_point(Vertex_handle vertex) const { return point_cloud_[vertex]; }
105 
109  std::vector<Sphere> & get_cache() { return cache_; }
110 
114  const bool is_exact() { return exact_; }
115 
116  private:
117  Proximity_graph cech_skeleton_graph_;
118  Filtration_value max_radius_;
119  Point_cloud point_cloud_;
120  std::vector<Sphere> cache_;
121  const bool exact_;
122 };
123 
124 } // namespace cech_complex
125 
126 } // namespace Gudhi
127 
128 #endif // CECH_COMPLEX_H_
Cech complex class.
Definition: Cech_complex.h:44
const Point_d & get_point(Vertex_handle vertex) const
Definition: Cech_complex.h:104
Cech_complex(const InputPointRange &points, Filtration_value max_radius, const bool exact=false)
Cech_complex constructor from a range of points.
Definition: Cech_complex.h:72
std::vector< Sphere > & get_cache()
Definition: Cech_complex.h:109
const bool is_exact()
Check exact option.
Definition: Cech_complex.h:114
void create_complex(SimplicialComplexForCechComplex &complex, int dim_max)
Initializes the simplicial complex from the proximity graph and expands it until a given maximal dime...
Definition: Cech_complex.h:88
Filtration_value max_radius() const
Definition: Cech_complex.h:99
Graph simplicial complex methods.
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
typename boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, boost::property< vertex_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value >, boost::property< edge_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value > > Proximity_graph
Proximity_graph contains the vertices and edges with their filtration values in order to store the re...
Definition: graph_simplicial_complex.h:45
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:20