Point Cloud Library (PCL)  1.7.0
/tmp/buildd/pcl-1.7-1.7.0/surface/include/pcl/surface/vtk_smoothing/vtk_mesh_smoothing_windowed_sinc.h
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_WINDOWED_SINC_H_
00040 #define VTK_MESH_SMOOTHING_WINDOWED_SINC_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 vtkWindowedSincPolyDataFilter 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 MeshSmoothingWindowedSincVTK : public MeshProcessing
00053   {
00054     public:
00055       /** \brief Empty constructor that sets the values of the algorithm parameters to the VTK defaults */
00056       MeshSmoothingWindowedSincVTK ()
00057         : MeshProcessing (),
00058           num_iter_ (20),
00059           pass_band_ (0.1f),
00060           feature_edge_smoothing_ (false),
00061           feature_angle_ (45.f),
00062           edge_angle_ (15.f),
00063           boundary_smoothing_ (true),
00064           normalize_coordinates_ (false)
00065       {};
00066 
00067       /** \brief Set the number of iterations for the smoothing filter.
00068         * \param[in] num_iter the number of iterations
00069         */
00070       inline void
00071       setNumIter (int num_iter)
00072       {
00073         num_iter_ = num_iter;
00074       };
00075 
00076       /** \brief Get the number of iterations. */
00077       inline int
00078       getNumIter ()
00079       {
00080         return num_iter_;
00081       };
00082 
00083       /** \brief Set the pass band value for windowed sinc filtering.
00084         * \param[in] pass_band value for the pass band.
00085         */
00086       inline void
00087       setPassBand (float pass_band)
00088       {
00089         pass_band_ = pass_band;
00090       };
00091 
00092       /** \brief Get the pass band value. */
00093       inline float
00094       getPassBand ()
00095       {
00096         return pass_band_;
00097       };
00098 
00099       /** \brief Turn on/off coordinate normalization. The positions can be translated and scaled such that they fit
00100        * within a [-1, 1] prior to the smoothing computation. The default is off. The numerical stability of the
00101        * solution can be improved by turning normalization on. If normalization is on, the coordinates will be rescaled
00102        * to the original coordinate system after smoothing has completed.
00103        * \param[in] normalize_coordinates decision whether to normalize coordinates or not
00104        */
00105       inline void
00106       setNormalizeCoordinates (bool normalize_coordinates)
00107       {
00108         normalize_coordinates_ = normalize_coordinates;
00109       }
00110 
00111       /** \brief Get whether the coordinate normalization is active or not */
00112       inline bool
00113       getNormalizeCoordinates ()
00114       {
00115         return normalize_coordinates_;
00116       }
00117 
00118       /** \brief Turn on/off smoothing along sharp interior edges.
00119        * \param[in] status decision whether to enable/disable smoothing along sharp interior edges
00120        */
00121       inline void
00122       setFeatureEdgeSmoothing (bool feature_edge_smoothing)
00123       {
00124         feature_edge_smoothing_ = feature_edge_smoothing;
00125       };
00126 
00127       /** \brief Get the status of the feature edge smoothing */
00128       inline bool
00129       getFeatureEdgeSmoothing ()
00130       {
00131         return feature_edge_smoothing_;
00132       };
00133 
00134       /** \brief Specify the feature angle for sharp edge identification.
00135        * \param[in] feature_angle the angle threshold for considering an edge to be sharp
00136        */
00137       inline void
00138       setFeatureAngle (float feature_angle)
00139       {
00140         feature_angle_ = feature_angle;
00141       };
00142 
00143       /** \brief Get the angle threshold for considering an edge to be sharp */
00144       inline float
00145       getFeatureAngle ()
00146       {
00147         return feature_angle_;
00148       };
00149 
00150       /** \brief Specify the edge angle to control smoothing along edges (either interior or boundary).
00151        * \param[in] edge_angle the angle to control smoothing along edges
00152        */
00153       inline void
00154       setEdgeAngle (float edge_angle)
00155       {
00156         edge_angle_ = edge_angle;
00157       };
00158 
00159       /** \brief Get the edge angle to control smoothing along edges */
00160       inline float
00161       getEdgeAngle ()
00162       {
00163         return edge_angle_;
00164       };
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 
00184     protected:
00185       void
00186       performProcessing (pcl::PolygonMesh &output);
00187 
00188     private:
00189       vtkSmartPointer<vtkPolyData> vtk_polygons_;
00190       int num_iter_;
00191       float pass_band_;
00192       bool feature_edge_smoothing_;
00193       float feature_angle_;
00194       float edge_angle_;
00195       bool boundary_smoothing_;
00196       bool normalize_coordinates_;
00197   };
00198 }
00199 #endif /* VTK_MESH_SMOOTHING_WINDOWED_SINC_H_ */