Ponca  f5b8b13495108d95baa74f687c24d962f21272fc
Point Cloud Analysis library
Loading...
Searching...
No Matches
knnGraphRangeIterator.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 <iterator>
10#include <cstddef>
11
12namespace Ponca {
13
14template <typename Traits>
15class KnnGraphRangeQuery;
16
31template <typename Traits>
33{
34protected:
35 friend class KnnGraphRangeQuery<Traits>;
36 using Index = typename Traits::IndexType;
37public:
38 // Tagged as an input iterator, because the increment logic is shared between iterators of the same queries.
39 // Which makes the iterator not valid when duplicated (through postfix increment for example).
40 using iterator_category = PONCA_MULTIARCH_CU_STD_NAMESPACE(input_iterator_tag);
41 using difference_type = std::ptrdiff_t;
42 using value_type = Index;
43 using pointer = Index*;
44 using reference = const Index&;
45
46 inline KnnGraphRangeIterator(KnnGraphRangeQuery<Traits>* query, Index index = Index(-1)) : m_query(query), m_index(index) {}
47
48public:
50 bool operator != (const KnnGraphRangeIterator& other) const{
51 return m_index != other.m_index;
52 }
53
55 bool operator == (const KnnGraphRangeIterator& other) const {
56 return m_index == other.m_index;
57 }
58
61 m_query->advance(*this);
62 return *this;
63 }
64
66 inline void operator++(value_type) { ++*this; }
67
69 inline reference operator *() const {
70 return const_cast<reference>(m_index);
71 }
72
73protected:
74 KnnGraphRangeQuery<Traits>* m_query {nullptr};
75 value_type m_index {-1};
76};
77
78} // namespace Ponca
Input iterator to read the KnnGraphRangeQuery object.
bool operator!=(const KnnGraphRangeIterator &other) const
Inequality operand.
KnnGraphRangeIterator & operator++()
Prefix increment.
reference operator*() const
Dereference operator.
void operator++(value_type)
Postfix increment.
bool operator==(const KnnGraphRangeIterator &other) const
Equality operand.
Extension of the Query class that allows to read the result of a range neighbor search on the KnnGrap...
This Source Code Form is subject to the terms of the Mozilla Public License, v.