Euclidean_witness_complex_interface.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): Vincent Rouvreau
6  *
7  * Copyright (C) 2016 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 INCLUDE_EUCLIDEAN_WITNESS_COMPLEX_INTERFACE_H_
24 #define INCLUDE_EUCLIDEAN_WITNESS_COMPLEX_INTERFACE_H_
25 
26 #include <gudhi/Simplex_tree.h>
27 #include <gudhi/Euclidean_witness_complex.h>
28 
29 #include "Simplex_tree_interface.h"
30 
31 #include <CGAL/Epick_d.h>
32 
33 #include <vector>
34 #include <utility> // std::pair
35 #include <iostream>
36 #include <cstddef>
37 
38 namespace Gudhi {
39 
40 namespace witness_complex {
41 
42 
43 class Euclidean_witness_complex_interface {
44  using Dynamic_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >;
45  using Point_d = Dynamic_kernel::Point_d;
46 
47  typedef typename Simplex_tree<>::Simplex_key Simplex_key;
48 
49  public:
50  Euclidean_witness_complex_interface(const std::vector<std::vector<double>>& landmarks,
51  const std::vector<std::vector<double>>& witnesses) {
52  landmarks_.reserve(landmarks.size());
53  for (auto& landmark : landmarks)
54  landmarks_.emplace_back(landmark.begin(), landmark.end());
55  witness_complex_ = new Euclidean_witness_complex<Dynamic_kernel>(landmarks_, witnesses);
56  }
57 
58  ~Euclidean_witness_complex_interface() {
59  delete witness_complex_;
60  }
61 
62  void create_simplex_tree(Gudhi::Simplex_tree<>* simplex_tree, double max_alpha_square, std::size_t limit_dimension) {
63  witness_complex_->create_complex(*simplex_tree, max_alpha_square, limit_dimension);
64  simplex_tree->initialize_filtration();
65  }
66 
67  void create_simplex_tree(Gudhi::Simplex_tree<>* simplex_tree, double max_alpha_square) {
68  witness_complex_->create_complex(*simplex_tree, max_alpha_square);
69  simplex_tree->initialize_filtration();
70  }
71 
72  std::vector<double> get_point(unsigned vh) {
73  std::vector<double> vd;
74  if (vh < landmarks_.size()) {
75  Point_d ph = witness_complex_->get_point(vh);
76  for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++)
77  vd.push_back(*coord);
78  }
79  return vd;
80  }
81 
82  private:
83  std::vector<Point_d> landmarks_;
84  Euclidean_witness_complex<Dynamic_kernel>* witness_complex_;
85 };
86 
87 } // namespace witness_complex
88 
89 } // namespace Gudhi
90 
91 #endif // INCLUDE_EUCLIDEAN_WITNESS_COMPLEX_INTERFACE_H_
92 
Simplex Tree data structure for representing simplicial complexes.
Definition: Simplex_tree.h:72
Definition: SimplicialComplexForAlpha.h:26
Key type used as simplex identifier.
Definition: SimplexKey.h:27
void initialize_filtration()
Initializes the filtrations, i.e. sort the simplices according to their order in the filtration and i...
Definition: Simplex_tree.h:800
GUDHI  Version 2.2.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : GPL v3 Generated on Tue Jul 17 2018 12:56:28 for GUDHI by Doxygen 1.8.13