Cech_complex_blocker.h
1 /* This file is part of the Gudhi Library. The Gudhi library
2  * (Geometric Understanding in Higher Dimensions) is a generic C++
3  * library for computational topology.
4  *
5  * Author(s): Vincent Rouvreau
6  *
7  * Copyright (C) 2018 Inria
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef CECH_COMPLEX_BLOCKER_H_
24 #define CECH_COMPLEX_BLOCKER_H_
25 
26 #include <gudhi/distance_functions.h> // for Gudhi::Minimal_enclosing_ball_radius
27 
28 #include <iostream>
29 #include <vector>
30 #include <cmath> // for std::sqrt
31 
32 namespace Gudhi {
33 
34 namespace cech_complex {
35 
50 template <typename SimplicialComplexForCech, typename Cech_complex>
51 class Cech_blocker {
52  private:
53  using Point_cloud = typename Cech_complex::Point_cloud;
54 
55  using Simplex_handle = typename SimplicialComplexForCech::Simplex_handle;
57 
58  public:
63  bool operator()(Simplex_handle sh) {
64  Point_cloud points;
65  for (auto vertex : sc_ptr_->simplex_vertex_range(sh)) {
66  points.push_back(cc_ptr_->get_point(vertex));
67 #ifdef DEBUG_TRACES
68  std::cout << "#(" << vertex << ")#";
69 #endif // DEBUG_TRACES
70  }
72 #ifdef DEBUG_TRACES
73  if (radius > cc_ptr_->max_radius()) std::cout << "radius > max_radius => expansion is blocked\n";
74 #endif // DEBUG_TRACES
75  sc_ptr_->assign_filtration(sh, radius);
76  return (radius > cc_ptr_->max_radius());
77  }
78 
80  Cech_blocker(SimplicialComplexForCech* sc_ptr, Cech_complex* cc_ptr) : sc_ptr_(sc_ptr), cc_ptr_(cc_ptr) {}
81 
82  private:
83  SimplicialComplexForCech* sc_ptr_;
84  Cech_complex* cc_ptr_;
85 };
86 
87 } // namespace cech_complex
88 
89 } // namespace Gudhi
90 
91 #endif // CECH_COMPLEX_BLOCKER_H_
unspecified Filtration_value
Definition: SimplicialComplexForCech.h:39
Definition: SimplicialComplexForAlpha.h:26
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:32
Global distance functions.
unspecified Simplex_handle
Definition: SimplicialComplexForCech.h:35
Compute the radius of the minimal enclosing ball between Points given by a range of coordinates...
Definition: distance_functions.h:76
Cech complex data structure.
Definition: Cech_complex.h:56
GUDHI  Version 2.3.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : GPL v3 Generated on Fri Jan 22 2021 03:21:44 for GUDHI by Doxygen 1.8.13