Skeleton_blocker_geometric_complex.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_GEOMETRIC_COMPLEX_H_
24 #define SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_
25 
26 #include <gudhi/Skeleton_blocker_complex.h>
27 #include <gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h>
28 #include <gudhi/Debug_utils.h>
29 
30 namespace Gudhi {
31 
32 namespace skeleton_blocker {
33 
39 template<typename SkeletonBlockerGeometricDS>
41 public Skeleton_blocker_complex<SkeletonBlockerGeometricDS> {
42  public:
43  typedef typename SkeletonBlockerGeometricDS::GT GT;
44 
46 
47  typedef typename SimplifiableSkeletonblocker::Vertex_handle Vertex_handle;
48  typedef typename SimplifiableSkeletonblocker::Root_vertex_handle Root_vertex_handle;
49  typedef typename SimplifiableSkeletonblocker::Edge_handle Edge_handle;
51 
52  typedef typename SimplifiableSkeletonblocker::Graph_vertex Graph_vertex;
53 
54  typedef typename SkeletonBlockerGeometricDS::Point Point;
55 
57 
61  template<typename PointIterator>
62  explicit Skeleton_blocker_geometric_complex(int num_vertices, PointIterator begin, PointIterator end) {
63  for (auto point = begin; point != end; ++point)
64  add_vertex(*point);
65  }
66 
72  template<typename SimpleHandleOutputIterator, typename PointIterator>
74  SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end,
75  PointIterator points_begin, PointIterator points_end,
76  bool is_flag_complex = false)
77  : Skeleton_blocker_complex<SkeletonBlockerGeometricDS>(simplex_begin, simplex_end, is_flag_complex) {
78  unsigned current = 0;
79  for (auto point = points_begin; point != points_end; ++point)
80  (*this)[Vertex_handle(current++)].point() = Point(point->begin(), point->end());
81  }
82 
88  template<typename SimpleHandleOutputIterator>
90  SimpleHandleOutputIterator simplex_begin, SimpleHandleOutputIterator simplex_end,
91  bool is_flag_complex = false)
92  : Skeleton_blocker_complex<SkeletonBlockerGeometricDS>(simplex_begin, simplex_end, is_flag_complex) { }
93 
97  Vertex_handle add_vertex() {
99  }
100 
104  Vertex_handle add_vertex(const Point& point) {
105  Vertex_handle ad = SimplifiableSkeletonblocker::add_vertex();
106  (*this)[ad].point() = point;
107  return ad;
108  }
109 
113  const Point& point(Vertex_handle v) const {
114  assert(this->contains_vertex(v));
115  return (*this)[v].point();
116  }
117 
121  Point& point(Vertex_handle v) {
122  assert(this->contains_vertex(v));
123  return (*this)[v].point();
124  }
125 
126  const Point& point(Root_vertex_handle global_v) const {
127  Vertex_handle local_v((*this)[global_v]);
128  assert(this->contains_vertex(local_v));
129  return (*this)[local_v].point();
130  }
131 
132  Point& point(Root_vertex_handle global_v) {
133  Vertex_handle local_v((*this)[global_v]);
134  assert(this->contains_vertex(local_v));
135  return (*this)[local_v].point();
136  }
137 
139 
143  Geometric_link link(Vertex_handle v) const {
144  Geometric_link link(*this, Simplex(v));
145  // we now add the point info
146  add_points_to_link(link);
147  return link;
148  }
149 
153  Geometric_link link(const Simplex& simplex) const {
154  Geometric_link link(*this, simplex);
155  // we now add the point info
156  add_points_to_link(link);
157  return link;
158  }
159 
163  Geometric_link link(Edge_handle edge) const {
164  Geometric_link link(*this, edge);
165  // we now add the point info
166  add_points_to_link(link);
167  return link;
168  }
169 
171 
175  Abstract_link abstract_link(Vertex_handle v) const {
176  return Abstract_link(*this, Simplex(v));
177  }
178 
182  Abstract_link abstract_link(const Simplex& simplex) const {
183  return Abstract_link(*this, simplex);
184  }
185 
189  Abstract_link abstract_link(Edge_handle edge) const {
190  return Abstract_link(*this, edge);
191  }
192 
193  private:
194  void add_points_to_link(Geometric_link& link) const {
195  for (Vertex_handle v : link.vertex_range()) {
196  Root_vertex_handle v_root(link.get_id(v));
197  link.point(v) = (*this).point(v_root);
198  }
199  }
200 };
201 
202 
203 template<typename SkeletonBlockerGeometricComplex, typename SimpleHandleOutputIterator, typename PointIterator>
204 SkeletonBlockerGeometricComplex make_complex_from_top_faces(
205  SimpleHandleOutputIterator simplex_begin,
206  SimpleHandleOutputIterator simplex_end,
207  PointIterator points_begin,
208  PointIterator points_end,
209  bool is_flag_complex = false) {
210  typedef SkeletonBlockerGeometricComplex SBGC;
211  SkeletonBlockerGeometricComplex complex;
212  unsigned current = 0;
213  complex =
214  make_complex_from_top_faces<SBGC>(simplex_begin, simplex_end, is_flag_complex);
215  for (auto point = points_begin; point != points_end; ++point)
216  // complex.point(Vertex_handle(current++)) = Point(point->begin(),point->end());
217  complex.point(typename SBGC::Vertex_handle(current++)) = typename SBGC::Point(*point);
218  return complex;
219 }
220 
221 } // namespace skeleton_blocker
222 
223 namespace skbl = skeleton_blocker;
224 
225 } // namespace Gudhi
226 
227 #endif // SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_
Abstract simplex used in Skeleton blockers data-structure.
Definition: Skeleton_blocker_simplex.h:50
GeometryTrait GT
Definition: SkeletonBlockerGeometricDS.h:44
Vertex_handle add_vertex()
Add a vertex to the complex with a default constructed associated point.
Definition: Skeleton_blocker_geometric_complex.h:97
SkeletonBlockerGeometricDS ::Vertex_handle Vertex_handle
The type of an handle to a vertex of the complex.
Definition: Skeleton_blocker_complex.h:89
Geometric_link link(Edge_handle edge) const
Definition: Skeleton_blocker_geometric_complex.h:163
Definition: SimplicialComplexForAlpha.h:26
Vertex_handle add_vertex(const Point &point)
Add a vertex to the complex with its associated point.
Definition: Skeleton_blocker_geometric_complex.h:104
Point & point(Vertex_handle v)
Returns the Point associated to the vertex v.
Definition: Skeleton_blocker_geometric_complex.h:121
Skeleton_blocker_geometric_complex(int num_vertices, PointIterator begin, PointIterator end)
Definition: Skeleton_blocker_geometric_complex.h:62
Root_vertex_handle get_id(Vertex_handle local) const
Definition: Skeleton_blocker_complex.h:455
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:89
Class that represents a geometric complex that can be simplified. The class allows access to points o...
Definition: Skeleton_blocker_geometric_complex.h:40
Vertex_handle add_vertex()
Adds a vertex to the simplicial complex and returns its Vertex_handle.
Definition: Skeleton_blocker_complex.h:384
Geometric_link link(const Simplex &simplex) const
Definition: Skeleton_blocker_geometric_complex.h:153
Concept for template class of Skeleton_blocker_geometric_complex . It must specify a GeometryTrait wh...
Definition: SkeletonBlockerGeometricDS.h:40
GeometryTrait::Point Point
Definition: SkeletonBlockerGeometricDS.h:49
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:73
boost::graph_traits< Graph >::edge_descriptor Edge_handle
Handle to an edge of the complex.
Definition: Skeleton_blocker_complex.h:126
const Point & point(Vertex_handle v) const
Returns the Point associated to the vertex v.
Definition: Skeleton_blocker_geometric_complex.h:113
Abstract_link abstract_link(Edge_handle edge) const
Definition: Skeleton_blocker_geometric_complex.h:189
Complex_vertex_range vertex_range() const
Returns a Complex_vertex_range over all vertices of the complex.
Definition: Skeleton_blocker_complex.h:1296
Abstract_link abstract_link(Vertex_handle v) const
Definition: Skeleton_blocker_geometric_complex.h:175
Abstract_link abstract_link(const Simplex &simplex) const
Definition: Skeleton_blocker_geometric_complex.h:182
SkeletonBlockerGeometricDS ::Graph_vertex Graph_vertex
The type of stored vertex node, specified by the template SkeletonBlockerDS.
Definition: Skeleton_blocker_complex.h:77
Geometric_link link(Vertex_handle v) const
Definition: Skeleton_blocker_geometric_complex.h:143
Abstract Simplicial Complex represented with a skeleton/blockers pair.
Definition: Skeleton_blocker_complex.h:63
GUDHI  Version 2.2.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : GPL v3 Generated on Thu Jun 14 2018 15:00:55 for GUDHI by Doxygen 1.8.13