Ponca  7d8ac87a7de01d881c9fde3c42e397b44bffb901
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;
33
35 typename QueryType::InputType input)
36 : KdTreeQuery<Traits>(kdtree), QueryType(input)
37 {
38 }
39
41 PONCA_MULTIARCH inline Iterator begin()
42 {
43 QueryAccelType::reset();
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
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:318
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
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
This Source Code Form is subject to the terms of the Mozilla Public License, v.