Ponca  7df32c91629c89b89840c4d7917cb272433f2d2b
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/knnGraphKNearestIterator.h"
11
12namespace Ponca
13{
14
15 template <typename Traits>
16 class StaticKnnGraphBase; // Need forward declaration to avoid mutual inclusion
17
18#ifndef PARSED_WITH_DOXYGEN
19 struct KnnGraphQueryOutputType : public QueryOutputBase
20 {
21 using OutputParameter = typename QueryOutputBase::DummyOutputParameter;
22 };
23#endif
24
33 template <typename Traits>
36 : public KNearestIndexQuery<typename Traits::IndexType, typename Traits::DataPoint::Scalar>
37#else
38 // we skip output because we don't need it: k is static, and already stored in the index array
39 : public Query<QueryInputIsIndex<typename Traits::IndexType>, KnnGraphQueryOutputType>
40#endif
41 {
42 public:
44#ifdef PARSED_WITH_DOXYGEN
46#else
48#endif
50
51 public:
52 PONCA_MULTIARCH inline KnnGraphKNearestQuery(const StaticKnnGraphBase<Traits>* graph, int index)
53 : QueryType(index), m_graph(graph)
54 {
55 }
57 PONCA_MULTIARCH inline Self& operator()(int index) { return QueryType::template operator()<Self>(index); }
58
60 PONCA_MULTIARCH [[nodiscard]] inline Iterator begin() const
61 {
62 return Iterator(m_graph->getIndexPtr()) + QueryType::input() * m_graph->k();
63 }
64
66 PONCA_MULTIARCH [[nodiscard]] inline Iterator end() const
67 {
68 return Iterator(m_graph->getIndexPtr()) + (QueryType::input() + 1) * m_graph->k();
69 }
70
71 protected:
72 const StaticKnnGraphBase<Traits>* m_graph{nullptr};
73 };
74
75} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:257
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.
Composes the Query object depending on an input type and output type.
Definition query.h:294
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition bitset.h:17