9#include "../../query.h"
10#include "../Iterator/knnGraphRangeIterator.h"
17template <
typename Traits>
class KnnGraphBase;
19template <
typename Traits>
27 using DataPoint =
typename Traits::DataPoint;
28 using IndexType =
typename Traits::IndexType;
29 using Scalar =
typename DataPoint::Scalar;
30 using VectorType =
typename DataPoint::VectorType;
49 return Iterator(
this, m_graph->size());
53 inline void initialize(
Iterator& iterator){
55 m_flag.insert(QueryType::input());
57 PONCA_DEBUG_ASSERT(
m_stack.empty());
58 m_stack.push(QueryType::input());
60 iterator.m_index = -1;
63 inline void advance(
Iterator& iterator){
64 const auto& points = m_graph->m_kdTreePoints;
65 const auto& point = points[QueryType::input()].pos();
67 if(! (iterator != end()))
return;
75 int idx_current =
m_stack.top();
78 PONCA_DEBUG_ASSERT((point - points[idx_current].pos()).squaredNorm() < QueryType::squared_radius());
80 iterator.m_index = idx_current;
82 for(
int idx_nei : m_graph->k_nearest_neighbors(idx_current))
84 PONCA_DEBUG_ASSERT(idx_nei>=0);
85 Scalar d = (point - points[idx_nei].pos()).squaredNorm();
92 if (iterator.m_index == QueryType::input()) advance(iterator);
Customizable base class for KnnGraph datastructure.
std::stack< int > m_stack
hold ids (ids range from 0 to point cloud size)
std::set< int > m_flag
store visited ids
Scalar descentDistanceThreshold() const
Distance threshold used during tree descent to select nodes to explore.
Base Query class combining QueryInputIsIndex and QueryOutputIsRange.
This Source Code Form is subject to the terms of the Mozilla Public License, v.