14#include <nanoflann.hpp>
52 const std::size_t dim)
const {
78 using TreeType = nanoflann::KDTreeSingleIndexAdaptor<
79 nanoflann::L2_Simple_Adaptor<double, BodiesAdaptor>,
92 nanoflann::KDTreeSingleIndexAdaptorParams(10)) {
105 template <
typename VectorOfPairs>
107 const double search_radius,
108 VectorOfPairs& out_results) {
111#if defined(NANOFLANN_VERSION) && NANOFLANN_VERSION < 0x150
113 return tree_.radiusSearch(query_point,
114 search_radius * search_radius,
115 out_results, nanoflann::SearchParams());
118 return tree_.radiusSearch(
119 query_point, search_radius * search_radius, out_results,
120 nanoflann::SearchParameters());
SoA container for simulation bodies and proxies for AoS-like access.
An adapter to allow nanoflann to work directly with our Bodies SoA container.
bool kdtree_get_bbox(BBOX &) const
Optional bounding box calculation (not used here).
BodiesAdaptor(const Bodies &in_bodies)
Construct a new Bodies Adaptor object.
double kdtree_get_pt(const std::size_t idx, const std::size_t dim) const
Returns the value of a single dimension of a point.
const Bodies & bodies_
A const reference to the bodies container.
std::size_t kdtree_get_point_count() const
Returns the number of bodies (points) in the dataset.
Structure-of-Arrays (SoA) container for all bodies in the simulation.
std::size_t size() const
Get number of bodies in the simulation.
std::vector< Vector3d > x_
Bodies' positions.
A k-d tree for fast nearest neighbour searches, specialized for our Bodies container.
BodiesAdaptor adaptor_
The adapter that lets nanoflann access our data.
nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< double, BodiesAdaptor >, BodiesAdaptor, 3, std::size_t > TreeType
The specific KD-Tree type using our adapter.
TreeType tree_
The underlying nanoflann k-d tree index.
std::size_t radiusSearch(const double *query_point, const double search_radius, VectorOfPairs &out_results)
Finds all bodies within a given radius of a query point.
KDTree(const Bodies &in_bodies)
Construct a new KDTree object and build the index.