Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
octree
octree_pointcloud_adjacency_container.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2012, Jeremie Papon
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 Willow Garage, Inc. 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
* Author : jpapon@gmail.com
37
* Email : jpapon@gmail.com
38
*/
39
40
#pragma once
41
42
#include <list>
// for std::list
43
44
namespace
pcl
{
45
46
namespace
octree
{
47
/** \brief @b Octree adjacency leaf container class- stores a list of pointers to
48
* neighbors, number of points added, and a DataT value \note This class implements a
49
* leaf node that stores pointers to neighboring leaves \note This class also has a
50
* virtual computeData function, which is called by
51
* octreePointCloudAdjacency::addPointsFromInputCloud. \note You should make explicit
52
* instantiations of it for your pointtype/datatype combo (if needed) see
53
* supervoxel_clustering.hpp for an example of this
54
*/
55
template
<
typename
Po
int
InT,
typename
DataT = Po
int
InT>
56
class
OctreePointCloudAdjacencyContainer
:
public
OctreeContainerBase
{
57
template
<
typename
T,
typename
U,
typename
V>
58
friend
class
OctreePointCloudAdjacency
;
59
60
public
:
61
using
NeighborListT
= std::list<OctreePointCloudAdjacencyContainer<PointInT, DataT>*>;
62
using
const_iterator
=
typename
NeighborListT::const_iterator;
63
// const iterators to neighbors
64
inline
const_iterator
65
cbegin
()
const
66
{
67
return
(neighbors_.begin());
68
}
69
inline
const_iterator
70
cend
()
const
71
{
72
return
(neighbors_.end());
73
}
74
// size of neighbors
75
inline
std::size_t
76
size
()
const
77
{
78
return
neighbors_.size();
79
}
80
81
/** \brief Class initialization. */
82
OctreePointCloudAdjacencyContainer
() :
OctreeContainerBase
() { this->
reset
(); }
83
84
/** \brief Empty class deconstructor. */
85
~OctreePointCloudAdjacencyContainer
()
override
=
default
;
86
87
/** \brief Returns the number of neighbors this leaf has
88
* \returns number of neighbors
89
*/
90
std::size_t
91
getNumNeighbors
()
const
92
{
93
return
neighbors_.size();
94
}
95
96
/** \brief Gets the number of points contributing to this leaf */
97
uindex_t
98
getPointCounter
()
const
99
{
100
return
num_points_;
101
}
102
103
/** \brief Returns a reference to the data member to access it without copying */
104
DataT&
105
getData
()
106
{
107
return
data_;
108
}
109
110
/** \brief Sets the data member
111
* \param[in] data_arg New value for data
112
*/
113
void
114
setData
(
const
DataT& data_arg)
115
{
116
data_ = data_arg;
117
}
118
119
/** \brief virtual method to get size of container
120
* \return number of points added to leaf node container.
121
*/
122
uindex_t
123
getSize
()
const override
124
{
125
return
num_points_;
126
}
127
128
protected
:
129
// iterators to neighbors
130
using
iterator
=
typename
NeighborListT::iterator;
131
inline
iterator
132
begin
()
133
{
134
return
(neighbors_.begin());
135
}
136
inline
iterator
137
end
()
138
{
139
return
(neighbors_.end());
140
}
141
142
/** \brief deep copy function */
143
virtual
OctreePointCloudAdjacencyContainer
*
144
deepCopy
()
const
145
{
146
auto
* new_container =
new
OctreePointCloudAdjacencyContainer
;
147
new_container->setNeighbors(this->neighbors_);
148
new_container->setPointCounter(this->num_points_);
149
return
new_container;
150
}
151
152
/** \brief Add new point to container- this just counts points
153
* \note To actually store data in the leaves, need to specialize this
154
* for your point and data type as in supervoxel_clustering.hpp
155
*/
156
// param[in] new_point the new point to add
157
void
158
addPoint
(
const
PointInT&
/*new_point*/
)
159
{
160
using namespace
pcl::common
;
161
++num_points_;
162
}
163
164
/** \brief Function for working on data added. Base implementation does nothing
165
* */
166
void
167
computeData
()
168
{}
169
170
/** \brief Sets the number of points contributing to this leaf */
171
void
172
setPointCounter
(
uindex_t
points_arg)
173
{
174
num_points_ = points_arg;
175
}
176
177
/** \brief Clear the voxel centroid */
178
void
179
reset
()
override
180
{
181
neighbors_.clear();
182
num_points_ = 0;
183
data_ = DataT();
184
}
185
186
/** \brief Add new neighbor to voxel.
187
* \param[in] neighbor the new neighbor to add
188
*/
189
void
190
addNeighbor
(
OctreePointCloudAdjacencyContainer
* neighbor)
191
{
192
neighbors_.push_back(neighbor);
193
}
194
195
/** \brief Remove neighbor from neighbor set.
196
* \param[in] neighbor the neighbor to remove
197
*/
198
void
199
removeNeighbor
(
OctreePointCloudAdjacencyContainer
* neighbor)
200
{
201
for
(
auto
neighb_it = neighbors_.begin(); neighb_it != neighbors_.end();
202
++neighb_it) {
203
if
(*neighb_it == neighbor) {
204
neighbors_.erase(neighb_it);
205
return
;
206
}
207
}
208
}
209
210
/** \brief Sets the whole neighbor set
211
* \param[in] neighbor_arg the new set
212
*/
213
void
214
setNeighbors
(
const
NeighborListT
& neighbor_arg)
215
{
216
neighbors_ = neighbor_arg;
217
}
218
219
private
:
220
uindex_t
num_points_;
221
NeighborListT
neighbors_;
222
DataT data_;
223
};
224
}
// namespace octree
225
}
// namespace pcl
pcl::octree::OctreeContainerBase
Octree container class that can serve as a base to construct own leaf node container classes.
Definition
octree_container.h:56
pcl::octree::OctreePointCloudAdjacencyContainer
Octree adjacency leaf container class- stores a list of pointers to neighbors, number of points added...
Definition
octree_pointcloud_adjacency_container.h:56
pcl::octree::OctreePointCloudAdjacencyContainer::end
iterator end()
Definition
octree_pointcloud_adjacency_container.h:137
pcl::octree::OctreePointCloudAdjacencyContainer::cend
const_iterator cend() const
Definition
octree_pointcloud_adjacency_container.h:70
pcl::octree::OctreePointCloudAdjacencyContainer::setNeighbors
void setNeighbors(const NeighborListT &neighbor_arg)
Sets the whole neighbor set.
Definition
octree_pointcloud_adjacency_container.h:214
pcl::octree::OctreePointCloudAdjacencyContainer::addPoint
void addPoint(const PointInT &)
Add new point to container- this just counts points.
Definition
octree_pointcloud_adjacency_container.h:158
pcl::octree::OctreePointCloudAdjacencyContainer::addNeighbor
void addNeighbor(OctreePointCloudAdjacencyContainer *neighbor)
Add new neighbor to voxel.
Definition
octree_pointcloud_adjacency_container.h:190
pcl::octree::OctreePointCloudAdjacencyContainer::removeNeighbor
void removeNeighbor(OctreePointCloudAdjacencyContainer *neighbor)
Remove neighbor from neighbor set.
Definition
octree_pointcloud_adjacency_container.h:199
pcl::octree::OctreePointCloudAdjacencyContainer::cbegin
const_iterator cbegin() const
Definition
octree_pointcloud_adjacency_container.h:65
pcl::octree::OctreePointCloudAdjacencyContainer::begin
iterator begin()
Definition
octree_pointcloud_adjacency_container.h:132
pcl::octree::OctreePointCloudAdjacencyContainer::const_iterator
typename NeighborListT::const_iterator const_iterator
Definition
octree_pointcloud_adjacency_container.h:62
pcl::octree::OctreePointCloudAdjacencyContainer::getSize
uindex_t getSize() const override
virtual method to get size of container
Definition
octree_pointcloud_adjacency_container.h:123
pcl::octree::OctreePointCloudAdjacencyContainer::deepCopy
virtual OctreePointCloudAdjacencyContainer * deepCopy() const
deep copy function
Definition
octree_pointcloud_adjacency_container.h:144
pcl::octree::OctreePointCloudAdjacencyContainer::getData
DataT & getData()
Returns a reference to the data member to access it without copying.
Definition
octree_pointcloud_adjacency_container.h:105
pcl::octree::OctreePointCloudAdjacencyContainer::getPointCounter
uindex_t getPointCounter() const
Gets the number of points contributing to this leaf.
Definition
octree_pointcloud_adjacency_container.h:98
pcl::octree::OctreePointCloudAdjacencyContainer::getNumNeighbors
std::size_t getNumNeighbors() const
Returns the number of neighbors this leaf has.
Definition
octree_pointcloud_adjacency_container.h:91
pcl::octree::OctreePointCloudAdjacencyContainer::size
std::size_t size() const
Definition
octree_pointcloud_adjacency_container.h:76
pcl::octree::OctreePointCloudAdjacencyContainer::reset
void reset() override
Clear the voxel centroid.
Definition
octree_pointcloud_adjacency_container.h:179
pcl::octree::OctreePointCloudAdjacencyContainer::iterator
typename NeighborListT::iterator iterator
Definition
octree_pointcloud_adjacency_container.h:130
pcl::octree::OctreePointCloudAdjacencyContainer< PointT, VoxelData >::OctreePointCloudAdjacency
friend class OctreePointCloudAdjacency
Definition
octree_pointcloud_adjacency_container.h:58
pcl::octree::OctreePointCloudAdjacencyContainer::setPointCounter
void setPointCounter(uindex_t points_arg)
Sets the number of points contributing to this leaf.
Definition
octree_pointcloud_adjacency_container.h:172
pcl::octree::OctreePointCloudAdjacencyContainer::OctreePointCloudAdjacencyContainer
OctreePointCloudAdjacencyContainer()
Class initialization.
Definition
octree_pointcloud_adjacency_container.h:82
pcl::octree::OctreePointCloudAdjacencyContainer::NeighborListT
std::list< OctreePointCloudAdjacencyContainer< PointInT, DataT > * > NeighborListT
Definition
octree_pointcloud_adjacency_container.h:61
pcl::octree::OctreePointCloudAdjacencyContainer::computeData
void computeData()
Function for working on data added.
Definition
octree_pointcloud_adjacency_container.h:167
pcl::octree::OctreePointCloudAdjacencyContainer::~OctreePointCloudAdjacencyContainer
~OctreePointCloudAdjacencyContainer() override=default
Empty class deconstructor.
pcl::octree::OctreePointCloudAdjacencyContainer::setData
void setData(const DataT &data_arg)
Sets the data member.
Definition
octree_pointcloud_adjacency_container.h:114
pcl::common
Definition
generate.h:50
pcl::octree
Definition
color_coding.h:47
pcl
Definition
convolution.h:46
pcl::uindex_t
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
Definition
types.h:120