diff options
-rw-r--r-- | src/Subsampling/test/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/Subsampling/test/test_sparsify_point_set.cpp | 34 |
2 files changed, 37 insertions, 3 deletions
diff --git a/src/Subsampling/test/CMakeLists.txt b/src/Subsampling/test/CMakeLists.txt index 3a45c685..1785b86d 100644 --- a/src/Subsampling/test/CMakeLists.txt +++ b/src/Subsampling/test/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 2.6) -project(GUDHILandmarkingTest) +project(Subsampling_tests) -# Landmarking test if(CGAL_FOUND) if (NOT CGAL_VERSION VERSION_LESS 4.8.0) message(STATUS "CGAL version: ${CGAL_VERSION}.") @@ -13,8 +12,9 @@ if(CGAL_FOUND) include_directories (BEFORE "../../include") add_executable( landmarking_UT landmarking.cpp ) + add_executable( Subsampling_test_sparsify_point_set test_sparsify_point_set.cpp) else() - message(WARNING "Eigen3 not found. Version 3.1.0 is required for Landmarking feature.") + message(WARNING "Eigen3 not found. Version 3.1.0 is required for Subsampling feature.") endif() else() message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile Landmarking feature. Version 4.8.0 is required.") diff --git a/src/Subsampling/test/test_sparsify_point_set.cpp b/src/Subsampling/test/test_sparsify_point_set.cpp new file mode 100644 index 00000000..e9d2a8f6 --- /dev/null +++ b/src/Subsampling/test/test_sparsify_point_set.cpp @@ -0,0 +1,34 @@ +// #ifdef _DEBUG +// # define TBB_USE_THREADING_TOOL +// #endif + +#include <gudhi/sparsify_point_set.h> + +#include <CGAL/Epick_d.h> +#include <CGAL/Random.h> + +#include <array> +#include <vector> +#include <iterator> + +int main() { + typedef CGAL::Epick_d<CGAL::Dimension_tag<4> > K; + typedef typename K::FT FT; + typedef typename K::Point_d Point_d; + + CGAL::Random rd; + + std::vector<Point_d> points; + for (int i = 0 ; i < 500 ; ++i) + points.push_back(Point_d(std::array<FT,4>({rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1)}))); + + K k; + std::vector<Point_d> results; + Gudhi::subsampling::sparsify_point_set(k, points, 0.5, std::back_inserter(results)); + std::cout << "Before sparsification: " << points.size() << " points.\n"; + std::cout << "After sparsification: " << results.size() << " points.\n"; + //for (auto p : results) + // std::cout << p << "\n"; + + return 0; +} |