Point Cloud Library (PCL) 1.15.0
Loading...
Searching...
No Matches
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#pragma once
42
43#include <pcl/point_cloud.h>
44#include <pcl/PolygonMesh.h>
45#include <pcl/TextureMesh.h>
46#include <pcl/pcl_macros.h>
47#include <pcl/conversions.h>
48#include <pcl/range_image/range_image_planar.h>
49
50// Ignore warnings in the above headers
51#ifdef __GNUC__
52#pragma GCC system_header
53#endif
54#include <vtkPolyData.h> // for vtkPolyData
55#include <vtkSmartPointer.h>
56#include <vtkStructuredGrid.h>
57
58namespace pcl
59{
60 namespace io
61 {
62 /** \brief Convert vtkPolyData object to a PCL PolygonMesh
63 * \param[in] poly_data Pointer (vtkSmartPointer) to a vtkPolyData object
64 * \param[out] mesh PCL Polygon Mesh to fill
65 * \return Number of points in the point cloud of mesh.
66 */
67 PCL_EXPORTS int
69 pcl::PolygonMesh& mesh);
70
71 /** \brief Convert vtkPolyData object to a PCL TextureMesh
72 * \note In addition to the vtk2mesh (const vtkSmartPointer<vtkPolyData>&, pcl::PolygonMesh&)
73 * method, it fills the mesh with the uv-coordinates.
74 * \param[in] poly_data Pointer (vtkSmartPointer) to a vtkPolyData object
75 * \param[out] mesh PCL TextureMesh to fill
76 * \return Number of points in the point cloud of mesh.
77 */
78 PCL_EXPORTS int
80 pcl::TextureMesh& mesh);
81
82
83 /** \brief Convert a PCL PolygonMesh to a vtkPolyData object
84 * \param[in] mesh Reference to PCL Polygon Mesh
85 * \param[out] poly_data Pointer (vtkSmartPointer) to a vtkPolyData object
86 * \return Number of points in the point cloud of mesh.
87 */
88 PCL_EXPORTS int
91
92 /** \brief Load a \ref PolygonMesh object given an input file name, based on the file extension
93 * \param[in] file_name the name of the file containing the polygon data
94 * \param[out] mesh the object that we want to load the data in
95 * \return Number of points in the point cloud of the mesh.
96 * \ingroup io
97 */
98 PCL_EXPORTS int
99 loadPolygonFile (const std::string &file_name,
100 pcl::PolygonMesh& mesh);
101
102 /** \brief Save a \ref PolygonMesh object given an input file name, based on the file extension
103 * \param[in] file_name the name of the file to save the data to
104 * \param[in] mesh the object that contains the data
105 * \param[in] binary_format if true, exported file is in binary format
106 * \return True if successful, false otherwise
107 * \ingroup io
108 */
109 PCL_EXPORTS bool
110 savePolygonFile (const std::string &file_name,
111 const pcl::PolygonMesh& mesh,
112 const bool binary_format = true);
113
114 /** \brief Load a VTK file into a \ref PolygonMesh object
115 * \param[in] file_name the name of the file that contains the data
116 * \param[out] mesh the object that we want to load the data in
117 * \return Number of points in the point cloud of the mesh.
118 * \ingroup io
119 */
120 PCL_EXPORTS int
121 loadPolygonFileVTK (const std::string &file_name,
122 pcl::PolygonMesh& mesh);
123
124 /** \brief Load a PLY file into a \ref PolygonMesh object
125 * \param[in] file_name the name of the file that contains the data
126 * \param[out] mesh the object that we want to load the data in
127 * \return Number of points in the point cloud of the mesh.
128 * \ingroup io
129 */
130 PCL_EXPORTS int
131 loadPolygonFilePLY (const std::string &file_name,
132 pcl::PolygonMesh& mesh);
133
134 /** \brief Load an OBJ file into a \ref PolygonMesh object
135 * \param[in] file_name the name of the file that contains the data
136 * \param[out] mesh the object that we want to load the data in
137 * \return Number of points in the point cloud of the mesh.
138 * \ingroup io
139 */
140 PCL_EXPORTS int
141 loadPolygonFileOBJ (const std::string &file_name,
142 pcl::PolygonMesh& mesh);
143
144 /** \brief Load an OBJ file into a \ref TextureMesh object.
145 * \note In addition to the loadPolygonFileOBJ (const std::string, pcl::PolygonMesh&)
146 * method, this method also loads the uv-coordinates from the file. It does not
147 * load the material information.
148 * \param[in] file_name the name of the file that contains the data
149 * \param[out] mesh the object that we want to load the data in
150 * \return Number of points in the point cloud of the mesh.
151 * \ingroup io
152 */
153 PCL_EXPORTS int
154 loadPolygonFileOBJ (const std::string &file_name,
155 pcl::TextureMesh& mesh);
156
157
158 /** \brief Load an STL file into a \ref PolygonMesh object
159 * \param[in] file_name the name of the file that contains the data
160 * \param[out] mesh the object that we want to load the data in
161 * \return Number of points in the point cloud of the mesh.
162 * \ingroup io
163 */
164 PCL_EXPORTS int
165 loadPolygonFileSTL (const std::string &file_name,
166 pcl::PolygonMesh& mesh);
167
168 /** \brief Save a \ref PolygonMesh object into a VTK file
169 * \param[in] file_name the name of the file to save the data to
170 * \param[in] mesh the object that contains the data
171 * \param[in] binary_format if true, exported file is in binary format
172 * \return True if successful, false otherwise
173 * \ingroup io
174 */
175 PCL_EXPORTS bool
176 savePolygonFileVTK (const std::string &file_name,
177 const pcl::PolygonMesh& mesh,
178 const bool binary_format = true);
179
180 /** \brief Save a \ref PolygonMesh object into a PLY file
181 * \param[in] file_name the name of the file to save the data to
182 * \param[in] mesh the object that contains the data
183 * \param[in] binary_format if true, exported file is in binary format
184 * \return True if successful, false otherwise
185 * \ingroup io
186 */
187 PCL_EXPORTS bool
188 savePolygonFilePLY (const std::string &file_name,
189 const pcl::PolygonMesh& mesh,
190 const bool binary_format = true);
191
192 /** \brief Save a \ref PolygonMesh object into an STL file
193 * \param[in] file_name the name of the file to save the data to
194 * \param[in] mesh the object that contains the data
195 * \param[in] binary_format if true, exported file is in binary format
196 * \return True if successful, false otherwise
197 * \ingroup io
198 */
199 PCL_EXPORTS bool
200 savePolygonFileSTL (const std::string &file_name,
201 const pcl::PolygonMesh& mesh,
202 const bool binary_format = true);
203
204 /** \brief Write a \ref RangeImagePlanar object to a PNG file
205 * \param[in] file_name the name of the file to save the data to
206 * \param[in] range_image the object that contains the data
207 * \ingroup io
208 */
209 PCL_EXPORTS void
210 saveRangeImagePlanarFilePNG (const std::string &file_name,
211 const pcl::RangeImagePlanar& range_image);
212
213 /** \brief Convert a pcl::PointCloud object to a VTK PolyData one.
214 * \param[in] cloud the input pcl::PointCloud object
215 * \param[out] polydata the resultant VTK PolyData object
216 * \ingroup io
217 */
218 template <typename PointT> void
220 vtkPolyData* const polydata);
221
222 /** \brief Convert a PCLPointCloud2 object to a VTK PolyData object.
223 * \param[in] cloud the input PCLPointCloud2Ptr object
224 * \param[out] poly_data the resultant VTK PolyData object
225 * \ingroup io
226 */
227 PCL_EXPORTS void
229
230 /** \brief Convert a pcl::PointCloud object to a VTK StructuredGrid one.
231 * \param[in] cloud the input pcl::PointCloud object
232 * \param[out] structured_grid the resultant VTK StructuredGrid object
233 * \ingroup io
234 */
235 template <typename PointT> void
237 vtkStructuredGrid* const structured_grid);
238
239 /** \brief Convert a VTK PolyData object to a pcl::PointCloud one.
240 * \param[in] polydata the input VTK PolyData object
241 * \param[out] cloud the resultant pcl::PointCloud object
242 * \ingroup io
243 */
244 template <typename PointT> void
245 vtkPolyDataToPointCloud (vtkPolyData* const polydata,
247
248 /** \brief Convert a VTK StructuredGrid object to a pcl::PointCloud one.
249 * \param[in] structured_grid the input VTK StructuredGrid object
250 * \param[out] cloud the resultant pcl::PointCloud object
251 * \ingroup io
252 */
253 template <typename PointT> void
254 vtkStructuredGridToPointCloud (vtkStructuredGrid* const structured_grid,
256
257 }
258}
259
260#include <pcl/io/impl/vtk_lib_io.hpp>
PointCloud represents the base class in PCL for storing collections of 3D points.
RangeImagePlanar is derived from the original range image and differs from it because it's not a sphe...
void vtkPolyDataToPointCloud(vtkPolyData *const polydata, pcl::PointCloud< PointT > &cloud)
Convert a VTK PolyData object to a pcl::PointCloud one.
PCL_EXPORTS int loadPolygonFileVTK(const std::string &file_name, pcl::PolygonMesh &mesh)
Load a VTK file into a PolygonMesh object.
void vtkStructuredGridToPointCloud(vtkStructuredGrid *const structured_grid, pcl::PointCloud< PointT > &cloud)
Convert a VTK StructuredGrid object to a pcl::PointCloud one.
PCL_EXPORTS void saveRangeImagePlanarFilePNG(const std::string &file_name, const pcl::RangeImagePlanar &range_image)
Write a RangeImagePlanar object to a PNG file.
void pointCloudTovtkStructuredGrid(const pcl::PointCloud< PointT > &cloud, vtkStructuredGrid *const structured_grid)
Convert a pcl::PointCloud object to a VTK StructuredGrid one.
PCL_EXPORTS bool savePolygonFilePLY(const std::string &file_name, const pcl::PolygonMesh &mesh, const bool binary_format=true)
Save a PolygonMesh object into a PLY file.
PCL_EXPORTS int loadPolygonFilePLY(const std::string &file_name, pcl::PolygonMesh &mesh)
Load a PLY file into a PolygonMesh object.
PCL_EXPORTS bool savePolygonFileVTK(const std::string &file_name, const pcl::PolygonMesh &mesh, const bool binary_format=true)
Save a PolygonMesh object into a VTK file.
PCL_EXPORTS int loadPolygonFileOBJ(const std::string &file_name, pcl::PolygonMesh &mesh)
Load an OBJ file into a PolygonMesh object.
PCL_EXPORTS bool savePolygonFile(const std::string &file_name, const pcl::PolygonMesh &mesh, const bool binary_format=true)
Save a PolygonMesh object given an input file name, based on the file extension.
PCL_EXPORTS bool savePolygonFileSTL(const std::string &file_name, const pcl::PolygonMesh &mesh, const bool binary_format=true)
Save a PolygonMesh object into an STL file.
PCL_EXPORTS int loadPolygonFile(const std::string &file_name, pcl::PolygonMesh &mesh)
Load a PolygonMesh object given an input file name, based on the file extension.
PCL_EXPORTS int loadPolygonFileSTL(const std::string &file_name, pcl::PolygonMesh &mesh)
Load an STL file into a PolygonMesh object.
void pointCloudTovtkPolyData(const pcl::PointCloud< PointT > &cloud, vtkPolyData *const polydata)
Convert a pcl::PointCloud object to a VTK PolyData one.
PCL_EXPORTS int mesh2vtk(const pcl::PolygonMesh &mesh, vtkSmartPointer< vtkPolyData > &poly_data)
Convert a PCL PolygonMesh to a vtkPolyData object.
PCL_EXPORTS int vtk2mesh(const vtkSmartPointer< vtkPolyData > &poly_data, pcl::PolygonMesh &mesh)
Convert vtkPolyData object to a PCL PolygonMesh.
PCLPointCloud2::Ptr PCLPointCloud2Ptr
Defines all the PCL and non-PCL macros used.