11#ifndef SPARSIFY_POINT_SET_H_
12#define SPARSIFY_POINT_SET_H_
14# include <boost/iterator/function_output_iterator.hpp>
16#include <gudhi/Kd_tree_search.h>
17#ifdef GUDHI_SUBSAMPLING_PROFILING
18#include <gudhi/Clock.h>
26namespace subsampling {
48template <
typename Kernel,
typename Po
int_range,
typename OutputIterator>
51 const Kernel &k, Point_range
const& input_pts,
52 typename Kernel::FT min_squared_dist,
53 OutputIterator output_it) {
55 Kernel, Point_range> Points_ds;
57#ifdef GUDHI_SUBSAMPLING_PROFILING
61 Points_ds points_ds(input_pts);
63 std::vector<bool> dropped_points(input_pts.size(),
false);
67 std::size_t pt_idx = 0;
68 for (
auto const& pt : input_pts) {
69 if (dropped_points[pt_idx++])
75 auto drop = [&dropped_points] (std::ptrdiff_t neighbor_point_idx) { dropped_points[neighbor_point_idx] =
true; };
76 points_ds.all_near_neighbors2(pt, min_squared_dist, min_squared_dist, boost::make_function_output_iterator(std::ref(drop)));
79#ifdef GUDHI_SUBSAMPLING_PROFILING
81 std::cerr <<
"Point set sparsified in " << t.num_seconds()
82 <<
" seconds." << std::endl;
Spatial tree data structure to perform (approximate) nearest and furthest neighbor search.
Definition: Kd_tree_search.h:70
void sparsify_point_set(const Kernel &k, Point_range const &input_pts, typename Kernel::FT min_squared_dist, OutputIterator output_it)
Outputs a subset of the input points so that the squared distance between any two points is greater t...
Definition: sparsify_point_set.h:50