1 #ifndef GEOMETRY_BallTREE_H 2 #define GEOMETRY_BallTREE_H 5 #include <KrisLibrary/math/vector.h> 35 inline bool IsLeaf()
const {
return children.empty(); }
40 int MaxLeafSize()
const;
41 int MinLeafSize()
const;
49 std::vector<Point> pts;
52 std::vector<std::unique_ptr<BallTreeNode> > children;
58 typedef std::function<double(const Vector&,const Vector&)> Metric;
59 typedef std::function<void(const Vector&,const Vector&,Real,Vector&)>
Interpolator;
63 Interpolator interpolator;
67 BallTree(Metric metric,
int numSplitsPerNode=2);
68 BallTree(Metric metric,Interpolator interpolator,
int numSplitsPerNode=2);
71 inline int MaxDepth()
const {
return root.MaxDepth(); }
72 inline int MinDepth()
const {
return root.MinDepth(); }
75 inline int MinLeafSize()
const {
return root.MinLeafSize(); }
81 void Build(
const std::vector<Vector>& p,
int maxDepth);
103 int PointWithin(
const Vector& pt,Real& dist)
const;
106 void ClosePoints(
const Vector& pt,Real radius,std::vector<Real>& distances,std::vector<int>& ids)
const;
110 void KClosestPoints(
const Vector& pt,
int k,Real* dist,
int* idx)
const;
113 void _ClosestPoint(
const BallTreeNode* node,
const Vector& pt,Real& dist,
int& idx)
const;
114 void _ClosePoints(
const BallTreeNode* node,
const Vector& pt,Real radius,std::vector<Real>& distances,std::vector<int>& ids)
const;
115 void _KClosestPoints(
const BallTreeNode* node,
const Vector& pt,
int k,Real* dist,
int* idx,
int& maxdist)
const;
int MaxLeafSize() const
max/min number of points in leaves of tree
Definition: BallTree.cpp:43
A node of a ball-tree point location data structure.
Definition: BallTree.h:28
int TreeSize() const
Number of nodes in tree.
Definition: BallTree.cpp:60
A base class for all 1D interpolators.
Definition: Interpolator.h:10
int ClosestPoint(const CollisionMesh &mesh, const Vector3 &p, Vector3 &cp, Real bound)
Definition: CollisionMesh.cpp:1309
int MaxDepth() const
depth statistics
Definition: BallTree.h:71
Contains all definitions in the Math package.
Definition: WorkspaceBound.h:12
int MaxLeafSize() const
max/min number of points in leaves of tree
Definition: BallTree.h:74
Definition: BallTree.h:55
Contains all definitions in the Geometry package.
Definition: AnyGeometry.cpp:26
int TreeSize() const
Number of nodes in tree.
Definition: BallTree.h:78