Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
surface
impl
reconstruction.hpp
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2010-2011, Willow Garage, 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 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
* $Id$
37
*
38
*/
39
40
#ifndef PCL_SURFACE_RECONSTRUCTION_IMPL_H_
41
#define PCL_SURFACE_RECONSTRUCTION_IMPL_H_
42
43
#include <pcl/conversions.h>
// for pcl::toPCLPointCloud2
44
#include <pcl/search/kdtree.h>
// for KdTree
45
#include <pcl/search/organized.h>
// for OrganizedNeighbor
46
47
48
namespace
pcl
49
{
50
51
template
<
typename
Po
int
InT>
void
52
SurfaceReconstruction<PointInT>::reconstruct
(
pcl::PolygonMesh
&output)
53
{
54
// Copy the header
55
output.
header
=
input_
->header;
56
57
if
(!
initCompute
())
58
{
59
output.
cloud
.
width
= output.
cloud
.
height
= 0;
60
output.
cloud
.
data
.clear ();
61
output.
polygons
.clear ();
62
return
;
63
}
64
65
// Check if a space search locator was given
66
if
(
check_tree_
)
67
{
68
if
(!
tree_
)
69
{
70
if
(
input_
->isOrganized ())
71
tree_
.reset (
new
pcl::search::OrganizedNeighbor<PointInT>
());
72
else
73
tree_
.reset (
new
pcl::search::KdTree<PointInT>
(
false
));
74
}
75
76
// Send the surface dataset to the spatial locator
77
tree_
->setInputCloud (
input_
,
indices_
);
78
}
79
80
// Set up the output dataset
81
pcl::toPCLPointCloud2
(*
input_
, output.
cloud
);
/// NOTE: passing in boost shared pointer with * as const& should be OK here
82
output.
polygons
.clear ();
83
output.
polygons
.reserve (2*
indices_
->size ());
/// NOTE: usually the number of triangles is around twice the number of vertices
84
// Perform the actual surface reconstruction
85
performReconstruction
(output);
86
87
deinitCompute
();
88
}
89
90
91
template
<
typename
Po
int
InT>
void
92
SurfaceReconstruction<PointInT>::reconstruct
(
pcl::PointCloud<PointInT>
&points,
93
std::vector<pcl::Vertices> &polygons)
94
{
95
// Copy the header
96
points.
header
=
input_
->header;
97
98
if
(!
initCompute
())
99
{
100
points.
width
= points.
height
= 0;
101
points.
clear
();
102
polygons.clear ();
103
return
;
104
}
105
106
// Check if a space search locator was given
107
if
(
check_tree_
)
108
{
109
if
(!
tree_
)
110
{
111
if
(
input_
->isOrganized ())
112
tree_
.reset (
new
pcl::search::OrganizedNeighbor<PointInT>
());
113
else
114
tree_
.reset (
new
pcl::search::KdTree<PointInT>
(
false
));
115
}
116
117
// Send the surface dataset to the spatial locator
118
tree_
->setInputCloud (
input_
,
indices_
);
119
}
120
121
// Set up the output dataset
122
polygons.clear ();
123
polygons.reserve (2 *
indices_
->size ());
/// NOTE: usually the number of triangles is around twice the number of vertices
124
// Perform the actual surface reconstruction
125
performReconstruction
(points, polygons);
126
127
deinitCompute
();
128
}
129
130
131
template
<
typename
Po
int
InT>
void
132
MeshConstruction<PointInT>::reconstruct
(
pcl::PolygonMesh
&output)
133
{
134
// Copy the header
135
output.
header
=
input_
->header;
136
137
if
(!
initCompute
())
138
{
139
output.
cloud
.
width
= output.
cloud
.
height
= 1;
140
output.
cloud
.
data
.clear ();
141
output.
polygons
.clear ();
142
return
;
143
}
144
145
// Check if a space search locator was given
146
if
(check_tree_)
147
{
148
if
(!tree_)
149
{
150
if
(input_->isOrganized ())
151
tree_.reset (
new
pcl::search::OrganizedNeighbor<PointInT>
());
152
else
153
tree_.reset (
new
pcl::search::KdTree<PointInT>
(
false
));
154
}
155
156
// Send the surface dataset to the spatial locator
157
tree_->setInputCloud (input_, indices_);
158
}
159
160
// Set up the output dataset
161
pcl::toPCLPointCloud2
(*input_, output.
cloud
);
/// NOTE: passing in boost shared pointer with * as const& should be OK here
162
// output.polygons.clear ();
163
// output.polygons.reserve (2*indices_->size ()); /// NOTE: usually the number of triangles is around twice the number of vertices
164
// Perform the actual surface reconstruction
165
performReconstruction (output);
166
167
deinitCompute ();
168
}
169
170
171
template
<
typename
Po
int
InT>
void
172
MeshConstruction<PointInT>::reconstruct
(std::vector<pcl::Vertices> &polygons)
173
{
174
if
(!
initCompute
())
175
{
176
polygons.clear ();
177
return
;
178
}
179
180
// Check if a space search locator was given
181
if
(
check_tree_
)
182
{
183
if
(!
tree_
)
184
{
185
if
(
input_
->isOrganized ())
186
tree_
.reset (
new
pcl::search::OrganizedNeighbor<PointInT>
());
187
else
188
tree_
.reset (
new
pcl::search::KdTree<PointInT>
(
false
));
189
}
190
191
// Send the surface dataset to the spatial locator
192
tree_
->setInputCloud (
input_
,
indices_
);
193
}
194
195
// Set up the output dataset
196
//polygons.clear ();
197
//polygons.reserve (2 * indices_->size ()); /// NOTE: usually the number of triangles is around twice the number of vertices
198
// Perform the actual surface reconstruction
199
performReconstruction
(polygons);
200
201
deinitCompute
();
202
}
203
204
}
// namespace pcl
205
206
#endif
// PCL_SURFACE_RECONSTRUCTION_IMPL_H_
207
pcl::MeshConstruction::performReconstruction
virtual void performReconstruction(pcl::PolygonMesh &output)=0
Abstract surface reconstruction method.
pcl::MeshConstruction::reconstruct
void reconstruct(pcl::PolygonMesh &output) override
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>.
Definition
reconstruction.hpp:132
pcl::MeshConstruction::check_tree_
bool check_tree_
A flag specifying whether or not the derived reconstruction algorithm needs the search object tree.
Definition
reconstruction.h:228
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
Definition
pcl_base.h:147
pcl::PCLBase< PointInT >::indices_
IndicesPtr indices_
Definition
pcl_base.h:150
pcl::PCLBase< PointInT >::initCompute
bool initCompute()
pcl::PCLBase< PointInT >::deinitCompute
bool deinitCompute()
pcl::PCLSurfaceBase::tree_
KdTreePtr tree_
A pointer to the spatial search object.
Definition
reconstruction.h:96
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition
point_cloud.h:174
pcl::PointCloud::width
std::uint32_t width
The point cloud width (if organized as an image-structure).
Definition
point_cloud.h:399
pcl::PointCloud::header
pcl::PCLHeader header
The point cloud header.
Definition
point_cloud.h:393
pcl::PointCloud::height
std::uint32_t height
The point cloud height (if organized as an image-structure).
Definition
point_cloud.h:401
pcl::PointCloud::clear
void clear()
Removes all points in a cloud and sets the width and height to 0.
Definition
point_cloud.h:886
pcl::SurfaceReconstruction::performReconstruction
virtual void performReconstruction(pcl::PolygonMesh &output)=0
Abstract surface reconstruction method.
pcl::SurfaceReconstruction::check_tree_
bool check_tree_
A flag specifying whether or not the derived reconstruction algorithm needs the search object tree.
Definition
reconstruction.h:156
pcl::SurfaceReconstruction::reconstruct
void reconstruct(pcl::PolygonMesh &output) override
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>.
Definition
reconstruction.hpp:52
pcl::search::KdTree
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
Definition
kdtree.h:62
pcl::search::OrganizedNeighbor
OrganizedNeighbor is a class for optimized nearest neighbor search in organized projectable point clo...
Definition
organized.h:66
pcl
Definition
convolution.h:46
pcl::toPCLPointCloud2
void toPCLPointCloud2(const pcl::PointCloud< PointT > &cloud, pcl::PCLPointCloud2 &msg, bool padding)
Convert a pcl::PointCloud<T> object to a PCLPointCloud2 binary data blob.
Definition
conversions.h:372
pcl::PCLPointCloud2::width
uindex_t width
Definition
PCLPointCloud2.h:21
pcl::PCLPointCloud2::height
uindex_t height
Definition
PCLPointCloud2.h:20
pcl::PCLPointCloud2::data
std::vector< std::uint8_t > data
Definition
PCLPointCloud2.h:30
pcl::PolygonMesh
Definition
PolygonMesh.h:15
pcl::PolygonMesh::header
::pcl::PCLHeader header
Definition
PolygonMesh.h:18
pcl::PolygonMesh::polygons
std::vector< ::pcl::Vertices > polygons
Definition
PolygonMesh.h:22
pcl::PolygonMesh::cloud
::pcl::PCLPointCloud2 cloud
Definition
PolygonMesh.h:20