blob: 698226ccc8958284845e1f8c55839efadca3621e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Vincent Rouvreau
*
* Copyright (C) 2016 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/
#ifndef INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_
#define INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_
#include <gudhi/Simplex_tree.h>
#include <gudhi/Tangential_complex.h>
#include <gudhi/Points_off_io.h>
#include <CGAL/Epick_d.h>
#include "Simplex_tree_interface.h"
#include <vector>
#include <utility> // std::pair
#include <iostream>
#include <string>
namespace Gudhi {
namespace tangential_complex {
class Tangential_complex_interface {
using Dynamic_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >;
using Point_d = Dynamic_kernel::Point_d;
using TC = Tangential_complex<Dynamic_kernel, CGAL::Dynamic_dimension_tag, CGAL::Parallel_tag>;
public:
Tangential_complex_interface(int intrisic_dim, const std::vector<std::vector<double>>& points) {
Dynamic_kernel k;
tangential_complex_ = new TC(points, intrisic_dim, k);
}
Tangential_complex_interface(int intrisic_dim, const std::string& off_file_name, bool from_file = true) {
Dynamic_kernel k;
Gudhi::Points_off_reader<Point_d> off_reader(off_file_name);
std::vector<Point_d> points = off_reader.get_point_cloud();
tangential_complex_ = new TC(points, intrisic_dim, k);
}
~Tangential_complex_interface() {
delete tangential_complex_;
}
void compute_tangential_complex() {
tangential_complex_->compute_tangential_complex();
num_inconsistencies_ = tangential_complex_->number_of_inconsistent_simplices();
}
std::vector<double> get_point(unsigned vh) {
std::vector<double> vd;
if (vh < tangential_complex_->number_of_vertices()) {
Point_d ph = tangential_complex_->get_point(vh);
for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++)
vd.push_back(*coord);
}
return vd;
}
unsigned number_of_vertices() {
return tangential_complex_->number_of_vertices();
}
unsigned number_of_simplices() {
return num_inconsistencies_.num_simplices;
}
unsigned number_of_inconsistent_simplices() {
return num_inconsistencies_.num_inconsistent_simplices;
}
unsigned number_of_inconsistent_stars() {
return num_inconsistencies_.num_inconsistent_stars;
}
void fix_inconsistencies_using_perturbation(double max_perturb, double time_limit) {
tangential_complex_->fix_inconsistencies_using_perturbation(max_perturb, time_limit);
num_inconsistencies_ = tangential_complex_->number_of_inconsistent_simplices();
}
void create_simplex_tree(Simplex_tree<>* simplex_tree) {
tangential_complex_->create_complex<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>(*simplex_tree);
simplex_tree->initialize_filtration();
}
void set_max_squared_edge_length(double max_squared_edge_length) {
tangential_complex_->set_max_squared_edge_length(max_squared_edge_length);
}
private:
TC* tangential_complex_;
TC::Num_inconsistencies num_inconsistencies_;
};
} // namespace tangential_complex
} // namespace Gudhi
#endif // INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_
|