Euclidean_witness_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_EUCLIDEAN_WITNESS_COMPLEX_INTERFACE_H_
12 #define INCLUDE_EUCLIDEAN_WITNESS_COMPLEX_INTERFACE_H_
13 
14 #include <gudhi/Simplex_tree.h>
15 #include <gudhi/Euclidean_witness_complex.h>
16 
17 #include "Simplex_tree_interface.h"
18 
19 #include <CGAL/Epick_d.h>
20 
21 #include <vector>
22 #include <utility> // std::pair
23 #include <iostream>
24 #include <cstddef>
25 
26 namespace Gudhi {
27 
28 namespace witness_complex {
29 
30 
31 class Euclidean_witness_complex_interface {
32  using Dynamic_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >;
33  using Point_d = Dynamic_kernel::Point_d;
34 
35  typedef typename Simplex_tree<>::Simplex_key Simplex_key;
36 
37  public:
38  Euclidean_witness_complex_interface(const std::vector<std::vector<double>>& landmarks,
39  const std::vector<std::vector<double>>& witnesses) {
40  landmarks_.reserve(landmarks.size());
41  for (auto& landmark : landmarks)
42  landmarks_.emplace_back(landmark.begin(), landmark.end());
43  witness_complex_ = new Euclidean_witness_complex<Dynamic_kernel>(landmarks_, witnesses);
44  }
45 
46  ~Euclidean_witness_complex_interface() {
47  delete witness_complex_;
48  }
49 
50  void create_simplex_tree(Gudhi::Simplex_tree<>* simplex_tree, double max_alpha_square, std::size_t limit_dimension) {
51  witness_complex_->create_complex(*simplex_tree, max_alpha_square, limit_dimension);
52  }
53 
54  void create_simplex_tree(Gudhi::Simplex_tree<>* simplex_tree, double max_alpha_square) {
55  witness_complex_->create_complex(*simplex_tree, max_alpha_square);
56  }
57 
58  std::vector<double> get_point(unsigned vh) {
59  std::vector<double> vd;
60  if (vh < landmarks_.size()) {
61  Point_d ph = witness_complex_->get_point(vh);
62  for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++)
63  vd.push_back(*coord);
64  }
65  return vd;
66  }
67 
68  private:
69  std::vector<Point_d> landmarks_;
70  Euclidean_witness_complex<Dynamic_kernel>* witness_complex_;
71 };
72 
73 } // namespace witness_complex
74 
75 } // namespace Gudhi
76 
77 #endif // INCLUDE_EUCLIDEAN_WITNESS_COMPLEX_INTERFACE_H_
78 
Simplex Tree data structure for representing simplicial complexes.
Definition: Simplex_tree.h:75
Options::Simplex_key Simplex_key
Key associated to each simplex.
Definition: Simplex_tree.h:86
GUDHIdev  Version 3.5.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Fri Jan 14 2022 18:28:42 for GUDHIdev by Doxygen 1.9.1