19 #include <nanoflann.hpp>
23 using nanoflann::KDTreeSingleIndexAdaptor;
24 using nanoflann::KDTreeSingleIndexAdaptorParams;
25 using nanoflann::L2_Simple_Adaptor;
27 typedef KDTreeSingleIndexAdaptor<L2_Simple_Adaptor<real_t, NanoFlannAdapter>,
28 NanoFlannAdapter, 3, uint64_t>
38 impl_ = std::unique_ptr<KDTreeEnvironment::NanoflannImpl>(
41 3, *
nf_adapter_, KDTreeSingleIndexAdaptorParams(param->nanoflann_depth));
57 std::array<real_t, 6> tmp_dim = {{inf, -inf, inf, -inf, inf, -inf}};
61 impl_->index_->buildIndex();
66 bool uninitialized =
impl_->index_->m_size == 0;
67 if (uninitialized && param->bound_space) {
72 int min = param->min_bound;
73 int max = param->max_bound;
77 }
else if (!uninitialized) {
85 "You tried to initialize an empty simulation without bound space. "
86 "Therefore we cannot determine the size of the simulation space. "
87 "Please add simulation objects, or set Param::bound_space_, "
88 "Param::min_bound_, and Param::max_bound_.");
100 const Real3& query_position,
102 const Agent* query_agent) {
103 std::vector<std::pair<uint64_t, real_t>> neighbors;
105 nanoflann::SearchParams params;
106 params.sorted =
false;
109 impl_->index_->radiusSearch(&query_position[0], squared_radius, neighbors,
113 for (
auto& n : neighbors) {
116 if (nb_so != query_agent) {
117 lambda(nb_so, n.second);
123 const Agent& query,
void* criteria) {
124 Log::Fatal(
"KDTreeEnvironment::ForEachNeighbor",
125 "You tried to call a specific ForEachNeighbor in an "
126 "environment that does not yet support it.");
138 Log::Fatal(
"KDTreeEnvironment::GetLoadBalanceInfo",
139 "You tried to call GetLoadBalanceInfo in an environment that does "
150 int32_t inf = std::numeric_limits<int32_t>::max();
156 const std::array<real_t, 6>& grid_dimensions) {