Ponca  eb7239a9c07e156fb1edc6faac7fe89e2b256bda
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{
15
23 template <typename Traits, template <typename> typename IteratorType, typename QueryType>
24 class KdTreeNearestQueryBase : public KdTreeQuery<Traits>, public QueryType
25 {
26 public:
27 using DataPoint = typename Traits::DataPoint;
28 using IndexType = typename Traits::IndexType;
29 using Scalar = typename DataPoint::Scalar;
30 using VectorType = typename DataPoint::VectorType;
31 using QueryAccelType = KdTreeQuery<Traits>;
32 using Iterator = IteratorType<typename Traits::IndexType>;
33
34 PONCA_MULTIARCH KdTreeNearestQueryBase(const StaticKdTreeBase<Traits>* kdtree,
35 typename QueryType::InputType input)
36 : KdTreeQuery<Traits>(kdtree), QueryType(input)
37 {
38 }
39
41 PONCA_MULTIARCH inline Iterator begin()
42 {
44 QueryType::reset();
45 this->search();
46 return Iterator(QueryType::m_nearest);
47 }
48
50 PONCA_MULTIARCH inline Iterator end() { return Iterator(QueryType::m_nearest + 1); }
51
52 protected:
53 PONCA_MULTIARCH inline void search()
54 {
56 QueryType::template getInputPosition<VectorType>(QueryAccelType::m_kdtree->points()),
57 [](IndexType, IndexType) {}, [this]() { return QueryType::descentDistanceThreshold(); },
58 [this](IndexType idx) { return QueryType::skipIndexFunctor(idx); },
59 [this](IndexType idx, IndexType, Scalar d) {
60 QueryType::m_nearest = idx;
61 QueryType::m_squared_distance = d;
62 return false;
63 });
64 }
65 };
66
72 template <typename Traits>
75 NearestIndexQuery<typename Traits::IndexType, typename Traits::DataPoint::Scalar>>;
76
83 template <typename Traits>
86 NearestPointQuery<typename Traits::IndexType, typename Traits::DataPoint>>;
87} // namespace Ponca
Input iterator to read the KdTreeKNearestQueryBase object.
Extension of the Query class that allows to read the result of a nearest neighbor search on the KdTre...
Iterator end()
Returns an iterator to the end of the nearest neighbor query.
Iterator begin()
Returns an iterator to the beginning of the nearest neighbor query.
const StaticKdTreeBase< Traits > * m_kdtree
[KdTreeQuery kdtree type]
Definition kdTreeQuery.h:45
void reset()
Init stack for a new search.
Definition kdTreeQuery.h:38
bool searchInternal(const VectorType &point, LeafPreparationFunctor prepareLeafTraversal, DescentDistanceThresholdFunctor descentDistanceThreshold, SkipIndexFunctor skipFunctor, ProcessNeighborFunctor processNeighborFunctor)
Search internally the neighbors of a point using the kdtree.
Definition kdTreeQuery.h:53
Customizable static base class for KdTree datastructure implementations.
Definition kdTree.h:138
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11
KdTreeNearestQueryBase< Traits, KdTreeNearestIterator, NearestPointQuery< typename Traits::IndexType, typename Traits::DataPoint > > KdTreeNearestPointQuery
Extension of the Query class that allows to read the result of a nearest neighbor search on the KdTre...
KdTreeNearestQueryBase< Traits, KdTreeNearestIterator, NearestIndexQuery< typename Traits::IndexType, typename Traits::DataPoint::Scalar > > KdTreeNearestIndexQuery
Extension of the Query class that allows to read the result of a nearest neighbor search on the KdTre...