Edge_profile.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 CONTRACTION_EDGE_PROFILE_H_
24 #define CONTRACTION_EDGE_PROFILE_H_
25 
26 #include <ostream>
27 
28 namespace Gudhi {
29 
30 namespace contraction {
31 
32 template<typename GeometricSimplifiableComplex> class Edge_profile {
33  public:
34  typedef GeometricSimplifiableComplex Complex;
35  typedef typename Complex::GT GT;
36 
37  typedef typename GeometricSimplifiableComplex::Vertex_handle Vertex_handle;
38  typedef typename GeometricSimplifiableComplex::Root_vertex_handle Root_vertex_handle;
39 
40 
41  typedef typename GeometricSimplifiableComplex::Edge_handle Edge_handle;
42  typedef typename GeometricSimplifiableComplex::Graph_vertex Graph_vertex;
43  typedef typename GeometricSimplifiableComplex::Graph_edge Graph_edge;
44  typedef typename GeometricSimplifiableComplex::Point Point;
45 
46  Edge_profile(GeometricSimplifiableComplex& complex, Edge_handle edge) : complex_(complex), edge_handle_(edge),
47  v0_(complex_.first_vertex(edge_handle_)), v1_(complex_.second_vertex(edge_handle_)) {
48  assert(complex_.get_address(complex_[edge_handle_].first()));
49  assert(complex_.get_address(complex_[edge_handle_].second()));
50  assert(complex_.contains_edge(v0_handle(), v1_handle()));
51  assert(v0_handle() != v1_handle());
52  }
53 
54  virtual ~Edge_profile() { }
55 
56  GeometricSimplifiableComplex& complex() const {
57  return complex_;
58  }
59 
60  Edge_handle edge_handle() const {
61  return edge_handle_;
62  }
63 
64  Graph_edge& edge() const {
65  return complex_[edge_handle_];
66  }
67 
68  Graph_vertex& v0() const {
69  return complex_[v0_handle()];
70  }
71 
72  Graph_vertex& v1() const {
73  return complex_[v1_handle()];
74  }
75 
76  Vertex_handle v0_handle() const {
77  return v0_;
78  // Root_vertex_handle root = complex_[edge_handle_].first();
79  // assert(complex_.get_address(root));
80  // return *complex_.get_address(root);
81  }
82 
83  Vertex_handle v1_handle() const {
84  return v1_;
85  // Root_vertex_handle root = complex_[edge_handle_].second();
86  // assert(complex_.get_address(root));
87  // return *complex_.get_address(root);
88  }
89 
90  const Point& p0() const {
91  return complex_.point(v0_handle());
92  }
93 
94  const Point& p1() const {
95  return complex_.point(v1_handle());
96  }
97 
98  friend std::ostream& operator<<(std::ostream& o, const Edge_profile& v) {
99  return o << "v0:" << v.v0_handle() << " v1:" << v.v1_handle();
100  }
101 
102  private:
103  GeometricSimplifiableComplex& complex_;
104 
105  Edge_handle edge_handle_;
106 
107  Vertex_handle v0_;
108 
109  Vertex_handle v1_;
110 };
111 
112 template<typename EdgeProfile> class Edge_profile_factory {
113  public:
114  typedef typename EdgeProfile::Edge_handle Edge_handle_;
115  typedef typename EdgeProfile::Complex Complex_;
116 
117  virtual EdgeProfile make_profile(
118  Complex_& complex,
119  Edge_handle_ edge) const {
120  return EdgeProfile(complex, edge);
121  }
122 
123  virtual ~Edge_profile_factory() { }
124 };
125 
126 } // namespace contraction
127 
128 } // namespace Gudhi
129 
130 #endif // CONTRACTION_EDGE_PROFILE_H_
Definition: SimplicialComplexForAlpha.h:26
GUDHI  Version 2.2.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : GPL v3 Generated on Tue Aug 21 2018 01:41:05 for GUDHI by Doxygen 1.8.13