16 #ifndef _d2k_parsed_kdtree_distance_h 17 #define _d2k_parsed_kdtree_distance_h 19 #include <deal2lkit/config.h> 24 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
25 #include <external/nanoflann.h> 26 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
74 const unsigned int &max_leaf_size=10,
95 const std::vector<Point<dim> > &
points;
109 return points.size();
116 inline coord_t
kdtree_distance(
const coord_t *p1,
const size_t idx_p2,
size_t size)
const 120 for (
size_t d=0;
d<size; ++
d)
121 res += (p1[
d]-points[idx_p2][
d])*(p1[d]-points[idx_p2][d]);
122 return std::sqrt(res);
132 return points[idx][d];
143 template <
class BBOX>
154 typedef typename nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<double, PointCloudAdaptor> ,
180 virtual double value(
const Point<dim> &p,
const unsigned int component=0)
const;
201 void set_points(
const std::vector<
Point<dim> > &pts);
210 return adaptor->points[i];
217 inline unsigned int size()
const 220 return adaptor->points.size();
239 unsigned int get_points_within_ball(
const Point<dim> &target,
const double &radius,
240 std::vector<std::pair<unsigned int, double> > &matches,
241 bool sorted=
false)
const;
254 void get_closest_points(
const Point<dim> &target,
255 std::vector<unsigned int> &indices,
256 std::vector<double> &distances)
const;
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.
const Point< dim > & operator[](unsigned int i) const
A const accessor to the underlying points.
#define AssertDimension(dim1, dim2)
A parameter acceptor base class.
Adaptor class used internally by nanoflann.
double coord_t
A typedef used by nanoflann.
unsigned int size() const
The size of the vector stored by this class.
shared_ptr< KDTree > kdtree
The actual kdtree.
#define AssertIndexRange(index, range)
unsigned int max_leaf_size
Max number of points per leaf.
const std::vector< Point< dim > > & points
Reference to the vector of points from which we want to compute the distance.
bool kdtree_get_bbox(BBOX &) const
Optional bounding-box computation: return false to default to a standard bbox computation loop...
coord_t kdtree_get_pt(const size_t idx, int d) const
Return the dim'th component of the idx'th point in the class.
shared_ptr< PointCloudAdaptor > adaptor
A point cloud adaptor, to be filled when set points is called.
PointCloudAdaptor(const std::vector< Point< dim > > &_points)
The constrcutor needs the data set source.
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
coord_t kdtree_distance(const coord_t *p1, const size_t idx_p2, size_t size) const
Return the L2 distance between points.
size_t kdtree_get_point_count() const
Return number of points in the data set (required by nanoflann).