Ponca  7d8ac87a7de01d881c9fde3c42e397b44bffb901
Point Cloud Analysis library
Loading...
Searching...
No Matches
knnGraphKNearestQuery.h
1/*
2 This Source Code Form is subject to the terms of the Mozilla Public
3 License, v. 2.0. If a copy of the MPL was not distributed with this
4 file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
7#pragma once
8
9#include "../../query.h"
10#include "../Iterator/knnGraphRangeIterator.h"
11#include <vector>
12
13namespace Ponca
14{
15
16 template <typename Traits>
17 class KnnGraphBase; // Need forward declaration to avoid mutual inclusion
18
19#ifndef PARSED_WITH_DOXYGEN
20 struct KnnGraphQueryOutputType : public QueryOutputBase
21 {
22 using OutputParameter = typename QueryOutputBase::DummyOutputParameter;
23 };
24#endif
25
34 template <typename Traits>
37 : public KNearestIndexQuery<typename Traits::IndexType, typename Traits::DataPoint::Scalar>
38#else
39 // we skip output because we don't need it: k is static, and already stored in the index array
40 : public Query<QueryInputIsIndex<typename Traits::IndexType>, KnnGraphQueryOutputType>
41#endif
42 {
43 public:
44 using Iterator = typename Traits::IndexContainer::const_iterator;
45#ifdef PARSED_WITH_DOXYGEN
47#else
49#endif
51
52 public:
53 inline KnnGraphKNearestQuery(const KnnGraphBase<Traits>* graph, int index) : QueryType(index), m_graph(graph) {}
54
56 inline Self& operator()(int index) { return QueryType::template operator()<Self>(index); }
57
59 inline Iterator begin() const { return m_graph->index_data().begin() + QueryType::input() * m_graph->k(); }
60
62 inline Iterator end() const { return m_graph->index_data().begin() + (QueryType::input() + 1) * m_graph->k(); }
63
64 protected:
65 const KnnGraphBase<Traits>* m_graph{nullptr};
66 };
67
68} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:318
Extension of the Query class that allows to read the result of a k-nearest neighbors search on the Kn...
Self & operator()(int index)
Call the k-nearest neighbors query with new input parameter.
Iterator end() const
Returns an iterator to the end of the k-nearest neighbors query.
Iterator begin() const
Returns an iterator to the beginning of the k-nearest neighbors query.
Base Query class combining QueryInputIsIndex and QueryOutputIsKNearest.
Definition query.h:373
Composes the Query object depending on an input type and output type.
Definition query.h:334
This Source Code Form is subject to the terms of the Mozilla Public License, v.