Point Cloud Library (PCL)
1.12.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
() {}
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
OctreePointCloudAdjacencyContainer
* new_container =
147
new
OctreePointCloudAdjacencyContainer
;
148
new_container->
setNeighbors
(this->neighbors_);
149
new_container->
setPointCounter
(this->num_points_);
150
return
new_container;
151
}
152
153
/** \brief Add new point to container- this just counts points
154
* \note To actually store data in the leaves, need to specialize this
155
* for your point and data type as in supervoxel_clustering.hpp
156
*/
157
// param[in] new_point the new point to add
158
void
159
addPoint
(
const
PointInT&
/*new_point*/
)
160
{
161
using namespace
pcl::common
;
162
++num_points_;
163
}
164
165
/** \brief Function for working on data added. Base implementation does nothing
166
* */
167
void
168
computeData
()
169
{}
170
171
/** \brief Sets the number of points contributing to this leaf */
172
void
173
setPointCounter
(
uindex_t
points_arg)
174
{
175
num_points_ = points_arg;
176
}
177
178
/** \brief Clear the voxel centroid */
179
void
180
reset
()
override
181
{
182
neighbors_.clear();
183
num_points_ = 0;
184
data_ = DataT();
185
}
186
187
/** \brief Add new neighbor to voxel.
188
* \param[in] neighbor the new neighbor to add
189
*/
190
void
191
addNeighbor
(
OctreePointCloudAdjacencyContainer
* neighbor)
192
{
193
neighbors_.push_back(neighbor);
194
}
195
196
/** \brief Remove neighbor from neighbor set.
197
* \param[in] neighbor the neighbor to remove
198
*/
199
void
200
removeNeighbor
(
OctreePointCloudAdjacencyContainer
* neighbor)
201
{
202
for
(
iterator
neighb_it = neighbors_.begin(); neighb_it != neighbors_.end();
203
++neighb_it) {
204
if
(*neighb_it == neighbor) {
205
neighbors_.erase(neighb_it);
206
return
;
207
}
208
}
209
}
210
211
/** \brief Sets the whole neighbor set
212
* \param[in] neighbor_arg the new set
213
*/
214
void
215
setNeighbors
(
const
NeighborListT
& neighbor_arg)
216
{
217
neighbors_ = neighbor_arg;
218
}
219
220
private
:
221
uindex_t
num_points_;
222
NeighborListT
neighbors_;
223
DataT data_;
224
};
225
}
// namespace octree
226
}
// 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:55
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::~OctreePointCloudAdjacencyContainer
~OctreePointCloudAdjacencyContainer()
Empty class deconstructor.
Definition
octree_pointcloud_adjacency_container.h:85
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:215
pcl::octree::OctreePointCloudAdjacencyContainer::addPoint
void addPoint(const PointInT &)
Add new point to container- this just counts points.
Definition
octree_pointcloud_adjacency_container.h:159
pcl::octree::OctreePointCloudAdjacencyContainer::addNeighbor
void addNeighbor(OctreePointCloudAdjacencyContainer *neighbor)
Add new neighbor to voxel.
Definition
octree_pointcloud_adjacency_container.h:191
pcl::octree::OctreePointCloudAdjacencyContainer::removeNeighbor
void removeNeighbor(OctreePointCloudAdjacencyContainer *neighbor)
Remove neighbor from neighbor set.
Definition
octree_pointcloud_adjacency_container.h:200
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< PointT, VoxelData >::reset
void reset() override
Definition
octree_pointcloud_adjacency_container.h:180
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:173
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:168
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