all_faces_in.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): Siargey Kachanovich
6  *
7  * Copyright (C) 2015 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 WITNESS_COMPLEX_ALL_FACES_IN_H_
24 #define WITNESS_COMPLEX_ALL_FACES_IN_H_
25 
26 /* \brief Check if the facets of the k-dimensional simplex witnessed
27  * by witness witness_id are already in the complex.
28  * inserted_vertex is the handle of the (k+1)-th vertex witnessed by witness_id
29  */
30 template < typename SimplicialComplexForWitness,
31  typename Simplex >
32  bool all_faces_in(Simplex& simplex,
33  double* filtration_value,
34  SimplicialComplexForWitness& sc) {
35  typedef typename SimplicialComplexForWitness::Simplex_handle Simplex_handle;
36 
37  if (simplex.size() == 1)
38  return true; /* Add vertices unconditionally */
39 
40  Simplex facet;
41  for (typename Simplex::iterator not_it = simplex.begin(); not_it != simplex.end(); ++not_it) {
42  facet.clear();
43  for (typename Simplex::iterator it = simplex.begin(); it != simplex.end(); ++it)
44  if (it != not_it)
45  facet.push_back(*it);
46  Simplex_handle facet_sh = sc.find(facet);
47  if (facet_sh == sc.null_simplex())
48  return false;
49  else if (sc.filtration(facet_sh) > *filtration_value)
50  *filtration_value = sc.filtration(facet_sh);
51  }
52  return true;
53  }
54 
55 #endif // WITNESS_COMPLEX_ALL_FACES_IN_H_
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