9#include "../../query.h"
10#include "../Iterator/knnGraphRangeIterator.h"
17template <
typename Traits>
class KnnGraphBase;
26template <
typename Traits>
34 using DataPoint =
typename Traits::DataPoint;
35 using IndexType =
typename Traits::IndexType;
36 using Scalar =
typename DataPoint::Scalar;
37 using VectorType =
typename DataPoint::VectorType;
50 return QueryType::template operator()<
Self>(index, radius);
55 return QueryType::template operator()<
Self>(index);
69 return Iterator(
this,
static_cast<int>(m_graph->size()));
73 inline void initialize(Iterator& iterator){
77 PONCA_DEBUG_ASSERT(
m_stack.empty());
80 iterator.m_index = -1;
83 inline void advance(Iterator& iterator){
84 const auto& points = m_graph->m_kdTreePoints;
87 if(! (iterator !=
end()))
return;
95 int idx_current =
m_stack.top();
100 iterator.m_index = idx_current;
102 for(
int idx_nei : m_graph->kNearestNeighbors(idx_current))
104 PONCA_DEBUG_ASSERT(idx_nei>=0);
105 Scalar d = (point - points[idx_nei].pos()).squaredNorm();
117 const KnnGraphBase<Traits>* m_graph {
nullptr};
Customizable base class for KnnGraph datastructure.
Input iterator to read the KnnGraphRangeQuery object.
Extension of the Query class that allows to read the result of a range neighbor search on the KnnGrap...
Self & operator()(int index, Scalar radius)
Call the range neighbors query with new input and radius parameters.
Iterator begin()
Returns an iterator to the beginning of the range neighbors query.
Self & operator()(int index)
Call the range neighbors query with new input parameter.
std::stack< int > m_stack
hold ids (ids range from 0 to point cloud size)
std::set< int > m_flag
store visited ids
Iterator end()
Returns an iterator to the end of the range neighbors query.
Scalar squaredRadius() const
Generic method to access the radius squared.
Scalar descentDistanceThreshold() const
Distance threshold used during tree descent to select nodes to explore.
void reset()
Reset Query for a new search.
const InputType & input() const
Read access to the input.
Base Query class combining QueryInputIsIndex and QueryOutputIsRange.
This Source Code Form is subject to the terms of the Mozilla Public License, v.