Top_faces.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): David Salinas
4  *
5  * Copyright (C) 2014 Inria
6  *
7  * Modification(s):
8  * - YYYY/MM Author: Description of the modification
9  */
10 
11 #ifndef SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_
12 #define SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_
13 
14 #include <list>
15 #include <vector>
16 #include <set>
17 
18 namespace Gudhi {
19 
20 namespace skeleton_blocker {
21 
22 template<typename SimplexHandle>
23 std::list<SimplexHandle> subfaces(SimplexHandle top_face) {
24  std::list<SimplexHandle> res;
25  if (top_face.dimension() == -1) return res;
26  if (top_face.dimension() == 0) {
27  res.push_back(top_face);
28  return res;
29  } else {
30  auto first_vertex = top_face.first_vertex();
31  top_face.remove_vertex(first_vertex);
32  res = subfaces(top_face);
33  std::list<SimplexHandle> copy = res;
34  for (auto& simplex : copy) {
35  simplex.add_vertex(first_vertex);
36  }
37  res.push_back(SimplexHandle(first_vertex));
38  res.splice(res.end(), copy);
39  return res;
40  }
41 }
42 
46 template<typename SimplexHandle>
47 void register_faces(std::vector< std::set<SimplexHandle> >& simplices_per_dimension,
48  const SimplexHandle& top_face) {
49  std::list<SimplexHandle> subfaces_list = subfaces(top_face);
50  for (auto& simplex : subfaces_list) {
51  simplices_per_dimension[simplex.dimension()].insert(simplex);
52  }
53 }
54 
55 } // namespace skeleton_blocker
56 
57 namespace skbl = skeleton_blocker;
58 
59 } // namespace Gudhi
60 
61 #endif // SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_
GUDHI  Version 3.4.1  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Tue Oct 26 2021 14:06:04 for GUDHI by Doxygen 1.9.1