Point Cloud Library (PCL)
1.7.0
Main Page
Modules
Namespaces
Classes
io
include
pcl
io
vtk_lib_io.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2011, Dirk Holz, University of Bonn.
6
* Copyright (c) 2012-, Open Perception, Inc.
7
*
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
12
* are met:
13
*
14
* * Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
16
* * Redistributions in binary form must reproduce the above
17
* copyright notice, this list of conditions and the following
18
* disclaimer in the documentation and/or other materials provided
19
* with the distribution.
20
* * Neither the name of the copyright holder(s) nor the names of its
21
* contributors may be used to endorse or promote products derived
22
* from this software without specific prior written permission.
23
*
24
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGE.
36
*
37
* $Id$
38
*
39
*/
40
41
#ifndef PCL_IO_VTK_LIB_IO_H_
42
#define PCL_IO_VTK_LIB_IO_H_
43
44
#include <pcl/point_types.h>
45
#include <pcl/point_cloud.h>
46
#include <pcl/PolygonMesh.h>
47
#include <pcl/TextureMesh.h>
48
#include <pcl/pcl_macros.h>
49
#include <pcl/conversions.h>
50
#include <pcl/io/pcd_io.h>
51
#include <pcl/range_image/range_image_planar.h>
52
53
// Ignore warnings in the above headers
54
#ifdef __GNUC__
55
#pragma GCC system_header
56
#endif
57
#include <vtkSmartPointer.h>
58
#include <vtkStructuredGrid.h>
59
#include <vtkPoints.h>
60
#include <vtkPointData.h>
61
#include <vtkCellArray.h>
62
#include <vtkUnsignedCharArray.h>
63
#include <vtkFloatArray.h>
64
#include <vtkPolyDataReader.h>
65
#include <vtkPolyDataWriter.h>
66
#include <vtkPLYReader.h>
67
#include <vtkPLYWriter.h>
68
#include <vtkOBJReader.h>
69
#include <vtkSTLReader.h>
70
#include <vtkSTLWriter.h>
71
#include <vtkPNGReader.h>
72
#include <vtkImageData.h>
73
#include <vtkPolyDataNormals.h>
74
75
namespace
pcl
76
{
77
namespace
io
78
{
79
/** \brief Convert vtkPolyData object to a PCL PolygonMesh
80
* \param[in] poly_data Pointer (vtkSmartPointer) to a vtkPolyData object
81
* \param[out] mesh PCL Polygon Mesh to fill
82
* \return Number of points in the point cloud of mesh.
83
*/
84
PCL_EXPORTS
int
85
vtk2mesh
(
const
vtkSmartPointer<vtkPolyData>
& poly_data,
86
pcl::PolygonMesh
& mesh);
87
88
/** \brief Convert vtkPolyData object to a PCL TextureMesh
89
* \note In addition to the vtk2mesh (const vtkSmartPointer<vtkPolyData>&, pcl::PolygonMesh&)
90
* method, it fills the mesh with the uv-coordinates.
91
* \param[in] poly_data Pointer (vtkSmartPointer) to a vtkPolyData object
92
* \param[out] mesh PCL TextureMesh to fill
93
* \return Number of points in the point cloud of mesh.
94
*/
95
PCL_EXPORTS
int
96
vtk2mesh
(
const
vtkSmartPointer<vtkPolyData>
& poly_data,
97
pcl::TextureMesh
& mesh);
98
99
100
/** \brief Convert a PCL PolygonMesh to a vtkPolyData object
101
* \param[in] mesh Reference to PCL Polygon Mesh
102
* \param[out] poly_data Pointer (vtkSmartPointer) to a vtkPolyData object
103
* \return Number of points in the point cloud of mesh.
104
*/
105
PCL_EXPORTS
int
106
mesh2vtk
(
const
pcl::PolygonMesh
& mesh,
107
vtkSmartPointer<vtkPolyData>
& poly_data);
108
109
/** \brief Load a \ref PolygonMesh object given an input file name, based on the file extension
110
* \param[in] file_name the name of the file containing the polygon data
111
* \param[out] mesh the object that we want to load the data in
112
* \ingroup io
113
*/
114
PCL_EXPORTS
int
115
loadPolygonFile
(
const
std::string &file_name,
116
pcl::PolygonMesh
& mesh);
117
118
/** \brief Save a \ref PolygonMesh object given an input file name, based on the file extension
119
* \param[in] file_name the name of the file to save the data to
120
* \param[in] mesh the object that contains the data
121
* \ingroup io
122
*/
123
PCL_EXPORTS
int
124
savePolygonFile
(
const
std::string &file_name,
125
const
pcl::PolygonMesh
& mesh);
126
127
/** \brief Load a VTK file into a \ref PolygonMesh object
128
* \param[in] file_name the name of the file that contains the data
129
* \param[out] mesh the object that we want to load the data in
130
* \ingroup io
131
*/
132
PCL_EXPORTS
int
133
loadPolygonFileVTK
(
const
std::string &file_name,
134
pcl::PolygonMesh
& mesh);
135
136
/** \brief Load a PLY file into a \ref PolygonMesh object
137
* \param[in] file_name the name of the file that contains the data
138
* \param[out] mesh the object that we want to load the data in
139
* \ingroup io
140
*/
141
PCL_EXPORTS
int
142
loadPolygonFilePLY
(
const
std::string &file_name,
143
pcl::PolygonMesh
& mesh);
144
145
/** \brief Load an OBJ file into a \ref PolygonMesh object
146
* \param[in] file_name the name of the file that contains the data
147
* \param[out] mesh the object that we want to load the data in
148
* \ingroup io
149
*/
150
PCL_EXPORTS
int
151
loadPolygonFileOBJ
(
const
std::string &file_name,
152
pcl::PolygonMesh
& mesh);
153
154
/** \brief Load an OBJ file into a \ref TextureMesh object.
155
* \note In addition to the loadPolygonFileOBJ (const std::string, pcl::PolygonMesh&)
156
* method, this method also loads the uv-coordinates from the file. It does not
157
* load the material information.
158
* \param[in] file_name the name of the file that contains the data
159
* \param[out] mesh the object that we want to load the data in
160
* \ingroup io
161
*/
162
PCL_EXPORTS
int
163
loadPolygonFileOBJ
(
const
std::string &file_name,
164
pcl::TextureMesh
& mesh);
165
166
167
/** \brief Load an STL file into a \ref PolygonMesh object
168
* \param[in] file_name the name of the file that contains the data
169
* \param[out] mesh the object that we want to load the data in
170
* \ingroup io
171
*/
172
PCL_EXPORTS
int
173
loadPolygonFileSTL
(
const
std::string &file_name,
174
pcl::PolygonMesh
& mesh);
175
176
/** \brief Save a \ref PolygonMesh object into a VTK file
177
* \param[in] file_name the name of the file to save the data to
178
* \param[in] mesh the object that contains the data
179
* \ingroup io
180
*/
181
PCL_EXPORTS
int
182
savePolygonFileVTK
(
const
std::string &file_name,
183
const
pcl::PolygonMesh
& mesh);
184
185
/** \brief Save a \ref PolygonMesh object into a PLY file
186
* \param[in] file_name the name of the file to save the data to
187
* \param[in] mesh the object that contains the data
188
* \ingroup io
189
*/
190
PCL_EXPORTS
int
191
savePolygonFilePLY
(
const
std::string &file_name,
192
const
pcl::PolygonMesh
& mesh);
193
194
/** \brief Save a \ref PolygonMesh object into an STL file
195
* \param[in] file_name the name of the file to save the data to
196
* \param[in] mesh the object that contains the data
197
* \ingroup io
198
*/
199
PCL_EXPORTS
int
200
savePolygonFileSTL
(
const
std::string &file_name,
201
const
pcl::PolygonMesh
& mesh);
202
203
/** \brief Write a \ref RangeImagePlanar object to a PNG file
204
* \param[in] file_name the name of the file to save the data to
205
* \param[in] range_image the object that contains the data
206
* \ingroup io
207
*/
208
PCL_EXPORTS
void
209
saveRangeImagePlanarFilePNG
(
const
std::string &file_name,
210
const
pcl::RangeImagePlanar
& range_image);
211
212
/** \brief Convert a pcl::PointCloud object to a VTK PolyData one.
213
* \param[in] cloud the input pcl::PointCloud object
214
* \param[out] polydata the resultant VTK PolyData object
215
* \ingroup io
216
*/
217
template
<
typename
Po
int
T>
void
218
pointCloudTovtkPolyData
(
const
pcl::PointCloud<PointT>
& cloud,
219
vtkPolyData*
const
polydata);
220
221
/** \brief Convert a PCLPointCloud2 object to a VTK PolyData object.
222
* \param[in] cloud the input PCLPointCloud2Ptr object
223
* \param[out] poly_data the resultant VTK PolyData object
224
* \ingroup io
225
*/
226
PCL_EXPORTS
void
227
pointCloudTovtkPolyData
(
const
pcl::PCLPointCloud2Ptr
& cloud,
vtkSmartPointer<vtkPolyData>
& poly_data);
228
229
/** \brief Convert a pcl::PointCloud object to a VTK StructuredGrid one.
230
* \param[in] cloud the input pcl::PointCloud object
231
* \param[out] structured_grid the resultant VTK StructuredGrid object
232
* \ingroup io
233
*/
234
template
<
typename
Po
int
T>
void
235
pointCloudTovtkStructuredGrid
(
const
pcl::PointCloud<PointT>
& cloud,
236
vtkStructuredGrid*
const
structured_grid);
237
238
/** \brief Convert a VTK PolyData object to a pcl::PointCloud one.
239
* \param[in] polydata the input VTK PolyData object
240
* \param[out] cloud the resultant pcl::PointCloud object
241
* \ingroup io
242
*/
243
template
<
typename
Po
int
T>
void
244
vtkPolyDataToPointCloud
(vtkPolyData*
const
polydata,
245
pcl::PointCloud<PointT>
& cloud);
246
247
/** \brief Convert a VTK StructuredGrid object to a pcl::PointCloud one.
248
* \param[in] structured_grid the input VTK StructuredGrid object
249
* \param[out] cloud the resultant pcl::PointCloud object
250
* \ingroup io
251
*/
252
template
<
typename
Po
int
T>
void
253
vtkStructuredGridToPointCloud
(vtkStructuredGrid*
const
structured_grid,
254
pcl::PointCloud<PointT>
& cloud);
255
256
}
257
}
258
259
#include <pcl/io/impl/vtk_lib_io.hpp>
260
261
#endif
/* PLC_IO_VTK_LIB_IO_H_ */