Edge_profile.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 CONTRACTION_EDGE_PROFILE_H_
12#define CONTRACTION_EDGE_PROFILE_H_
13
14#include <ostream>
15#include <cassert>
16
17namespace Gudhi {
18
19namespace contraction {
20
21template<typename GeometricSimplifiableComplex> class Edge_profile {
22 public:
23 typedef GeometricSimplifiableComplex Complex;
24 typedef typename Complex::GT GT;
25
26 typedef typename GeometricSimplifiableComplex::Vertex_handle Vertex_handle;
27 typedef typename GeometricSimplifiableComplex::Root_vertex_handle Root_vertex_handle;
28
29
30 typedef typename GeometricSimplifiableComplex::Edge_handle Edge_handle;
31 typedef typename GeometricSimplifiableComplex::Graph_vertex Graph_vertex;
32 typedef typename GeometricSimplifiableComplex::Graph_edge Graph_edge;
33 typedef typename GeometricSimplifiableComplex::Point Point;
34
35 Edge_profile(GeometricSimplifiableComplex& complex, Edge_handle edge) : complex_(complex), edge_handle_(edge),
36 v0_(complex_.first_vertex(edge_handle_)), v1_(complex_.second_vertex(edge_handle_)) {
37 assert(complex_.get_address(complex_[edge_handle_].first()));
38 assert(complex_.get_address(complex_[edge_handle_].second()));
39 assert(complex_.contains_edge(v0_handle(), v1_handle()));
40 assert(v0_handle() != v1_handle());
41 }
42
43 virtual ~Edge_profile() { }
44
45 GeometricSimplifiableComplex& complex() const {
46 return complex_;
47 }
48
49 Edge_handle edge_handle() const {
50 return edge_handle_;
51 }
52
53 Graph_edge& edge() const {
54 return complex_[edge_handle_];
55 }
56
57 Graph_vertex& v0() const {
58 return complex_[v0_handle()];
59 }
60
61 Graph_vertex& v1() const {
62 return complex_[v1_handle()];
63 }
64
65 Vertex_handle v0_handle() const {
66 return v0_;
67 // Root_vertex_handle root = complex_[edge_handle_].first();
68 // assert(complex_.get_address(root));
69 // return *complex_.get_address(root);
70 }
71
72 Vertex_handle v1_handle() const {
73 return v1_;
74 // Root_vertex_handle root = complex_[edge_handle_].second();
75 // assert(complex_.get_address(root));
76 // return *complex_.get_address(root);
77 }
78
79 const Point& p0() const {
80 return complex_.point(v0_handle());
81 }
82
83 const Point& p1() const {
84 return complex_.point(v1_handle());
85 }
86
87 friend std::ostream& operator<<(std::ostream& o, const Edge_profile& v) {
88 return o << "v0:" << v.v0_handle() << " v1:" << v.v1_handle();
89 }
90
91 private:
92 GeometricSimplifiableComplex& complex_;
93
94 Edge_handle edge_handle_;
95
96 Vertex_handle v0_;
97
98 Vertex_handle v1_;
99};
100
101template<typename EdgeProfile> class Edge_profile_factory {
102 public:
103 typedef typename EdgeProfile::Edge_handle Edge_handle_;
104 typedef typename EdgeProfile::Complex Complex_;
105
106 virtual EdgeProfile make_profile(
107 Complex_& complex,
108 Edge_handle_ edge) const {
109 return EdgeProfile(complex, edge);
110 }
111
112 virtual ~Edge_profile_factory() { }
113};
114
115} // namespace contraction
116
117} // namespace Gudhi
118
119#endif // CONTRACTION_EDGE_PROFILE_H_
Class that represents a geometric complex that can be simplified. The class allows access to points o...
Definition: Skeleton_blocker_geometric_complex.h:29
std::ostream & operator<<(std::ostream &os, const Permutahedral_representation< Vertex, OrderedSetPartition > &simplex)
Print a permutahedral representation to a stream.
Definition: Permutahedral_representation.h:173
Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor used in boost ...
Definition: SkeletonBlockerDS.h:47
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15