summaryrefslogtreecommitdiff
path: root/src/Spatial_searching/example/example_spatial_searching.cpp
diff options
context:
space:
mode:
authorcjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-06-28 16:23:35 +0000
committercjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-06-28 16:23:35 +0000
commit58bcd511da7d3c00b7a1f8ca130ba437ae6665c8 (patch)
tree74098568251a899732887e72aea019926974dc40 /src/Spatial_searching/example/example_spatial_searching.cpp
parente42f150700da50741b1e0d616a24a35574c1f76a (diff)
Add example
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1351 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2b99baa9a43854119a46ec8ce11b93f00ef74835
Diffstat (limited to 'src/Spatial_searching/example/example_spatial_searching.cpp')
-rw-r--r--src/Spatial_searching/example/example_spatial_searching.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Spatial_searching/example/example_spatial_searching.cpp b/src/Spatial_searching/example/example_spatial_searching.cpp
new file mode 100644
index 00000000..ba387b71
--- /dev/null
+++ b/src/Spatial_searching/example/example_spatial_searching.cpp
@@ -0,0 +1,37 @@
+#include <gudhi/Spatial_tree_data_structure.h>
+
+#include <CGAL/Epick_d.h>
+#include <CGAL/Random.h>
+
+#include <array>
+#include <vector>
+
+namespace gss = Gudhi::spatial_searching;
+
+int main (void)
+{
+ typedef CGAL::Epick_d<CGAL::Dimension_tag<4> > K;
+ typedef typename K::FT FT;
+ typedef typename K::Point_d Point;
+ typedef std::vector<Point> Points;
+
+ typedef gss::Spatial_tree_data_structure<K, Points> Points_ds;
+ typedef typename Points_ds::KNS_range KNS_range;
+ typedef typename Points_ds::KNS_iterator KNS_iterator;
+ typedef typename Points_ds::INS_range INS_range;
+ typedef typename Points_ds::INS_iterator INS_iterator;
+
+ CGAL::Random rd;
+
+ Points points;
+ for (int i = 0; i < 500; ++i)
+ points.push_back(Point(std::array<FT, 4>({ rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1) })));
+
+ Points_ds points_ds(points);
+
+ auto kns_range = points_ds.query_ANN(points[20], 10, true);
+ for (auto const& nghb : kns_range)
+ std::cout << nghb.first << " (sq. dist. = " << nghb.second << ")\n";
+
+ return 0;
+}