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