00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * 00035 */ 00036 #ifndef PCL_MODELER_CLOUD_MESH_H_ 00037 #define PCL_MODELER_CLOUD_MESH_H_ 00038 00039 #include <pcl/point_types.h> 00040 #include <pcl/point_cloud.h> 00041 #include <pcl/Vertices.h> 00042 #include <vtkSmartPointer.h> 00043 00044 class vtkPoints; 00045 class vtkCellArray; 00046 class vtkDataArray; 00047 00048 namespace pcl 00049 { 00050 namespace modeler 00051 { 00052 class CloudMesh 00053 { 00054 public: 00055 typedef pcl::PointSurfel PointT; 00056 typedef pcl::PointCloud<PointT> PointCloud; 00057 typedef PointCloud::Ptr PointCloudPtr; 00058 typedef PointCloud::ConstPtr PointCloudConstPtr; 00059 00060 CloudMesh (); 00061 CloudMesh (PointCloudPtr cloud); 00062 ~CloudMesh (); 00063 00064 PointCloudPtr& 00065 getCloud() {return cloud_;} 00066 PointCloudConstPtr 00067 getCloud() const {return cloud_;} 00068 00069 std::vector<pcl::Vertices>& 00070 getPolygons() {return polygons_;} 00071 const std::vector<pcl::Vertices>& 00072 getPolygons() const {return polygons_;} 00073 00074 vtkSmartPointer<vtkPoints>& 00075 getVtkPoints() {return vtk_points_;} 00076 const vtkSmartPointer<vtkPoints>& 00077 getVtkPoints() const {return vtk_points_;} 00078 00079 vtkSmartPointer<vtkCellArray>& 00080 getVtkPolygons() {return vtk_polygons_;} 00081 const vtkSmartPointer<vtkCellArray>& 00082 getVtkPolygons() const {return vtk_polygons_;} 00083 00084 std::vector<std::string> 00085 getAvaiableFieldNames() const; 00086 00087 bool 00088 open(const std::string& filename); 00089 00090 bool 00091 save(const std::string& filename) const; 00092 00093 static bool 00094 save(const std::vector<const CloudMesh*>& cloud_meshes, const std::string& filename); 00095 00096 void 00097 getColorScalarsFromField(vtkSmartPointer<vtkDataArray> &scalars, const std::string& field) const; 00098 00099 void 00100 updateVtkPoints(); 00101 00102 void 00103 updateVtkPolygons(); 00104 00105 void 00106 transform(double tx, double ty, double tz, double rx, double ry, double rz); 00107 00108 protected: 00109 00110 00111 private: 00112 PointCloudPtr cloud_; 00113 std::vector<pcl::Vertices> polygons_; 00114 00115 vtkSmartPointer<vtkPoints> vtk_points_; 00116 vtkSmartPointer<vtkCellArray> vtk_polygons_; 00117 }; 00118 } 00119 } 00120 00121 #endif // PCL_MODELER_CLOUD_MESH_H_