10 const unsigned int &max_leaf_size,
13 max_leaf_size(max_leaf_size)
27 "While building the tree, nodes are recursively divided until the number " 28 "of points inside is equal or below this value. While doing queries, the " 29 "tree algorithm ends by selecting leaf nodes, then performing linear search " 30 "(one-by-one) for the closest point to the query within all those in the leaf.");
45 const size_t num_results = 1;
48 nanoflann::KNNResultSet<double> resultSet(num_results);
50 resultSet.init(&ret_index, &dist);
51 kdtree->findNeighbors(resultSet, &p[0], nanoflann::SearchParams());
64 std::vector<std::pair<unsigned int, double> > &matches,
71 ExcMessage(
"Radius is expected to be positive."));
73 nanoflann::SearchParams params;
74 params.sorted = sorted;
75 return kdtree->radiusSearch(¢er[0], radius, matches, params);
80 std::vector<unsigned int> &indices,
81 std::vector<double> &distances)
const 87 kdtree->knnSearch(&target[0], indices.size(), &indices[0], &distances[0]);
A deal2lkit wrapper for the nanoflann library, used to compute the distance from a collection of poin...
nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< double, PointCloudAdaptor >, PointCloudAdaptor, dim, unsigned int > KDTree
A typedef for the actual KDTree object.
#define AssertDimension(dim1, dim2)
A parameter acceptor base class.
Adaptor class used internally by nanoflann.
static ParameterHandler prm
Static parameter.
shared_ptr< KDTree > kdtree
The actual kdtree.
unsigned int get_points_within_ball(const Point< dim > &target, const double &radius, std::vector< std::pair< unsigned int, double > > &matches, bool sorted=false) const
Fill a vector with the indices and the distance of the points that are at distance less than or equal...
static::ExceptionBase & ExcNotInitialized()
shared_ptr< T > SP(T *t)
Construct a shared pointer to a non const class T.
ParsedKDTreeDistance(const std::string &name="", const unsigned int &max_leaf_size=10, const std::vector< Point< dim > > &pts=std::vector< Point< dim > >())
Constructor: takes an optional name for the section.
unsigned int max_leaf_size
Max number of points per leaf.
static::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
void get_closest_points(const Point< dim > &target, std::vector< unsigned int > &indices, std::vector< double > &distances) const
Fill two vectors with the indices and distances of the closest points to the given target point...
shared_ptr< PointCloudAdaptor > adaptor
A point cloud adaptor, to be filled when set points is called.
virtual void declare_parameters(ParameterHandler &prm)
Calls the underlying function of ParsedFunction.
virtual double value(const Point< dim > &p, const unsigned int component=0) const
Compute the distance between the given point and the cloud of points in the currently stored adaptor...
void add_parameter(ParameterHandler &prm, T *parameter, const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation=std::string())
Add a parameter the given parameter list.
void set_points(const std::vector< Point< dim > > &pts)
Store a reference to the passed points.
static::ExceptionBase & ExcInternalError()