Ponca  7abd0fd82719106ad460aa0f2070dffbe375d727
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;
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 };
72 template <typename Traits>
76
83 template <typename Traits>
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.
Query object that provides a method to search neighbors on the KdTree depending on a distance thresho...
Definition kdTreeQuery.h:24
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
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 concepts.h:11