Euclidean_strong_witness_complex.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): Siargey Kachanovich
6  *
7  * Copyright (C) 2015 INRIA (France)
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 EUCLIDEAN_STRONG_WITNESS_COMPLEX_H_
24 #define EUCLIDEAN_STRONG_WITNESS_COMPLEX_H_
25 
26 #include <gudhi/Strong_witness_complex.h>
27 #include <gudhi/Active_witness/Active_witness.h>
28 #include <gudhi/Kd_tree_search.h>
29 
30 #include <utility>
31 #include <vector>
32 
33 namespace Gudhi {
34 
35 namespace witness_complex {
36 
46 template< class Kernel_ >
48  : public Strong_witness_complex<std::vector<typename Gudhi::spatial_searching::Kd_tree_search<Kernel_,
49  std::vector<typename Kernel_::Point_d>>::INS_range>> {
50  private:
51  typedef Kernel_ K;
52  typedef typename K::Point_d Point_d;
53  typedef std::vector<Point_d> Point_range;
55  typedef typename Kd_tree::INS_range Nearest_landmark_range;
56  typedef typename std::vector<Nearest_landmark_range> Nearest_landmark_table;
57 
58  typedef typename Nearest_landmark_range::Point_with_transformed_distance Id_distance_pair;
59  typedef typename Id_distance_pair::first_type Landmark_id;
60  typedef Landmark_id Vertex_handle;
61 
62  private:
63  Point_range landmarks_;
64  Kd_tree landmark_tree_;
65  using Strong_witness_complex<Nearest_landmark_table>::nearest_landmark_table_;
66 
67  public:
69  /* @name Constructor
70  */
71 
73 
80  template< typename LandmarkRange,
81  typename WitnessRange >
82  Euclidean_strong_witness_complex(const LandmarkRange & landmarks,
83  const WitnessRange & witnesses)
84  : landmarks_(std::begin(landmarks), std::end(landmarks)), landmark_tree_(landmarks_) {
85  nearest_landmark_table_.reserve(boost::size(witnesses));
86  for (auto w : witnesses)
87  nearest_landmark_table_.push_back(landmark_tree_.incremental_nearest_neighbors(w));
88  }
89 
92  template <typename Vertex_handle>
93  Point_d get_point(Vertex_handle vertex) const {
94  return landmarks_[vertex];
95  }
96 
98 };
99 
100 } // namespace witness_complex
101 
102 } // namespace Gudhi
103 
104 #endif // EUCLIDEAN_STRONG_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:110
Definition: SimplicialComplexForAlpha.h:26
Constructs strong witness complex for given sets of witnesses and landmarks in Euclidean space...
Definition: Euclidean_strong_witness_complex.h:47
Point_d get_point(Vertex_handle vertex) const
Returns the point corresponding to the given vertex.
Definition: Euclidean_strong_witness_complex.h:93
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:200
Euclidean_strong_witness_complex(const LandmarkRange &landmarks, const WitnessRange &witnesses)
Initializes member variables before constructing simplicial complex.
Definition: Euclidean_strong_witness_complex.h:82
GUDHI  Version 2.0.1  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding. Generated on Mon Oct 2 2017 10:20:49 for GUDHI by doxygen 1.8.11