9#include "../../query.h"
10#include "../Iterator/neighborGraphRangeIterator.h"
53 template <
typename _NeighborGraph>
54 class NeighborGraphRangeQuery :
public RangeIndexQuery<typename _NeighborGraph::Traits::IndexType,
55 typename _NeighborGraph::Traits::DataPoint::Scalar>
59 using NeighborGraph = _NeighborGraph;
61 using QueryType = RangeIndexQuery<typename Traits::IndexType, typename Traits::DataPoint::Scalar>;
62 using DataPoint =
typename Traits::DataPoint;
63 using IndexType =
typename Traits::IndexType;
64 using Scalar =
typename DataPoint::Scalar;
65 using VectorType =
typename DataPoint::VectorType;
67 using Self = NeighborGraphRangeQuery<NeighborGraph>;
74 PONCA_MULTIARCH
inline NeighborGraphRangeQuery(
const NeighborGraph* graph, Scalar
radius,
int index)
82 return QueryType::template operator()<Self>(index,
radius);
86 PONCA_MULTIARCH
inline Self&
operator()(
int index) {
return QueryType::template operator()<Self>(index); }
89 PONCA_MULTIARCH
inline Iterator
begin()
99 PONCA_MULTIARCH
inline Iterator
end() {
return Iterator(
this,
static_cast<int>(m_graph->pointCount())); }
102 PONCA_MULTIARCH
inline void initialize(Iterator& iterator)
107 PONCA_DEBUG_ASSERT(
m_stack.empty());
110 iterator.m_index = -1;
118 PONCA_MULTIARCH
inline void advance(Iterator& iterator)
120 const auto& points = m_graph->points();
123 if (iterator ==
end())
129 int idx_current =
m_stack.top();
134 iterator.m_index = idx_current;
136 for (
int idx_nei : m_graph->oneConnectedNeighbors(idx_current))
138 PONCA_DEBUG_ASSERT(idx_nei >= 0);
141 Scalar d = (point - points[idx_nei].pos()).squaredNorm();
147 auto [iteratorToInsertedValue, wasInserted] =
m_flag.insert(idx_nei);
151 PONCA_ASSERT(iteratorToInsertedValue !=
m_flag.end());
167 typename Traits::KnnGraphRangeSet
m_flag;
NeighborGraphDefaultTraits< DataPoint > Traits
Input iterator to read the NeighborGraphRangeQuery object.
void advance(Iterator &iterator)
Helper function for the NeighborGraphRangeIterator that advances the range neighbors search using the...
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.
Traits::KnnGraphRangeStack m_stack
Holds the next ids the Query should visit.
Traits::KnnGraphRangeSet m_flag
Stores every visited neighbor ids.
Self & operator()(int index, Scalar radius)
Call the range neighbors query with new input and radius parameters.
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.
Scalar radius() const
Generic method to access the radius.
void reset()
Reset Query for a new search.
const InputType & input() const
This Source Code Form is subject to the terms of the Mozilla Public License, v.
NeighborGraphBase< NeighborGraphDefaultTraits< DataPoint > > NeighborGraph
Public interface for the NeighborGraph datastructure.