11 #ifndef SPARSIFY_POINT_SET_H_
12 #define SPARSIFY_POINT_SET_H_
14 #include <boost/version.hpp>
15 #if BOOST_VERSION < 106600
16 # include <boost/function_output_iterator.hpp>
18 # include <boost/iterator/function_output_iterator.hpp>
21 #include <gudhi/Kd_tree_search.h>
22 #ifdef GUDHI_SUBSAMPLING_PROFILING
23 #include <gudhi/Clock.h>
31 namespace subsampling {
53 template <
typename Kernel,
typename Po
int_range,
typename OutputIterator>
56 const Kernel &k, Point_range
const& input_pts,
57 typename Kernel::FT min_squared_dist,
58 OutputIterator output_it) {
60 Kernel, Point_range> Points_ds;
62 #ifdef GUDHI_SUBSAMPLING_PROFILING
66 Points_ds points_ds(input_pts);
68 std::vector<bool> dropped_points(input_pts.size(),
false);
72 std::size_t pt_idx = 0;
73 for (
auto const& pt : input_pts) {
74 if (dropped_points[pt_idx++])
80 auto drop = [&dropped_points] (std::ptrdiff_t neighbor_point_idx) { dropped_points[neighbor_point_idx] =
true; };
81 points_ds.all_near_neighbors2(pt, min_squared_dist, min_squared_dist, boost::make_function_output_iterator(std::ref(drop)));
84 #ifdef GUDHI_SUBSAMPLING_PROFILING
86 std::cerr <<
"Point set sparsified in " << t.num_seconds()
87 <<
" seconds." << std::endl;
94 #endif // SPARSIFY_POINT_SET_H_