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 "vtkPolyDataAlgorithm.h"
89 
90 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
91 
92 class vtkDoubleArray;
93 class vtkPriorityQueue;
94 
96 {
97 public:
99  void PrintSelf(ostream& os, vtkIndent indent);
100 
107  static vtkDecimatePro *New();
108 
110 
118  vtkSetClampMacro(TargetReduction,double,0.0,1.0);
119  vtkGetMacro(TargetReduction,double);
121 
123 
126  vtkSetMacro(PreserveTopology,int);
127  vtkGetMacro(PreserveTopology,int);
128  vtkBooleanMacro(PreserveTopology,int);
130 
132 
135  vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
136  vtkGetMacro(FeatureAngle,double);
138 
140 
144  vtkSetMacro(Splitting,int);
145  vtkGetMacro(Splitting,int);
146  vtkBooleanMacro(Splitting,int);
148 
150 
153  vtkSetClampMacro(SplitAngle,double,0.0,180.0);
154  vtkGetMacro(SplitAngle,double);
156 
158 
164  vtkSetMacro(PreSplitMesh,int);
165  vtkGetMacro(PreSplitMesh,int);
166  vtkBooleanMacro(PreSplitMesh,int);
168 
170 
174  vtkSetClampMacro(MaximumError,double,0.0,VTK_DOUBLE_MAX);
175  vtkGetMacro(MaximumError,double);
177 
179 
186  vtkSetMacro(AccumulateError,int);
187  vtkGetMacro(AccumulateError,int);
188  vtkBooleanMacro(AccumulateError,int);
190 
192 
196  vtkSetMacro(ErrorIsAbsolute,int);
197  vtkGetMacro(ErrorIsAbsolute,int);
199 
201 
202  vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
203  vtkGetMacro(AbsoluteError,double);
205 
207 
209  vtkSetMacro(BoundaryVertexDeletion,int);
210  vtkGetMacro(BoundaryVertexDeletion,int);
211  vtkBooleanMacro(BoundaryVertexDeletion,int);
213 
215 
219  vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
220  vtkGetMacro(Degree,int);
222 
224 
227  vtkSetClampMacro(InflectionPointRatio,double,1.001,VTK_DOUBLE_MAX);
228  vtkGetMacro(InflectionPointRatio,double);
230 
231 
237  vtkIdType GetNumberOfInflectionPoints();
238 
243  void GetInflectionPoints(double *inflectionPoints);
244 
250  double *GetInflectionPoints();
251 
252 protected:
253  vtkDecimatePro();
254  ~vtkDecimatePro();
255 
257 
259  double FeatureAngle;
260  double MaximumError;
264  double SplitAngle;
269  int Degree;
272 
273  // to replace a static object
276 
277  void SplitMesh();
278  int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
279  vtkIdType *tris, vtkIdType fedges[2]);
280  vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
281  vtkIdType& pt2, vtkIdList *CollapseTris);
282  int IsValidSplit(int index);
283  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
284  vtkIdType& n2, vtkIdType *l2);
285  void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
286  vtkIdType *tris, int insert);
287  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
288  vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
289  void DistributeError(double error);
290 
291  //
292  // Special classes for manipulating data
293  //
294  //BTX - begin tcl exclude
295  //
296  // Special structures for building loops
298  {
299  public:
301  double x[3];
302  double FAngle;
303  };
305 
306  class LocalTri
307  {
308  public:
310  double area;
311  double n[3];
312  vtkIdType verts[3];
313  };
315 
316  class VertexArray;
317  friend class VertexArray;
318  class VertexArray { //;prevent man page generation
319  public:
321  {this->MaxId = -1; this->Array = new LocalVertex[sz];};
323  {
324  if (this->Array)
325  {
326  delete [] this->Array;
327  }
328  };
329  vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
331  {this->MaxId++; this->Array[this->MaxId] = v;};
332  LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
333  void Reset() {this->MaxId = -1;};
334 
335  LocalVertex *Array; // pointer to data
336  vtkIdType MaxId; // maximum index inserted thus far
337  };
338 
339  class TriArray;
340  friend class TriArray;
341  class TriArray { //;prevent man page generation
342  public:
343  TriArray(const vtkIdType sz)
344  {this->MaxId = -1; this->Array = new LocalTri[sz];};
346  {
347  if (this->Array)
348  {
349  delete [] this->Array;
350  }
351  };
352  vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
354  {this->MaxId++; this->Array[this->MaxId] = t;};
355  LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
356  void Reset() {this->MaxId = -1;};
357 
358  LocalTri *Array; // pointer to data
359  vtkIdType MaxId; // maximum index inserted thus far
360  };
361  //ETX - end tcl exclude
362  //
363 
364 private:
365  void InitializeQueue(vtkIdType numPts);
366  void DeleteQueue();
367  void Insert(vtkIdType id, double error= -1.0);
368  int Pop(double &error);
369  double DeleteId(vtkIdType id);
370  void Reset();
371 
372  vtkPriorityQueue *Queue;
373  vtkDoubleArray *VertexError;
374 
375  VertexArray *V;
376  TriArray *T;
377 
378  // Use to be static variables used by object
379  vtkPolyData *Mesh; //operate on this data structure
380  double Pt[3]; //least squares plane point
381  double Normal[3]; //least squares plane normal
382  double LoopArea; //the total area of all triangles in a loop
383  double CosAngle; //Cosine of dihedral angle
384  double Tolerance; //Intersection tolerance
385  double X[3]; //coordinates of current point
386  int NumCollapses; //Number of times edge collapses occur
387  int NumMerges; //Number of times vertex merges occur
388  int Split; //Controls whether and when vertex splitting occurs
389  int VertexDegree; //Maximum number of triangles that can use a vertex
390  vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
391  double TheSplitAngle; //Split angle
392  int SplitState; //State of the splitting process
393  double Error; //Maximum allowable surface error
394 
395 private:
396  vtkDecimatePro(const vtkDecimatePro&); // Not implemented.
397  void operator=(const vtkDecimatePro&); // Not implemented.
398 };
399 
400 #endif
401 
402 
#define VTK_GRAPHICS_EXPORT
LocalTri & GetTriangle(vtkIdType i)
#define VTK_DOUBLE_MAX
Definition: vtkType.h:133
void InsertNextTriangle(LocalTri &t)
Store vtkAlgorithm input/output information.
LocalTri * LocalTriPtr
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
int vtkIdType
Definition: vtkType.h:255
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:81
#define VTK_CELL_SIZE
Definition: vtkCell.h:42
dynamic, self-adjusting array of double
an list of ids arranged in priority order
LocalVertex * LocalVertexPtr
static vtkPolyDataAlgorithm * New()
void Split(const int N[3], const int minSide[3], vtkstd::vector< vtkAMRBox > &decomp)
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:37
list of point or cell ids
Definition: vtkIdList.h:34
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