From 0c85e54d44a95aa7aff3f6d51a587287ce4a88d6 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Sat, 3 Dec 2016 14:46:37 +0000 Subject: sparsify point set cythonization unitary tested git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1816 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 170f14ffcf009ebe1169df90a4e088441eaad13f --- src/cython/include/Subsampling_interface.h | 31 +++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/cython/include/Subsampling_interface.h') diff --git a/src/cython/include/Subsampling_interface.h b/src/cython/include/Subsampling_interface.h index 8ef4fea1..9340cd86 100644 --- a/src/cython/include/Subsampling_interface.h +++ b/src/cython/include/Subsampling_interface.h @@ -24,6 +24,8 @@ #define SUBSAMPLING_INTERFACE_H #include +#include +#include #include #include @@ -40,9 +42,6 @@ using Subsampling_ft = Subsampling_dynamic_kernel::FT; // ------ choose_n_farthest_points ------ std::vector> subsampling_n_farthest_points(std::vector>& points, unsigned nb_points) { - std::vector input, output; - for (auto point : points) - input.push_back(Subsampling_point_d(point.size(), point.begin(), point.end())); std::vector> landmarks; Subsampling_dynamic_kernel k; choose_n_farthest_points(k, points, nb_points, std::back_inserter(landmarks)); @@ -51,9 +50,6 @@ std::vector> subsampling_n_farthest_points(std::vector> subsampling_n_farthest_points(std::vector>& points, unsigned nb_points, unsigned starting_point) { - std::vector input, output; - for (auto point : points) - input.push_back(Subsampling_point_d(point.size(), point.begin(), point.end())); std::vector> landmarks; Subsampling_dynamic_kernel k; choose_n_farthest_points(k, points, nb_points, starting_point, std::back_inserter(landmarks)); @@ -75,9 +71,6 @@ std::vector> subsampling_n_farthest_points_from_file(std::st // ------ pick_n_random_points ------ std::vector> subsampling_n_random_points(std::vector>& points, unsigned nb_points) { - std::vector input, output; - for (auto point : points) - input.push_back(Subsampling_point_d(point.size(), point.begin(), point.end())); std::vector> landmarks; pick_n_random_points(points, nb_points, std::back_inserter(landmarks)); @@ -90,6 +83,26 @@ std::vector> subsampling_n_random_points_from_file(std::stri return subsampling_n_random_points(points, nb_points); } +// ------ sparsify_point_set ------ +std::vector> subsampling_sparsify_points(std::vector>& points, double min_squared_dist) { + std::vector input, output; + for (auto point : points) + input.push_back(Subsampling_point_d(point.size(), point.begin(), point.end())); + Subsampling_dynamic_kernel k; + sparsify_point_set(k, input, min_squared_dist, std::back_inserter(output)); + + std::vector> landmarks; + for (auto point : output) + landmarks.push_back(std::vector(point.cartesian_begin(), point.cartesian_end())); + return landmarks; +} + +std::vector> subsampling_sparsify_points_from_file(std::string& off_file, double min_squared_dist) { + Gudhi::Points_off_reader> off_reader(off_file); + std::vector> points = off_reader.get_point_cloud(); + return subsampling_sparsify_points(points, min_squared_dist); +} + } // namespace subsampling -- cgit v1.2.3