Ponca  aa50bfdf187919869239c5b44b748842569114c1
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 "../Iterator/knnGraphRangeIterator.h"
10#include <vector>
11
12namespace Ponca {
13
14template <typename Traits>class KnnGraphBase; // Need forward declaration to avoid mutual inclusion
15
16
17#ifndef PARSED_WITH_DOXYGEN
18struct KnnGraphQueryOutputType : public QueryOutputBase{
19 using OutputParameter = typename QueryOutputBase::DummyOutputParameter;
20};
21#endif
22
23template <typename Traits>class KnnGraphKNearestQuery
24#ifdef PARSED_WITH_DOXYGEN
25: public KNearestIndexQuery<typename Traits::IndexType, typename Traits::DataPoint::Scalar>
26#else
27 // we skip output because we don't need it: k is static, and already stored in the index array
28: public Query<QueryInputIsIndex<typename Traits::IndexType>,KnnGraphQueryOutputType>
29#endif
30{
31public:
32 using Iterator = typename Traits::IndexContainer::const_iterator;
33#ifdef PARSED_WITH_DOXYGEN
35#else
37#endif
38
39public:
40 inline KnnGraphKNearestQuery(const KnnGraphBase<Traits>* graph, int index)
41 : m_graph(graph), QueryType(index){}
42
43 inline Iterator begin() const{
44 return m_graph->index_data().begin() + QueryType::input() * m_graph->k();
45 }
46 inline Iterator end() const{
47 return m_graph->index_data().begin() + (QueryType::input()+1) * m_graph->k();
48 }
49
50protected:
51 const KnnGraphBase<Traits>* m_graph {nullptr};
52};
53
54} // namespace Ponca
Customizable base class for KnnGraph datastructure.
Definition: knnGraph.h:45
Base Query class combining QueryInputIsIndex and QueryOutputIsKNearest.
Definition: query.h:203
This Source Code Form is subject to the terms of the Mozilla Public License, v.