Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2011, Willow Garage, Inc. 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/or other materials provided 00017 * with the distribution. 00018 * * Neither the name of Willow Garage, Inc. nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 * $Id$ 00036 * 00037 */ 00038 00039 #ifndef VTK_MESH_SMOOTHING_LAPLACIAN_H_ 00040 #define VTK_MESH_SMOOTHING_LAPLACIAN_H_ 00041 00042 #include <pcl/surface/processing.h> 00043 #include <pcl/surface/vtk_smoothing/vtk.h> 00044 00045 namespace pcl 00046 { 00047 /** \brief PCL mesh smoothing based on the vtkSmoothPolyDataFilter algorithm from the VTK library. 00048 * Please check out the original documentation for more details on the inner workings of the algorithm 00049 * Warning: This wrapper does two fairly computationally expensive conversions from the PCL PolygonMesh 00050 * data structure to the vtkPolyData data structure and back. 00051 */ 00052 class PCL_EXPORTS MeshSmoothingLaplacianVTK : public MeshProcessing 00053 { 00054 public: 00055 /** \brief Empty constructor that sets the values of the algorithm parameters to the VTK defaults */ 00056 MeshSmoothingLaplacianVTK () 00057 : MeshProcessing () 00058 , vtk_polygons_ () 00059 , num_iter_ (20) 00060 , convergence_ (0.0f) 00061 , relaxation_factor_ (0.01f) 00062 , feature_edge_smoothing_ (false) 00063 , feature_angle_ (45.f) 00064 , edge_angle_ (15.f) 00065 , boundary_smoothing_ (true) 00066 {}; 00067 00068 /** \brief Set the number of iterations for the smoothing filter. 00069 * \param[in] num_iter the number of iterations 00070 */ 00071 inline void 00072 setNumIter (int num_iter) 00073 { 00074 num_iter_ = num_iter; 00075 }; 00076 00077 /** \brief Get the number of iterations. */ 00078 inline int 00079 getNumIter () 00080 { 00081 return num_iter_; 00082 }; 00083 00084 /** \brief Specify a convergence criterion for the iteration process. Smaller numbers result in more smoothing iterations. 00085 * \param[in] convergence convergence criterion for the Laplacian smoothing 00086 */ 00087 inline void 00088 setConvergence (float convergence) 00089 { 00090 convergence_ = convergence; 00091 }; 00092 00093 /** \brief Get the convergence criterion. */ 00094 inline float 00095 getConvergence () 00096 { 00097 return convergence_; 00098 }; 00099 00100 /** \brief Specify the relaxation factor for Laplacian smoothing. As in all iterative methods, 00101 * the stability of the process is sensitive to this parameter. 00102 * In general, small relaxation factors and large numbers of iterations are more stable than larger relaxation 00103 * factors and smaller numbers of iterations. 00104 * \param[in] relaxation_factor the relaxation factor of the Laplacian smoothing algorithm 00105 */ 00106 inline void 00107 setRelaxationFactor (float relaxation_factor) 00108 { 00109 relaxation_factor_ = relaxation_factor; 00110 }; 00111 00112 /** \brief Get the relaxation factor of the Laplacian smoothing */ 00113 inline float 00114 getRelaxationFactor () 00115 { 00116 return relaxation_factor_; 00117 }; 00118 00119 /** \brief Turn on/off smoothing along sharp interior edges. 00120 * \param[in] status decision whether to enable/disable smoothing along sharp interior edges 00121 */ 00122 inline void 00123 setFeatureEdgeSmoothing (bool feature_edge_smoothing) 00124 { 00125 feature_edge_smoothing_ = feature_edge_smoothing; 00126 }; 00127 00128 /** \brief Get the status of the feature edge smoothing */ 00129 inline bool 00130 getFeatureEdgeSmoothing () 00131 { 00132 return feature_edge_smoothing_; 00133 }; 00134 00135 /** \brief Specify the feature angle for sharp edge identification. 00136 * \param[in] feature_angle the angle threshold for considering an edge to be sharp 00137 */ 00138 inline void 00139 setFeatureAngle (float feature_angle) 00140 { 00141 feature_angle_ = feature_angle; 00142 }; 00143 00144 /** \brief Get the angle threshold for considering an edge to be sharp */ 00145 inline float 00146 getFeatureAngle () 00147 { 00148 return feature_angle_; 00149 }; 00150 00151 /** \brief Specify the edge angle to control smoothing along edges (either interior or boundary). 00152 * \param[in] edge_angle the angle to control smoothing along edges 00153 */ 00154 inline void 00155 setEdgeAngle (float edge_angle) 00156 { 00157 edge_angle_ = edge_angle; 00158 }; 00159 00160 /** \brief Get the edge angle to control smoothing along edges */ 00161 inline float 00162 getEdgeAngle () 00163 { 00164 return edge_angle_; 00165 }; 00166 00167 /** \brief Turn on/off the smoothing of vertices on the boundary of the mesh. 00168 * \param[in] boundary_smoothing decision whether boundary smoothing is on or off 00169 */ 00170 inline void 00171 setBoundarySmoothing (bool boundary_smoothing) 00172 { 00173 boundary_smoothing_ = boundary_smoothing; 00174 }; 00175 00176 /** \brief Get the status of the boundary smoothing */ 00177 inline bool 00178 getBoundarySmoothing () 00179 { 00180 return boundary_smoothing_; 00181 } 00182 00183 protected: 00184 void 00185 performProcessing (pcl::PolygonMesh &output); 00186 00187 private: 00188 vtkSmartPointer<vtkPolyData> vtk_polygons_; 00189 00190 /// Parameters 00191 int num_iter_; 00192 float convergence_; 00193 float relaxation_factor_; 00194 bool feature_edge_smoothing_; 00195 float feature_angle_; 00196 float edge_angle_; 00197 bool boundary_smoothing_; 00198 }; 00199 } 00200 #endif /* VTK_MESH_SMOOTHING_LAPLACIAN_H_ */