FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
NanoflannAdaptor.hpp
1#ifndef FIBER_BASEOP_NANOFLANN_ADAPTOR_HPP
2#define FIBER_BASEOP_NANOFLANN_ADAPTOR_HPP 20251027
3
4#if __has_include(<nanoflann.hpp>)
5# include <nanoflann.hpp>
6# define HAVE_NANOFLANN NANOFLANN_VERSION
7#else
8# define HAVE_NANOFLANN 0
9#endif
10
11#include <vector>
12#include <array>
13
14#include <eagle/PhysicalSpace.hpp>
15
16namespace Fiber
17{
18
23{
24 using point3 = Eagle::point3;
25
26 const std::vector<point3>& pts;
27
29 : pts(points) {}
30
31 size_t kdtree_get_point_count() const { return pts.size(); }
32
33 inline double kdtree_get_pt(size_t idx, size_t dim) const
34 {
35 switch (dim)
36 {
37 case 0: return pts[idx][dim];
38 case 1: return pts[idx][dim];
39 case 2: return pts[idx][dim];
40 default: return 0.0;
41 }
42 }
43
44 template <class BBOX>
45 bool kdtree_get_bbox(BBOX&) const { return false; }
46};
47
69using nanoflannKDTree = nanoflann::KDTreeSingleIndexAdaptor<
70 nanoflann::L2_Simple_Adaptor<double, NanoFlannPointCloudAdaptor>,
72 >;
73
74
78template <size_t N>
79size_t findNClosestPoints(const Eagle::point3&QueryPoint,
83{
84const double*query_pt = QueryPoint.const_elements_as_fixed_array();
85 return theTree.knnSearch(query_pt, N, indices.data(), squared_distances.data());
86}
87
88
89}
90
91
92#endif // FIBER_BASEOP_NANOFLANN_ADAPTOR_HPP
constexpr size_type size() const noexcept
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
size_t findNClosestPoints(const Eagle::point3 &QueryPoint, const nanoflannKDTree &theTree, std::array< uint32_t, N > &indices, std::array< double, N > &squared_distances)
Definition NanoflannAdaptor.hpp:79
nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< double, NanoFlannPointCloudAdaptor >, NanoFlannPointCloudAdaptor, 3 > nanoflannKDTree
Interface to the Nanoflann library: https://github.com/jlblancoc/nanoflann.
Definition NanoflannAdaptor.hpp:72
Adaptor for interfacing the nanoflann library.
Definition NanoflannAdaptor.hpp:23