Ponca  aa50bfdf187919869239c5b44b748842569114c1
Point Cloud Analysis library
Loading...
Searching...
No Matches
kdTreeNearestQueries.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/kdTreeNearestIterator.h"
12
13namespace Ponca {
14
15template <typename Traits,
16 template <typename> typename IteratorType,
17 typename QueryType>
18class KdTreeNearestQueryBase : 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>;
27
28 KdTreeNearestQueryBase(const KdTreeBase<Traits>* kdtree, typename QueryType::InputType input) :
29 KdTreeQuery<Traits>(kdtree), QueryType(input){}
30
31public:
32 inline Iterator begin(){
34 QueryType::reset();
35 this->search();
36 return Iterator(QueryType::m_nearest);
37 }
38 inline Iterator end(){
39 return Iterator(QueryType::m_nearest + 1);
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)
49 {
50 QueryType::m_nearest = idx;
51 QueryType::m_squared_distance = d;
52 return false;
53 }
54 );
55 }
56};
57
58template <typename Traits>
61template <typename Traits>
64} // 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 QueryOutputIsNearest.
Definition: query.h:204
Base Query class combining QueryInputIsPosition and QueryOutputIsNearest.
Definition: query.h:207
This Source Code Form is subject to the terms of the Mozilla Public License, v.