DeleteSetOfPoints function working
[engrid.git] / vtksmoothpolydatafilter2.h
blob571aea7488c5aba17998f17930e0d1e5c8f4c440
1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtksmoothpolydatafilter2.h,v $
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
14 =========================================================================*/
15 // .NAME vtkSmoothPolyDataFilter2 - adjust point positions using Laplacian smoothing
16 // .SECTION Description
17 // vtkSmoothPolyDataFilter2 is a filter that adjusts point coordinates using
18 // Laplacian smoothing. The effect is to "relax" the mesh, making the cells
19 // better shaped and the vertices more evenly distributed. Note that this
20 // filter operates on the lines, polygons, and triangle strips composing an
21 // instance of vtkPolyData. Vertex or poly-vertex cells are never modified.
22 //
23 // The algorithm proceeds as follows. For each vertex v, a topological and
24 // geometric analysis is performed to determine which vertices are connected
25 // to v, and which cells are connected to v. Then, a connectivity array is
26 // constructed for each vertex. (The connectivity array is a list of lists
27 // of vertices that directly attach to each vertex.) Next, an iteration
28 // phase begins over all vertices. For each vertex v, the coordinates of v
29 // are modified according to an average of the connected vertices. (A
30 // relaxation factor is available to control the amount of displacement of
31 // v). The process repeats for each vertex. This pass over the list of
32 // vertices is a single iteration. Many iterations (generally around 20 or
33 // so) are repeated until the desired result is obtained.
34 //
35 // There are some special instance variables used to control the execution
36 // of this filter. (These ivars basically control what vertices can be
37 // smoothed, and the creation of the connectivity array.) The
38 // BoundarySmoothing ivar enables/disables the smoothing operation on
39 // vertices that are on the "boundary" of the mesh. A boundary vertex is one
40 // that is surrounded by a semi-cycle of polygons (or used by a single
41 // line).
42 //
43 // Another important ivar is FeatureEdgeSmoothing. If this ivar is
44 // enabled, then interior vertices are classified as either "simple",
45 // "interior edge", or "fixed", and smoothed differently. (Interior
46 // vertices are manifold vertices surrounded by a cycle of polygons; or used
47 // by two line cells.) The classification is based on the number of feature
48 // edges attached to v. A feature edge occurs when the angle between the two
49 // surface normals of a polygon sharing an edge is greater than the
50 // FeatureAngle ivar. Then, vertices used by no feature edges are classified
51 // "simple", vertices used by exactly two feature edges are classified
52 // "interior edge", and all others are "fixed" vertices.
54 // Once the classification is known, the vertices are smoothed
55 // differently. Corner (i.e., fixed) vertices are not smoothed at all.
56 // Simple vertices are smoothed as before (i.e., average of connected
57 // vertex coordinates). Interior edge vertices are smoothed only along
58 // their two connected edges, and only if the angle between the edges
59 // is less than the EdgeAngle ivar.
61 // The total smoothing can be controlled by using two ivars. The
62 // NumberOfIterations is a cap on the maximum number of smoothing passes.
63 // The Convergence ivar is a limit on the maximum point motion. If the
64 // maximum motion during an iteration is less than Convergence, then the
65 // smoothing process terminates. (Convergence is expressed as a fraction of
66 // the diagonal of the bounding box.)
68 // There are two instance variables that control the generation of error
69 // data. If the ivar GenerateErrorScalars is on, then a scalar value indicating
70 // the distance of each vertex from its original position is computed. If the
71 // ivar GenerateErrorVectors is on, then a vector representing change in
72 // position is computed.
74 // Optionally you can further control the smoothing process by defining a
75 // second input: the Source. If defined, the input mesh is constrained to
76 // lie on the surface defined by the Source ivar.
78 // .SECTION Caveats
79 //
80 // The Laplacian operation reduces high frequency information in the geometry
81 // of the mesh. With excessive smoothing important details may be lost, and
82 // the surface may shrink towards the centroid. Enabling FeatureEdgeSmoothing
83 // helps reduce this effect, but cannot entirely eliminate it. You may also
84 // wish to try vtkWindowedSincPolyDataFilter. It does a better job of
85 // minimizing shrinkage.
87 // .SECTION See Also
88 // vtkWindowedSincPolyDataFilter vtkDecimate vtkDecimatePro
90 #ifndef __vtkSmoothPolyDataFilter2_h
91 #define __vtkSmoothPolyDataFilter2_h
93 #include "vtkPolyDataAlgorithm.h"
95 class vtkSmoothPoints;
97 class VTK_GRAPHICS_EXPORT vtkSmoothPolyDataFilter2 : public vtkPolyDataAlgorithm
99 public:
100 vtkTypeRevisionMacro(vtkSmoothPolyDataFilter2,vtkPolyDataAlgorithm);
101 void PrintSelf(ostream& os, vtkIndent indent);
103 // Description:
104 // Construct object with number of iterations 20; relaxation factor .01;
105 // feature edge smoothing turned off; feature
106 // angle 45 degrees; edge angle 15 degrees; and boundary smoothing turned
107 // on. Error scalars and vectors are not generated (by default). The
108 // convergence criterion is 0.0 of the bounding box diagonal.
109 static vtkSmoothPolyDataFilter2 *New();
111 // Description:
112 // Specify a convergence criterion for the iteration
113 // process. Smaller numbers result in more smoothing iterations.
114 vtkSetClampMacro(Convergence,double,0.0,1.0);
115 vtkGetMacro(Convergence,double);
117 // Description:
118 // Specify the number of iterations for Laplacian smoothing,
119 vtkSetClampMacro(NumberOfIterations,int,0,VTK_LARGE_INTEGER);
120 vtkGetMacro(NumberOfIterations,int);
122 // Description:
123 // Specify the relaxation factor for Laplacian smoothing. As in all
124 // iterative methods, the stability of the process is sensitive to
125 // this parameter. In general, small relaxation factors and large
126 // numbers of iterations are more stable than larger relaxation
127 // factors and smaller numbers of iterations.
128 vtkSetMacro(RelaxationFactor,double);
129 vtkGetMacro(RelaxationFactor,double);
131 // Description:
132 // Turn on/off smoothing along sharp interior edges.
133 vtkSetMacro(FeatureEdgeSmoothing,int);
134 vtkGetMacro(FeatureEdgeSmoothing,int);
135 vtkBooleanMacro(FeatureEdgeSmoothing,int);
137 // Description:
138 // Specify the feature angle for sharp edge identification.
139 vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
140 vtkGetMacro(FeatureAngle,double);
142 // Description:
143 // Specify the edge angle to control smoothing along edges (either interior
144 // or boundary).
145 vtkSetClampMacro(EdgeAngle,double,0.0,180.0);
146 vtkGetMacro(EdgeAngle,double);
148 // Description:
149 // Turn on/off the smoothing of vertices on the boundary of the mesh.
150 vtkSetMacro(BoundarySmoothing,int);
151 vtkGetMacro(BoundarySmoothing,int);
152 vtkBooleanMacro(BoundarySmoothing,int);
154 // Description:
155 // Turn on/off the generation of scalar distance values.
156 vtkSetMacro(GenerateErrorScalars,int);
157 vtkGetMacro(GenerateErrorScalars,int);
158 vtkBooleanMacro(GenerateErrorScalars,int);
160 // Description:
161 // Turn on/off the generation of error vectors.
162 vtkSetMacro(GenerateErrorVectors,int);
163 vtkGetMacro(GenerateErrorVectors,int);
164 vtkBooleanMacro(GenerateErrorVectors,int);
166 // Description:
167 // Specify the source object which is used to constrain smoothing. The
168 // source defines a surface that the input (as it is smoothed) is
169 // constrained to lie upon.
170 void SetSource(vtkPolyData *source);
171 vtkPolyData *GetSource();
173 protected:
174 vtkSmoothPolyDataFilter2();
175 ~vtkSmoothPolyDataFilter2() {};
177 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
178 virtual int FillInputPortInformation(int port, vtkInformation *info);
180 double Convergence;
181 int NumberOfIterations;
182 double RelaxationFactor;
183 int FeatureEdgeSmoothing;
184 double FeatureAngle;
185 double EdgeAngle;
186 int BoundarySmoothing;
187 int GenerateErrorScalars;
188 int GenerateErrorVectors;
190 vtkSmoothPoints *SmoothPoints;
191 private:
192 vtkSmoothPolyDataFilter2(const vtkSmoothPolyDataFilter2&); // Not implemented.
193 void operator=(const vtkSmoothPolyDataFilter2&); // Not implemented.
196 #endif