Ponca  7d8ac87a7de01d881c9fde3c42e397b44bffb901
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 <cstddef>
10
11namespace Ponca
12{
13
14 template <typename Traits>
15 class KnnGraphRangeQuery;
16
31 template <typename Traits>
33 {
34 protected:
35 friend class KnnGraphRangeQuery<Traits>;
36 using Index = typename Traits::IndexType;
37
38 public:
39 // Tagged as an input iterator, because the increment logic is shared between iterators of the same queries.
40 // Which makes the iterator not valid when duplicated (through postfix increment for example).
41 using iterator_category = std::input_iterator_tag;
42 using difference_type = std::ptrdiff_t;
43 using value_type = Index;
44 using pointer = Index*;
45 using reference = const Index&;
46
47 inline KnnGraphRangeIterator(KnnGraphRangeQuery<Traits>* query, Index index = Index(-1))
48 : m_query(query), m_index(index)
49 {
50 }
51
52 public:
54 bool operator!=(const KnnGraphRangeIterator& other) const { return m_index != other.m_index; }
55
57 bool operator==(const KnnGraphRangeIterator& other) const { return m_index == other.m_index; }
58
61 {
62 m_query->advance(*this);
63 return *this;
64 }
65
67 inline void operator++(value_type) { ++*this; }
68
70 inline reference operator*() const { return const_cast<reference>(m_index); }
71
72 protected:
73 KnnGraphRangeQuery<Traits>* m_query{nullptr};
74 value_type m_index{-1};
75 };
76
77} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:318
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.