Euclidean_witness_complex.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): Siargey Kachanovich
4  *
5  * Copyright (C) 2015 Inria
6  *
7  * Modification(s):
8  * - 2019/08 Vincent Rouvreau: Fix issue #10 for CGAL and Eigen3
9  * - YYYY/MM Author: Description of the modification
10  */
11 
12 #ifndef EUCLIDEAN_WITNESS_COMPLEX_H_
13 #define EUCLIDEAN_WITNESS_COMPLEX_H_
14 
15 #include <gudhi/Witness_complex.h>
16 #include <gudhi/Active_witness/Active_witness.h>
17 #include <gudhi/Kd_tree_search.h>
18 
19 #include <CGAL/version.h> // for CGAL_VERSION_NR
20 
21 #include <Eigen/src/Core/util/Macros.h> // for EIGEN_VERSION_AT_LEAST
22 
23 #include <utility>
24 #include <vector>
25 #include <list>
26 #include <limits>
27 
28 // Make compilation fail - required for external projects - https://github.com/GUDHI/gudhi-devel/issues/10
29 #if CGAL_VERSION_NR < 1041101000
30 # error Euclidean_witness_complex is only available for CGAL >= 4.11
31 #endif
32 
33 #if !EIGEN_VERSION_AT_LEAST(3,1,0)
34 # error Euclidean_witness_complex is only available for Eigen3 >= 3.1.0 installed with CGAL
35 #endif
36 
37 namespace Gudhi {
38 
39 namespace witness_complex {
40 
50 template< class Kernel_ >
52  : public Witness_complex<std::vector<typename Gudhi::spatial_searching::Kd_tree_search<Kernel_,
53  std::vector<typename Kernel_::Point_d>>::INS_range>> {
54  private:
55  typedef Kernel_ K;
56  typedef typename K::Point_d Point_d;
57  typedef std::vector<Point_d> Point_range;
59  typedef typename Kd_tree::INS_range Nearest_landmark_range;
60  typedef typename std::vector<Nearest_landmark_range> Nearest_landmark_table;
61 
62  typedef typename Nearest_landmark_range::Point_with_transformed_distance Id_distance_pair;
63  typedef typename Id_distance_pair::first_type Landmark_id;
64  typedef Landmark_id Vertex_handle;
65 
66  private:
67  Point_range landmarks_;
68  Kd_tree landmark_tree_;
70 
71  public:
73  /* @name Constructor
74  */
75 
77 
84  template< typename LandmarkRange,
85  typename WitnessRange >
86  Euclidean_witness_complex(const LandmarkRange & landmarks,
87  const WitnessRange & witnesses)
88  : landmarks_(std::begin(landmarks), std::end(landmarks)), landmark_tree_(landmarks) {
89  nearest_landmark_table_.reserve(boost::size(witnesses));
90  for (auto w : witnesses)
91  nearest_landmark_table_.push_back(landmark_tree_.incremental_nearest_neighbors(w));
92  }
93 
97  Point_d get_point(Vertex_handle vertex) const {
98  return landmarks_[vertex];
99  }
100 
102 };
103 
104 } // namespace witness_complex
105 
106 } // namespace Gudhi
107 
108 #endif // EUCLIDEAN_WITNESS_COMPLEX_H_
Incremental_neighbor_search INS_range
The range returned by an incremental nearest or furthest neighbor search. Its value type is std::pair...
Definition: Kd_tree_search.h:111
Constructs (weak) witness complex for given sets of witnesses and landmarks in Euclidean space...
Definition: Euclidean_witness_complex.h:51
Definition: SimplicialComplexForAlpha.h:14
INS_range incremental_nearest_neighbors(Point const &p, FT eps=FT(0)) const
Search incrementally for the nearest neighbors from a query point.
Definition: Kd_tree_search.h:201
Point_d get_point(Vertex_handle vertex) const
Returns the point corresponding to the given vertex.
Definition: Euclidean_witness_complex.h:97
Constructs (weak) witness complex for a given table of nearest landmarks with respect to witnesses...
Definition: Witness_complex.h:38
Euclidean_witness_complex(const LandmarkRange &landmarks, const WitnessRange &witnesses)
Initializes member variables before constructing simplicial complex.
Definition: Euclidean_witness_complex.h:86
GUDHI  Version 3.1.1  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Fri Feb 7 2020 16:35:36 for GUDHI by Doxygen 1.8.13