Skeleton_blocker_geometric_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): 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_GEOMETRIC_COMPLEX_H_
12 #define SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_
13 
14 #include <gudhi/Skeleton_blocker_complex.h>
15 #include <gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h>
16 #include <gudhi/Debug_utils.h>
17 
18 namespace Gudhi {
19 
20 namespace skeleton_blocker {
21 
27 template<typename SkeletonBlockerGeometricDS>
29 public Skeleton_blocker_complex<SkeletonBlockerGeometricDS> {
30  public:
31  typedef typename SkeletonBlockerGeometricDS::GT GT;
32 
34 
35  typedef typename SimplifiableSkeletonblocker::Vertex_handle Vertex_handle;
36  typedef typename SimplifiableSkeletonblocker::Root_vertex_handle Root_vertex_handle;
37  typedef typename SimplifiableSkeletonblocker::Edge_handle Edge_handle;
39 
40  typedef typename SimplifiableSkeletonblocker::Graph_vertex Graph_vertex;
41 
42  typedef typename SkeletonBlockerGeometricDS::Point Point;
43 
45 
49  template<typename PointIterator>
50  explicit Skeleton_blocker_geometric_complex(int num_vertices, PointIterator begin, PointIterator end) {
51  for (auto point = begin; point != end; ++point)
52  add_vertex(*point);
53  }
54 
60  template<typename SimpleHandleOutputIterator, typename PointIterator>
62  SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end,
63  PointIterator points_begin, PointIterator points_end,
64  bool is_flag_complex = false)
65  : Skeleton_blocker_complex<SkeletonBlockerGeometricDS>(simplex_begin, simplex_end, is_flag_complex) {
66  unsigned current = 0;
67  for (auto point = points_begin; point != points_end; ++point)
68  (*this)[Vertex_handle(current++)].point() = Point(point->begin(), point->end());
69  }
70 
76  template<typename SimpleHandleOutputIterator>
78  SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end,
79  bool is_flag_complex = false)
80  : Skeleton_blocker_complex<SkeletonBlockerGeometricDS>(simplex_begin, simplex_end, is_flag_complex) { }
81 
85  Vertex_handle add_vertex() {
87  }
88 
92  Vertex_handle add_vertex(const Point& point) {
93  Vertex_handle ad = SimplifiableSkeletonblocker::add_vertex();
94  (*this)[ad].point() = point;
95  return ad;
96  }
97 
101  const Point& point(Vertex_handle v) const {
102  assert(this->contains_vertex(v));
103  return (*this)[v].point();
104  }
105 
109  Point& point(Vertex_handle v) {
110  assert(this->contains_vertex(v));
111  return (*this)[v].point();
112  }
113 
114  const Point& point(Root_vertex_handle global_v) const {
115  Vertex_handle local_v((*this)[global_v]);
116  assert(this->contains_vertex(local_v));
117  return (*this)[local_v].point();
118  }
119 
120  Point& point(Root_vertex_handle global_v) {
121  Vertex_handle local_v((*this)[global_v]);
122  assert(this->contains_vertex(local_v));
123  return (*this)[local_v].point();
124  }
125 
127 
131  Geometric_link link(Vertex_handle v) const {
132  Geometric_link link(*this, Simplex(v));
133  // we now add the point info
134  add_points_to_link(link);
135  return link;
136  }
137 
141  Geometric_link link(const Simplex& simplex) const {
142  Geometric_link link(*this, simplex);
143  // we now add the point info
144  add_points_to_link(link);
145  return link;
146  }
147 
151  Geometric_link link(Edge_handle edge) const {
152  Geometric_link link(*this, edge);
153  // we now add the point info
154  add_points_to_link(link);
155  return link;
156  }
157 
159 
163  Abstract_link abstract_link(Vertex_handle v) const {
164  return Abstract_link(*this, Simplex(v));
165  }
166 
170  Abstract_link abstract_link(const Simplex& simplex) const {
171  return Abstract_link(*this, simplex);
172  }
173 
177  Abstract_link abstract_link(Edge_handle edge) const {
178  return Abstract_link(*this, edge);
179  }
180 
181  private:
182  void add_points_to_link(Geometric_link& link) const {
183  for (Vertex_handle v : link.vertex_range()) {
184  Root_vertex_handle v_root(link.get_id(v));
185  link.point(v) = (*this).point(v_root);
186  }
187  }
188 };
189 
190 
191 template<typename SkeletonBlockerGeometricComplex, typename SimpleHandleOutputIterator, typename PointIterator>
192 SkeletonBlockerGeometricComplex make_complex_from_top_faces(
193  SimpleHandleOutputIterator simplex_begin,
194  SimpleHandleOutputIterator simplex_end,
195  PointIterator points_begin,
196  PointIterator points_end,
197  bool is_flag_complex = false) {
198  typedef SkeletonBlockerGeometricComplex SBGC;
199  SkeletonBlockerGeometricComplex complex;
200  unsigned current = 0;
201  complex =
202  make_complex_from_top_faces<SBGC>(simplex_begin, simplex_end, is_flag_complex);
203  for (auto point = points_begin; point != points_end; ++point)
204  // complex.point(Vertex_handle(current++)) = Point(point->begin(),point->end());
205  complex.point(typename SBGC::Vertex_handle(current++)) = typename SBGC::Point(*point);
206  return complex;
207 }
208 
209 } // namespace skeleton_blocker
210 
211 namespace skbl = skeleton_blocker;
212 
213 } // namespace Gudhi
214 
215 #endif // SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_
Abstract simplex used in Skeleton blockers data-structure.
Definition: Skeleton_blocker_simplex.h:38
GeometryTrait GT
Definition: SkeletonBlockerGeometricDS.h:32
Vertex_handle add_vertex()
Add a vertex to the complex with a default constructed associated point.
Definition: Skeleton_blocker_geometric_complex.h:85
SkeletonBlockerGeometricDS ::Vertex_handle Vertex_handle
The type of an handle to a vertex of the complex.
Definition: Skeleton_blocker_complex.h:77
Geometric_link link(Edge_handle edge) const
Definition: Skeleton_blocker_geometric_complex.h:151
Definition: SimplicialComplexForAlpha.h:14
Vertex_handle add_vertex(const Point &point)
Add a vertex to the complex with its associated point.
Definition: Skeleton_blocker_geometric_complex.h:92
Point & point(Vertex_handle v)
Returns the Point associated to the vertex v.
Definition: Skeleton_blocker_geometric_complex.h:109
Skeleton_blocker_geometric_complex(int num_vertices, PointIterator begin, PointIterator end)
Definition: Skeleton_blocker_geometric_complex.h:50
Root_vertex_handle get_id(Vertex_handle local) const
Definition: Skeleton_blocker_complex.h:443
Skeleton_blocker_geometric_complex(SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end, bool is_flag_complex=false)
Constructor with a list of simplices. Points of every vertex are the point constructed with default c...
Definition: Skeleton_blocker_geometric_complex.h:77
Class that represents a geometric complex that can be simplified. The class allows access to points o...
Definition: Skeleton_blocker_geometric_complex.h:28
Vertex_handle add_vertex()
Adds a vertex to the simplicial complex and returns its Vertex_handle.
Definition: Skeleton_blocker_complex.h:372
Geometric_link link(const Simplex &simplex) const
Definition: Skeleton_blocker_geometric_complex.h:141
Concept for template class of Skeleton_blocker_geometric_complex . It must specify a GeometryTrait wh...
Definition: SkeletonBlockerGeometricDS.h:28
GeometryTrait::Point Point
Definition: SkeletonBlockerGeometricDS.h:37
Skeleton_blocker_geometric_complex(SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end, PointIterator points_begin, PointIterator points_end, bool is_flag_complex=false)
Constructor with a list of simplices.
Definition: Skeleton_blocker_geometric_complex.h:61
boost::graph_traits< Graph >::edge_descriptor Edge_handle
Handle to an edge of the complex.
Definition: Skeleton_blocker_complex.h:114
const Point & point(Vertex_handle v) const
Returns the Point associated to the vertex v.
Definition: Skeleton_blocker_geometric_complex.h:101
Abstract_link abstract_link(Edge_handle edge) const
Definition: Skeleton_blocker_geometric_complex.h:177
Complex_vertex_range vertex_range() const
Returns a Complex_vertex_range over all vertices of the complex.
Definition: Skeleton_blocker_complex.h:1284
Abstract_link abstract_link(Vertex_handle v) const
Definition: Skeleton_blocker_geometric_complex.h:163
Abstract_link abstract_link(const Simplex &simplex) const
Definition: Skeleton_blocker_geometric_complex.h:170
SkeletonBlockerGeometricDS ::Graph_vertex Graph_vertex
The type of stored vertex node, specified by the template SkeletonBlockerDS.
Definition: Skeleton_blocker_complex.h:65
Geometric_link link(Vertex_handle v) const
Definition: Skeleton_blocker_geometric_complex.h:131
Abstract Simplicial Complex represented with a skeleton/blockers pair.
Definition: Skeleton_blocker_complex.h:51
GUDHI  Version 3.1.1  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Fri Feb 7 2020 16:35:36 for GUDHI by Doxygen 1.8.13