VTK
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 
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 
254 
257  vtkSetMacro(OutputPointsPrecision,int);
258  vtkGetMacro(OutputPointsPrecision,int);
260 
261 protected:
262  vtkDecimatePro();
263  ~vtkDecimatePro();
264 
266 
268  double FeatureAngle;
269  double MaximumError;
273  double SplitAngle;
278  int Degree;
282 
283  // to replace a static object
286 
287  void SplitMesh();
288  int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
289  vtkIdType *tris, vtkIdType fedges[2]);
290  vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
291  vtkIdType& pt2, vtkIdList *CollapseTris);
292  int IsValidSplit(int index);
293  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
294  vtkIdType& n2, vtkIdType *l2);
295  void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
296  vtkIdType *tris, int insert);
297  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
298  vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
299  void DistributeError(double error);
300 
301  //
302  // Special classes for manipulating data
303  //
304  //BTX - begin tcl exclude
305  //
306  // Special structures for building loops
308  {
309  public:
311  double x[3];
312  double FAngle;
313  };
315 
316  class LocalTri
317  {
318  public:
320  double area;
321  double n[3];
322  vtkIdType verts[3];
323  };
325 
326  class VertexArray;
327  friend class VertexArray;
328  class VertexArray { //;prevent man page generation
329  public:
331  {this->MaxId = -1; this->Array = new LocalVertex[sz];};
333  {
334  delete [] this->Array;
335  };
336  vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
338  {this->MaxId++; this->Array[this->MaxId] = v;};
339  LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
340  void Reset() {this->MaxId = -1;};
341 
342  LocalVertex *Array; // pointer to data
343  vtkIdType MaxId; // maximum index inserted thus far
344  };
345 
346  class TriArray;
347  friend class TriArray;
348  class TriArray { //;prevent man page generation
349  public:
350  TriArray(const vtkIdType sz)
351  {this->MaxId = -1; this->Array = new LocalTri[sz];};
353  {
354  delete [] this->Array;
355  };
356  vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
358  {this->MaxId++; this->Array[this->MaxId] = t;};
359  LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
360  void Reset() {this->MaxId = -1;};
361 
362  LocalTri *Array; // pointer to data
363  vtkIdType MaxId; // maximum index inserted thus far
364  };
365  //ETX - end tcl exclude
366  //
367 
368 private:
369  void InitializeQueue(vtkIdType numPts);
370  void DeleteQueue();
371  void Insert(vtkIdType id, double error= -1.0);
372  int Pop(double &error);
373  double DeleteId(vtkIdType id);
374  void Reset();
375 
376  vtkPriorityQueue *Queue;
377  vtkDoubleArray *VertexError;
378 
379  VertexArray *V;
380  TriArray *T;
381 
382  // Use to be static variables used by object
383  vtkPolyData *Mesh; //operate on this data structure
384  double Pt[3]; //least squares plane point
385  double Normal[3]; //least squares plane normal
386  double LoopArea; //the total area of all triangles in a loop
387  double CosAngle; //Cosine of dihedral angle
388  double Tolerance; //Intersection tolerance
389  double X[3]; //coordinates of current point
390  int NumCollapses; //Number of times edge collapses occur
391  int NumMerges; //Number of times vertex merges occur
392  int Split; //Controls whether and when vertex splitting occurs
393  int VertexDegree; //Maximum number of triangles that can use a vertex
394  vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
395  double TheSplitAngle; //Split angle
396  int SplitState; //State of the splitting process
397  double Error; //Maximum allowable surface error
398 
399 private:
400  vtkDecimatePro(const vtkDecimatePro&); // Not implemented.
401  void operator=(const vtkDecimatePro&); // Not implemented.
402 };
403 
404 #endif
405 
406 
LocalTri & GetTriangle(vtkIdType i)
#define VTK_DOUBLE_MAX
Definition: vtkType.h:142
void InsertNextTriangle(LocalTri &t)
Store vtkAlgorithm input/output information.
LocalTri * LocalTriPtr
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
#define VTKFILTERSCORE_EXPORT
int vtkIdType
Definition: vtkType.h:275
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
#define VTK_CELL_SIZE
Definition: vtkCell.h:45
dynamic, self-adjusting array of double
a list of ids arranged in priority order
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.
a simple class to control print indentation
Definition: vtkIndent.h:38
list of point or cell ids
Definition: vtkIdList.h:35
void InsertNextVertex(LocalVertex &v)
vtkIdList * Neighbors
double InflectionPointRatio
double TargetReduction
VertexArray(const vtkIdType sz)
vtkDoubleArray * InflectionPoints
Store zero or more vtkInformation instances.
reduce the number of triangles in a mesh
vtkIdType GetNumberOfTriangles()
vtkPriorityQueue * EdgeLengths