Ponca  e26a0e88a45818354616c1a7180bcd203aecad3c
Point Cloud Analysis library
Loading...
Searching...
No Matches
kdTreeKNearestQueries.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 "kdTreeQuery.h"
10#include "../../query.h"
11#include "../Iterator/kdTreeKNearestIterator.h"
12
13namespace Ponca {
14
15template <typename Traits,
16 template <typename, typename> typename IteratorType,
17 typename QueryType>
18class KdTreeKNearestQueryBase : public KdTreeQuery<Traits>, public QueryType
19{
20public:
21 using DataPoint = typename Traits::DataPoint;
22 using IndexType = typename Traits::IndexType;
23 using Scalar = typename DataPoint::Scalar;
24 using VectorType = typename DataPoint::VectorType;
26 using Iterator = IteratorType<typename Traits::IndexType, typename Traits::DataPoint>;
27
28 inline KdTreeKNearestQueryBase(const KdTreeBase<Traits>* kdtree, IndexType k, typename QueryType::InputType input) :
29 KdTreeQuery<Traits>(kdtree), QueryType(k, input) { }
30
31public:
32 inline Iterator begin(){
34 QueryType::reset();
35 this->search();
36 return Iterator(QueryType::m_queue.begin());
37 }
38 inline Iterator end(){
39 return Iterator(QueryType::m_queue.end());
40 }
41
42protected:
43 inline void search(){
44 KdTreeQuery<Traits>::search_internal(QueryType::getInputPosition(QueryAccelType::m_kdtree->points()),
45 [](IndexType, IndexType){},
46 [this](){return QueryType::descentDistanceThreshold();},
47 [this](IndexType idx){return QueryType::skipIndexFunctor(idx);},
48 [this](IndexType idx, IndexType, Scalar d){QueryType::m_queue.push({idx, d}); return false;}
49 );
50 }
51};
52
53template <typename Traits>
56template <typename Traits>
59} // namespace ponca
[KdTreeSparse type definition]
Definition: kdTree.h:104
void reset()
Init stack for a new search.
Definition: kdTreeQuery.h:28
bool search_internal(const VectorType &point, LeafPreparationFunctor prepareLeafTraversal, DescentDistanceThresholdFunctor descentDistanceThreshold, SkipIndexFunctor skipFunctor, ProcessNeighborFunctor processNeighborFunctor)
Definition: kdTreeQuery.h:43
const KdTreeBase< Traits > * m_kdtree
[KdTreeQuery kdtree type]
Definition: kdTreeQuery.h:34
Base Query class combining QueryInputIsIndex and QueryOutputIsKNearest.
Definition: query.h:203
Base Query class combining QueryInputIsPosition and QueryOutputIsKNearest.
Definition: query.h:206
This Source Code Form is subject to the terms of the Mozilla Public License, v.