Top_faces.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): David Salinas
6  *
7  * Copyright (C) 2014 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 SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_
24 #define SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_
25 
26 #include <list>
27 #include <vector>
28 #include <set>
29 
30 namespace Gudhi {
31 
32 namespace skeleton_blocker {
33 
34 template<typename SimplexHandle>
35 std::list<SimplexHandle> subfaces(SimplexHandle top_face) {
36  std::list<SimplexHandle> res;
37  if (top_face.dimension() == -1) return res;
38  if (top_face.dimension() == 0) {
39  res.push_back(top_face);
40  return res;
41  } else {
42  auto first_vertex = top_face.first_vertex();
43  top_face.remove_vertex(first_vertex);
44  res = subfaces(top_face);
45  std::list<SimplexHandle> copy = res;
46  for (auto& simplex : copy) {
47  simplex.add_vertex(first_vertex);
48  }
49  res.push_back(SimplexHandle(first_vertex));
50  res.splice(res.end(), copy);
51  return res;
52  }
53 }
54 
58 template<typename SimplexHandle>
59 void register_faces(std::vector< std::set<SimplexHandle> >& simplices_per_dimension,
60  const SimplexHandle& top_face) {
61  std::list<SimplexHandle> subfaces_list = subfaces(top_face);
62  for (auto& simplex : subfaces_list) {
63  simplices_per_dimension[simplex.dimension()].insert(simplex);
64  }
65 }
66 
67 } // namespace skeleton_blocker
68 
69 namespace skbl = skeleton_blocker;
70 
71 } // namespace Gudhi
72 
73 #endif // SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_
Definition: SimplicialComplexForAlpha.h:26
GUDHI  Version 2.3.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : GPL v3 Generated on Fri Oct 5 2018 15:05:03 for GUDHI by Doxygen 1.8.13