VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vtkDecimatePro.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDecimatePro.h
5 
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.
9 
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.
13 
14 =========================================================================*/
85 #ifndef __vtkDecimatePro_h
86 #define __vtkDecimatePro_h
87 
88 #include "vtkFiltersCoreModule.h" // For export macro
89 #include "vtkPolyDataAlgorithm.h"
90 
91 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
92 
93 class vtkDoubleArray;
94 class vtkPriorityQueue;
95 
96 class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
97 {
98 public:
100  void PrintSelf(ostream& os, vtkIndent indent);
101 
108  static vtkDecimatePro *New();
109 
111 
119  vtkSetClampMacro(TargetReduction,double,0.0,1.0);
120  vtkGetMacro(TargetReduction,double);
122 
124 
127  vtkSetMacro(PreserveTopology,int);
128  vtkGetMacro(PreserveTopology,int);
129  vtkBooleanMacro(PreserveTopology,int);
131 
133 
136  vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
137  vtkGetMacro(FeatureAngle,double);
139 
141 
145  vtkSetMacro(Splitting,int);
146  vtkGetMacro(Splitting,int);
147  vtkBooleanMacro(Splitting,int);
149 
151 
154  vtkSetClampMacro(SplitAngle,double,0.0,180.0);
155  vtkGetMacro(SplitAngle,double);
157 
159 
165  vtkSetMacro(PreSplitMesh,int);
166  vtkGetMacro(PreSplitMesh,int);
167  vtkBooleanMacro(PreSplitMesh,int);
169 
171 
175  vtkSetClampMacro(MaximumError,double,0.0,VTK_DOUBLE_MAX);
176  vtkGetMacro(MaximumError,double);
178 
180 
187  vtkSetMacro(AccumulateError,int);
188  vtkGetMacro(AccumulateError,int);
189  vtkBooleanMacro(AccumulateError,int);
191 
193 
197  vtkSetMacro(ErrorIsAbsolute,int);
198  vtkGetMacro(ErrorIsAbsolute,int);
200 
202 
203  vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
204  vtkGetMacro(AbsoluteError,double);
206 
208 
210  vtkSetMacro(BoundaryVertexDeletion,int);
211  vtkGetMacro(BoundaryVertexDeletion,int);
212  vtkBooleanMacro(BoundaryVertexDeletion,int);
214 
216 
220  vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
221  vtkGetMacro(Degree,int);
223 
225 
228  vtkSetClampMacro(InflectionPointRatio,double,1.001,VTK_DOUBLE_MAX);
229  vtkGetMacro(InflectionPointRatio,double);
231 
232 
238  vtkIdType GetNumberOfInflectionPoints();
239 
244  void GetInflectionPoints(double *inflectionPoints);
245 
251  double *GetInflectionPoints();
252 
253 protected:
254  vtkDecimatePro();
255  ~vtkDecimatePro();
256 
257  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
258 
260  double FeatureAngle;
261  double MaximumError;
265  double SplitAngle;
270  int Degree;
272  vtkDoubleArray *InflectionPoints;
273 
274  // to replace a static object
275  vtkIdList *Neighbors;
276  vtkPriorityQueue *EdgeLengths;
277 
278  void SplitMesh();
279  int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
280  vtkIdType *tris, vtkIdType fedges[2]);
281  vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
282  vtkIdType& pt2, vtkIdList *CollapseTris);
283  int IsValidSplit(int index);
284  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
285  vtkIdType& n2, vtkIdType *l2);
286  void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
287  vtkIdType *tris, int insert);
288  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
289  vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
290  void DistributeError(double error);
291 
292  //
293  // Special classes for manipulating data
294  //
295  //BTX - begin tcl exclude
296  //
297  // Special structures for building loops
299  {
300  public:
301  vtkIdType id;
302  double x[3];
303  double FAngle;
304  };
306 
307  class LocalTri
308  {
309  public:
310  vtkIdType id;
311  double area;
312  double n[3];
313  vtkIdType verts[3];
314  };
316 
317  class VertexArray;
318  friend class VertexArray;
319  class VertexArray { //;prevent man page generation
320  public:
321  VertexArray(const vtkIdType sz)
322  {this->MaxId = -1; this->Array = new LocalVertex[sz];};
324  {
325  if (this->Array)
326  {
327  delete [] this->Array;
328  }
329  };
330  vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
332  {this->MaxId++; this->Array[this->MaxId] = v;};
333  LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
334  void Reset() {this->MaxId = -1;};
335 
336  LocalVertex *Array; // pointer to data
337  vtkIdType MaxId; // maximum index inserted thus far
338  };
339 
340  class TriArray;
341  friend class TriArray;
342  class TriArray { //;prevent man page generation
343  public:
344  TriArray(const vtkIdType sz)
345  {this->MaxId = -1; this->Array = new LocalTri[sz];};
347  {
348  if (this->Array)
349  {
350  delete [] this->Array;
351  }
352  };
353  vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
355  {this->MaxId++; this->Array[this->MaxId] = t;};
356  LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
357  void Reset() {this->MaxId = -1;};
358 
359  LocalTri *Array; // pointer to data
360  vtkIdType MaxId; // maximum index inserted thus far
361  };
362  //ETX - end tcl exclude
363  //
364 
365 private:
366  void InitializeQueue(vtkIdType numPts);
367  void DeleteQueue();
368  void Insert(vtkIdType id, double error= -1.0);
369  int Pop(double &error);
370  double DeleteId(vtkIdType id);
371  void Reset();
372 
373  vtkPriorityQueue *Queue;
374  vtkDoubleArray *VertexError;
375 
376  VertexArray *V;
377  TriArray *T;
378 
379  // Use to be static variables used by object
380  vtkPolyData *Mesh; //operate on this data structure
381  double Pt[3]; //least squares plane point
382  double Normal[3]; //least squares plane normal
383  double LoopArea; //the total area of all triangles in a loop
384  double CosAngle; //Cosine of dihedral angle
385  double Tolerance; //Intersection tolerance
386  double X[3]; //coordinates of current point
387  int NumCollapses; //Number of times edge collapses occur
388  int NumMerges; //Number of times vertex merges occur
389  int Split; //Controls whether and when vertex splitting occurs
390  int VertexDegree; //Maximum number of triangles that can use a vertex
391  vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
392  double TheSplitAngle; //Split angle
393  int SplitState; //State of the splitting process
394  double Error; //Maximum allowable surface error
395 
396 private:
397  vtkDecimatePro(const vtkDecimatePro&); // Not implemented.
398  void operator=(const vtkDecimatePro&); // Not implemented.
399 };
400 
401 #endif
402 
403 
LocalTri & GetTriangle(vtkIdType i)
void InsertNextTriangle(LocalTri &t)
LocalTri * LocalTriPtr
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:82
LocalVertex * LocalVertexPtr
static vtkPolyDataAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent)
LocalVertex & GetVertex(vtkIdType i)
TriArray(const vtkIdType sz)
Superclass for algorithms that produce only polydata as output.
void InsertNextVertex(LocalVertex &v)
vtkIdList * Neighbors
double InflectionPointRatio
double TargetReduction
VertexArray(const vtkIdType sz)
vtkDoubleArray * InflectionPoints
reduce the number of triangles in a mesh
vtkIdType GetNumberOfTriangles()
vtkPriorityQueue * EdgeLengths