9#include "../../indexSquaredDistance.h"
10#include "../../../Common/Containers/stack.h"
14 template <
typename Traits>
15 class StaticKdTreeBase;
22 template <
typename Traits>
26 using DataPoint =
typename Traits::DataPoint;
27 using IndexType =
typename Traits::IndexType;
28 using Scalar =
typename DataPoint::Scalar;
29 using VectorType =
typename DataPoint::VectorType;
38 PONCA_MULTIARCH
inline void reset()
51 template <
typename LeafPreparationFunctor,
typename DescentDistanceThresholdFunctor,
typename SkipIndexFunctor,
52 typename ProcessNeighborFunctor>
53 PONCA_MULTIARCH
bool searchInternal(
const VectorType& point, LeafPreparationFunctor prepareLeafTraversal,
54 DescentDistanceThresholdFunctor descentDistanceThreshold,
55 SkipIndexFunctor skipFunctor, ProcessNeighborFunctor processNeighborFunctor)
66 const auto& node = nodes[qnode.index];
68 if (qnode.squared_distance < descentDistanceThreshold())
73 IndexType start = node.leaf_start();
74 IndexType end = node.leaf_start() + node.leaf_size();
75 prepareLeafTraversal(start, end);
76 for (IndexType i = start; i < end; ++i)
82 Scalar d = (point - points[idx].pos()).squaredNorm();
84 if (d < descentDistanceThreshold())
86 if (processNeighborFunctor(idx, i, d))
94 Scalar newOff = point[node.inner_split_dim()] - node.inner_split_value();
98 m_stack.top().index = node.inner_first_child_id();
99 qnode.index = node.inner_first_child_id() + 1;
103 m_stack.top().index = node.inner_first_child_id() + 1;
104 qnode.index = node.inner_first_child_id();
106 m_stack.top().squared_distance = qnode.squared_distance;
107 qnode.squared_distance = newOff * newOff;
Query object that provides a method to search neighbors on the KdTree depending on a distance thresho...
const StaticKdTreeBase< Traits > * m_kdtree
[KdTreeQuery kdtree type]
void reset()
Init stack for a new search.
Stack< IndexSquaredDistance< IndexType, Scalar >, 2 *Traits::MAX_DEPTH > m_stack
[KdTreeQuery kdtree type]
bool searchInternal(const VectorType &point, LeafPreparationFunctor prepareLeafTraversal, DescentDistanceThresholdFunctor descentDistanceThreshold, SkipIndexFunctor skipFunctor, ProcessNeighborFunctor processNeighborFunctor)
Search internally the neighbors of a point using the kdtree.
Stack with fixed-size storage.
Customizable static base class for KdTree datastructure implementations.
IndexType pointCount() const
Get the number of points.
const NodeContainer & nodes() const
Get the internal node container.
IndexType pointFromSample(IndexType sample_index) const
Return the point index associated with the specified sample index.
IndexType sampleCount() const
Get the number of indices.
PointContainer & points()
Get the internal point container.
NodeIndexType nodeCount() const
Get the number of nodes in the KdTree.
This Source Code Form is subject to the terms of the Mozilla Public License, v.