Point Cloud Library (PCL) 1.15.0
Loading...
Searching...
No Matches
cloud_iterator.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2012-, Open Perception, Inc.
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of the copyright holder(s) nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 *
37 */
38
39#pragma once
40
41#include <pcl/point_cloud.h>
42#include <pcl/PointIndices.h>
43#include <pcl/correspondence.h>
44
45namespace pcl
46{
47 /** \brief Iterator class for point clouds with or without given indices
48 * \author Suat Gedikli
49 */
50 template <typename PointT>
52 {
53 public:
55
56 CloudIterator (PointCloud<PointT>& cloud, const Indices& indices);
57
58 CloudIterator (PointCloud<PointT>& cloud, const PointIndices& indices);
59
60 CloudIterator (PointCloud<PointT>& cloud, const Correspondences& corrs, bool source);
61
63
64 void operator ++ ();
65
66 void operator ++ (int);
67
68 PointT& operator* () const;
69
70 PointT* operator-> () const;
71
72 unsigned getCurrentPointIndex () const;
73
74 unsigned getCurrentIndex () const;
75
76 /** \brief Size of the range the iterator is going through. Depending on how the CloudIterator was constructed this is the size of the cloud or indices/correspondences. */
77 std::size_t size () const;
78
79 void reset ();
80
81 bool isValid () const;
82
83 operator bool () const
84 {
85 return isValid ();
86 }
87 private:
88
89 class Iterator
90 {
91 public:
92 virtual ~Iterator () = default;
93
94 virtual void operator ++ () = 0;
95
96 virtual void operator ++ (int) = 0;
97
98 virtual PointT& operator* () const = 0;
99
100 virtual PointT* operator-> () const = 0;
101
102 virtual unsigned getCurrentPointIndex () const = 0;
103
104 virtual unsigned getCurrentIndex () const = 0;
105
106 /** \brief Size of the range the iterator is going through. Depending on how the CloudIterator was constructed this is the size of the cloud or indices/correspondences. */
107 virtual std::size_t size () const = 0;
108
109 virtual void reset () = 0;
110
111 virtual bool isValid () const = 0;
112 };
113 Iterator* iterator_;
114 };
115
116 /** \brief Iterator class for point clouds with or without given indices
117 * \author Suat Gedikli
118 */
119 template <typename PointT>
121 {
122 public:
124
125 ConstCloudIterator (const PointCloud<PointT>& cloud, const Indices& indices);
126
127 ConstCloudIterator (const PointCloud<PointT>& cloud, const PointIndices& indices);
128
129 ConstCloudIterator (const PointCloud<PointT>& cloud, const Correspondences& corrs, bool source);
130
132
133 void operator ++ ();
134
135 void operator ++ (int);
136
137 const PointT& operator* () const;
138
139 const PointT* operator-> () const;
140
141 unsigned getCurrentPointIndex () const;
142
143 unsigned getCurrentIndex () const;
144
145 /** \brief Size of the range the iterator is going through. Depending on how the ConstCloudIterator was constructed this is the size of the cloud or indices/correspondences. */
146 std::size_t size () const;
147
148 void reset ();
149
150 bool isValid () const;
151
152 operator bool () const
153 {
154 return isValid ();
155 }
156 private:
157
158 class Iterator
159 {
160 public:
161 virtual ~Iterator () = default;
162
163 virtual void operator ++ () = 0;
164
165 virtual void operator ++ (int) = 0;
166
167 virtual const PointT& operator* () const = 0;
168
169 virtual const PointT* operator-> () const = 0;
170
171 virtual unsigned getCurrentPointIndex () const = 0;
172
173 virtual unsigned getCurrentIndex () const = 0;
174
175 /** \brief Size of the range the iterator is going through. Depending on how the ConstCloudIterator was constructed this is the size of the cloud or indices/correspondences. */
176 virtual std::size_t size () const = 0;
177
178 virtual void reset () = 0;
179
180 virtual bool isValid () const = 0;
181 };
182
183 class DefaultConstIterator;
184 class ConstIteratorIdx;
185 Iterator* iterator_;
186 };
187
188} // namespace pcl
189
190#include <pcl/impl/cloud_iterator.hpp>
Iterator class for point clouds with or without given indices.
unsigned getCurrentIndex() const
unsigned getCurrentPointIndex() const
std::size_t size() const
Size of the range the iterator is going through.
PointT * operator->() const
PointT & operator*() const
Iterator class for point clouds with or without given indices.
const PointT * operator->() const
unsigned getCurrentIndex() const
unsigned getCurrentPointIndex() const
const PointT & operator*() const
std::size_t size() const
Size of the range the iterator is going through.
PointCloud represents the base class in PCL for storing collections of 3D points.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133
A point structure representing Euclidean xyz coordinates, and the RGB color.