Point Cloud Library (PCL)  1.9.1-dev
vtk_mesh_smoothing_windowed_sinc.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2011, Willow Garage, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Willow Garage, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * $Id$
36  *
37  */
38 
39 #pragma once
40 
41 #include <pcl/surface/processing.h>
42 #include <pcl/surface/vtk_smoothing/vtk.h>
43 
44 namespace pcl
45 {
46  /** \brief PCL mesh smoothing based on the vtkWindowedSincPolyDataFilter algorithm from the VTK library.
47  * Please check out the original documentation for more details on the inner workings of the algorithm
48  * Warning: This wrapper does two fairly computationally expensive conversions from the PCL PolygonMesh
49  * data structure to the vtkPolyData data structure and back.
50  */
52  {
53  public:
54  /** \brief Empty constructor that sets the values of the algorithm parameters to the VTK defaults */
56  : num_iter_ (20),
57  pass_band_ (0.1f),
58  feature_edge_smoothing_ (false),
59  feature_angle_ (45.f),
60  edge_angle_ (15.f),
61  boundary_smoothing_ (true),
62  normalize_coordinates_ (false)
63  {};
64 
65  /** \brief Set the number of iterations for the smoothing filter.
66  * \param[in] num_iter the number of iterations
67  */
68  inline void
69  setNumIter (int num_iter)
70  {
71  num_iter_ = num_iter;
72  };
73 
74  /** \brief Get the number of iterations. */
75  inline int
77  {
78  return num_iter_;
79  };
80 
81  /** \brief Set the pass band value for windowed sinc filtering.
82  * \param[in] pass_band value for the pass band.
83  */
84  inline void
85  setPassBand (float pass_band)
86  {
87  pass_band_ = pass_band;
88  };
89 
90  /** \brief Get the pass band value. */
91  inline float
93  {
94  return pass_band_;
95  };
96 
97  /** \brief Turn on/off coordinate normalization. The positions can be translated and scaled such that they fit
98  * within a [-1, 1] prior to the smoothing computation. The default is off. The numerical stability of the
99  * solution can be improved by turning normalization on. If normalization is on, the coordinates will be rescaled
100  * to the original coordinate system after smoothing has completed.
101  * \param[in] normalize_coordinates decision whether to normalize coordinates or not
102  */
103  inline void
104  setNormalizeCoordinates (bool normalize_coordinates)
105  {
106  normalize_coordinates_ = normalize_coordinates;
107  }
108 
109  /** \brief Get whether the coordinate normalization is active or not */
110  inline bool
112  {
113  return normalize_coordinates_;
114  }
115 
116  /** \brief Turn on/off smoothing along sharp interior edges.
117  * \param[in] feature_edge_smoothing whether to enable/disable smoothing along sharp interior edges
118  */
119  inline void
120  setFeatureEdgeSmoothing (bool feature_edge_smoothing)
121  {
122  feature_edge_smoothing_ = feature_edge_smoothing;
123  };
124 
125  /** \brief Get the status of the feature edge smoothing */
126  inline bool
128  {
129  return feature_edge_smoothing_;
130  };
131 
132  /** \brief Specify the feature angle for sharp edge identification.
133  * \param[in] feature_angle the angle threshold for considering an edge to be sharp
134  */
135  inline void
136  setFeatureAngle (float feature_angle)
137  {
138  feature_angle_ = feature_angle;
139  };
140 
141  /** \brief Get the angle threshold for considering an edge to be sharp */
142  inline float
144  {
145  return feature_angle_;
146  };
147 
148  /** \brief Specify the edge angle to control smoothing along edges (either interior or boundary).
149  * \param[in] edge_angle the angle to control smoothing along edges
150  */
151  inline void
152  setEdgeAngle (float edge_angle)
153  {
154  edge_angle_ = edge_angle;
155  };
156 
157  /** \brief Get the edge angle to control smoothing along edges */
158  inline float
160  {
161  return edge_angle_;
162  };
163 
164 
165  /** \brief Turn on/off the smoothing of vertices on the boundary of the mesh.
166  * \param[in] boundary_smoothing decision whether boundary smoothing is on or off
167  */
168  inline void
169  setBoundarySmoothing (bool boundary_smoothing)
170  {
171  boundary_smoothing_ = boundary_smoothing;
172  };
173 
174  /** \brief Get the status of the boundary smoothing */
175  inline bool
177  {
178  return boundary_smoothing_;
179  }
180 
181 
182  protected:
183  void
184  performProcessing (pcl::PolygonMesh &output) override;
185 
186  private:
187  vtkSmartPointer<vtkPolyData> vtk_polygons_;
188  int num_iter_;
189  float pass_band_;
190  bool feature_edge_smoothing_;
191  float feature_angle_;
192  float edge_angle_;
193  bool boundary_smoothing_;
194  bool normalize_coordinates_;
195  };
196 }
void setEdgeAngle(float edge_angle)
Specify the edge angle to control smoothing along edges (either interior or boundary).
bool getFeatureEdgeSmoothing()
Get the status of the feature edge smoothing.
void setFeatureAngle(float feature_angle)
Specify the feature angle for sharp edge identification.
MeshProcessing represents the base class for mesh processing algorithms.
Definition: processing.h:93
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
void setBoundarySmoothing(bool boundary_smoothing)
Turn on/off the smoothing of vertices on the boundary of the mesh.
bool getNormalizeCoordinates()
Get whether the coordinate normalization is active or not.
float getPassBand()
Get the pass band value.
PCL mesh smoothing based on the vtkWindowedSincPolyDataFilter algorithm from the VTK library...
void setNumIter(int num_iter)
Set the number of iterations for the smoothing filter.
int getNumIter()
Get the number of iterations.
bool getBoundarySmoothing()
Get the status of the boundary smoothing.
float getFeatureAngle()
Get the angle threshold for considering an edge to be sharp.
float getEdgeAngle()
Get the edge angle to control smoothing along edges.
MeshSmoothingWindowedSincVTK()
Empty constructor that sets the values of the algorithm parameters to the VTK defaults.
void setNormalizeCoordinates(bool normalize_coordinates)
Turn on/off coordinate normalization.
void setPassBand(float pass_band)
Set the pass band value for windowed sinc filtering.
void setFeatureEdgeSmoothing(bool feature_edge_smoothing)
Turn on/off smoothing along sharp interior edges.
#define PCL_EXPORTS
Definition: pcl_macros.h:226