16 #include <deal.II/numerics/kdtree.h> 18 #ifdef DEAL_II_WITH_NANOFLANN 20 # include <deal.II/base/std_cxx14/memory.h> 22 DEAL_II_NAMESPACE_OPEN
28 : max_leaf_size(max_leaf_size)
37 std::vector<std::pair<unsigned int, double>>
47 nanoflann::SearchParams params;
48 params.sorted = sorted;
50 std::vector<std::pair<unsigned int, double>> matches;
51 # if NANOFLANN_VERSION < 0x130 52 kdtree->radiusSearch(center.
begin_raw(), radius, matches, params);
56 kdtree->radiusSearch(center.
begin_raw(), radius * radius, matches, params);
57 for (std::pair<unsigned int, double> &match : matches)
58 match.second = std::sqrt(match.second);
67 std::vector<std::pair<unsigned int, double>>
69 const unsigned int n_points)
const 75 std::vector<unsigned int> indices(n_points);
76 std::vector<double> distances(n_points);
84 std::vector<std::pair<unsigned int, double>> matches(n_points);
85 for (
unsigned int i = 0; i < n_points; ++i)
86 #
if NANOFLANN_VERSION < 0x130
87 matches[i] = std::make_pair(indices[i], distances[i]);
91 matches[i] = std::make_pair(indices[i], std::sqrt(distances[i]));
104 adaptor = std_cxx14::make_unique<PointCloudAdaptor>(pts);
105 kdtree = std_cxx14::make_unique<NanoFlannKDTree>(
106 dim, *adaptor, nanoflann::KDTreeSingleIndexAdaptorParams(max_leaf_size));
107 kdtree->buildIndex();
115 DEAL_II_NAMESPACE_CLOSE
std::vector< std::pair< unsigned int, double > > get_points_within_ball(const Point< dim > &target, const double radius, const bool sorted=false) const
static ::ExceptionBase & ExcNotInitialized()
std::vector< std::pair< unsigned int, double > > get_closest_points(const Point< dim > &target, const unsigned int n_points) const
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
void set_points(const std::vector< Point< dim >> &pts)
KDTree(const unsigned int max_leaf_size=10, const std::vector< Point< dim >> &pts={})
static ::ExceptionBase & ExcInternalError()