Tangential_complex_interface.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): Vincent Rouvreau
4  *
5  * Copyright (C) 2016 Inria
6  *
7  * Modification(s):
8  * - YYYY/MM Author: Description of the modification
9  */
10 
11 #ifndef INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_
12 #define INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_
13 
14 #include <gudhi/Simplex_tree.h>
15 #include <gudhi/Tangential_complex.h>
16 #include <gudhi/Points_off_io.h>
17 #include <CGAL/Epick_d.h>
18 
19 #include "Simplex_tree_interface.h"
20 
21 #include <vector>
22 #include <utility> // std::pair
23 #include <iostream>
24 #include <string>
25 
26 namespace Gudhi {
27 
28 namespace tangential_complex {
29 
30 class Tangential_complex_interface {
31  using Dynamic_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >;
32  using Point_d = Dynamic_kernel::Point_d;
33  using TC = Tangential_complex<Dynamic_kernel, CGAL::Dynamic_dimension_tag, CGAL::Parallel_tag>;
34 
35  public:
36  Tangential_complex_interface(int intrisic_dim, const std::vector<std::vector<double>>& points) {
37  Dynamic_kernel k;
38 
39  tangential_complex_ = new TC(points, intrisic_dim, k);
40  }
41 
42  Tangential_complex_interface(int intrisic_dim, const std::string& off_file_name, bool from_file = true) {
43  Dynamic_kernel k;
44 
45  Gudhi::Points_off_reader<Point_d> off_reader(off_file_name);
46  std::vector<Point_d> points = off_reader.get_point_cloud();
47 
48  tangential_complex_ = new TC(points, intrisic_dim, k);
49  }
50 
51  ~Tangential_complex_interface() {
52  delete tangential_complex_;
53  }
54 
55  void compute_tangential_complex() {
56  tangential_complex_->compute_tangential_complex();
57  num_inconsistencies_ = tangential_complex_->number_of_inconsistent_simplices();
58  }
59 
60  std::vector<double> get_point(unsigned vh) {
61  std::vector<double> vd;
62  if (vh < tangential_complex_->number_of_vertices()) {
63  Point_d ph = tangential_complex_->get_point(vh);
64  for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++)
65  vd.push_back(*coord);
66  }
67  return vd;
68  }
69 
70  unsigned number_of_vertices() {
71  return tangential_complex_->number_of_vertices();
72  }
73 
74  unsigned number_of_simplices() {
75  return num_inconsistencies_.num_simplices;
76  }
77 
78  unsigned number_of_inconsistent_simplices() {
79  return num_inconsistencies_.num_inconsistent_simplices;
80  }
81 
82  unsigned number_of_inconsistent_stars() {
83  return num_inconsistencies_.num_inconsistent_stars;
84  }
85 
86  void fix_inconsistencies_using_perturbation(double max_perturb, double time_limit) {
87  tangential_complex_->fix_inconsistencies_using_perturbation(max_perturb, time_limit);
88  num_inconsistencies_ = tangential_complex_->number_of_inconsistent_simplices();
89  }
90 
91  void create_simplex_tree(Simplex_tree<>* simplex_tree) {
92  tangential_complex_->create_complex<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>(*simplex_tree);
93  }
94 
95  void set_max_squared_edge_length(double max_squared_edge_length) {
96  tangential_complex_->set_max_squared_edge_length(max_squared_edge_length);
97  }
98 
99 private:
100  TC* tangential_complex_;
101  TC::Num_inconsistencies num_inconsistencies_;
102 };
103 
104 } // namespace tangential_complex
105 
106 } // namespace Gudhi
107 
108 #endif // INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_
OFF file reader implementation in order to read points from an OFF file.
Definition: Points_off_io.h:122
Tangential complex data structure.
Definition: Tangential_complex.h:125
Type returned by Tangential_complex::number_of_inconsistent_simplices.
Definition: Tangential_complex.h:539
GUDHIdev  Version 3.5.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Tue Aug 16 2022 14:01:50 for GUDHIdev by Doxygen 1.9.1