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 =========================================================================*/
86 #ifndef vtkDecimatePro_h
87 #define vtkDecimatePro_h
88 
89 #include "vtkFiltersCoreModule.h" // For export macro
90 #include "vtkPolyDataAlgorithm.h"
91 
92 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
93 
94 class vtkDoubleArray;
95 class vtkPriorityQueue;
96 
97 class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
98 {
99 public:
101  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
102 
111  static vtkDecimatePro *New();
112 
114 
123  vtkSetClampMacro(TargetReduction,double,0.0,1.0);
124  vtkGetMacro(TargetReduction,double);
126 
128 
133  vtkSetMacro(PreserveTopology,int);
134  vtkGetMacro(PreserveTopology,int);
135  vtkBooleanMacro(PreserveTopology,int);
137 
139 
144  vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
145  vtkGetMacro(FeatureAngle,double);
147 
149 
155  vtkSetMacro(Splitting,int);
156  vtkGetMacro(Splitting,int);
157  vtkBooleanMacro(Splitting,int);
159 
161 
166  vtkSetClampMacro(SplitAngle,double,0.0,180.0);
167  vtkGetMacro(SplitAngle,double);
169 
171 
179  vtkSetMacro(PreSplitMesh,int);
180  vtkGetMacro(PreSplitMesh,int);
181  vtkBooleanMacro(PreSplitMesh,int);
183 
185 
191  vtkSetClampMacro(MaximumError,double,0.0,VTK_DOUBLE_MAX);
192  vtkGetMacro(MaximumError,double);
194 
196 
204  vtkSetMacro(AccumulateError,int);
205  vtkGetMacro(AccumulateError,int);
206  vtkBooleanMacro(AccumulateError,int);
208 
210 
215  vtkSetMacro(ErrorIsAbsolute,int);
216  vtkGetMacro(ErrorIsAbsolute,int);
218 
220 
223  vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
224  vtkGetMacro(AbsoluteError,double);
226 
228 
232  vtkSetMacro(BoundaryVertexDeletion,int);
233  vtkGetMacro(BoundaryVertexDeletion,int);
234  vtkBooleanMacro(BoundaryVertexDeletion,int);
236 
238 
244  vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
245  vtkGetMacro(Degree,int);
247 
249 
254  vtkSetClampMacro(InflectionPointRatio,double,1.001,VTK_DOUBLE_MAX);
255  vtkGetMacro(InflectionPointRatio,double);
257 
258 
267 
274  void GetInflectionPoints(double *inflectionPoints);
275 
284 
286 
291  vtkSetMacro(OutputPointsPrecision,int);
292  vtkGetMacro(OutputPointsPrecision,int);
294 
295 protected:
297  ~vtkDecimatePro() VTK_OVERRIDE;
298 
299  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
300 
301  double TargetReduction;
302  double FeatureAngle;
303  double MaximumError;
304  double AbsoluteError;
305  int ErrorIsAbsolute;
306  int AccumulateError;
307  double SplitAngle;
308  int Splitting;
309  int PreSplitMesh;
310  int BoundaryVertexDeletion;
311  int PreserveTopology;
312  int Degree;
313  double InflectionPointRatio;
314  vtkDoubleArray *InflectionPoints;
315  int OutputPointsPrecision;
316 
317  // to replace a static object
318  vtkIdList *Neighbors;
319  vtkPriorityQueue *EdgeLengths;
320 
321  void SplitMesh();
322  int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
323  vtkIdType *tris, vtkIdType fedges[2]);
324  vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
325  vtkIdType& pt2, vtkIdList *CollapseTris);
326  int IsValidSplit(int index);
327  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
328  vtkIdType& n2, vtkIdType *l2);
329  void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
330  vtkIdType *tris, int insert);
331  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
332  vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
333  void DistributeError(double error);
334 
335  //
336  // Special classes for manipulating data
337  //
338  // Special structures for building loops
340  {
341  public:
343  double x[3];
344  double FAngle;
345  };
347 
348  class LocalTri
349  {
350  public:
352  double area;
353  double n[3];
354  vtkIdType verts[3];
355  };
357 
358  class VertexArray;
359  friend class VertexArray;
360  class VertexArray { //;prevent man page generation
361  public:
363  {this->MaxId = -1; this->Array = new LocalVertex[sz];};
365  {
366  delete [] this->Array;
367  };
368  vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
370  {this->MaxId++; this->Array[this->MaxId] = v;};
371  LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
372  void Reset() {this->MaxId = -1;};
373 
374  LocalVertex *Array; // pointer to data
375  vtkIdType MaxId; // maximum index inserted thus far
376  };
377 
378  class TriArray;
379  friend class TriArray;
380  class TriArray { //;prevent man page generation
381  public:
382  TriArray(const vtkIdType sz)
383  {this->MaxId = -1; this->Array = new LocalTri[sz];};
385  {
386  delete [] this->Array;
387  };
388  vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
390  {this->MaxId++; this->Array[this->MaxId] = t;};
391  LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
392  void Reset() {this->MaxId = -1;};
393 
394  LocalTri *Array; // pointer to data
395  vtkIdType MaxId; // maximum index inserted thus far
396  };
397 
398 private:
399  void InitializeQueue(vtkIdType numPts);
400  void DeleteQueue();
401  void Insert(vtkIdType id, double error= -1.0);
402  int Pop(double &error);
403  double DeleteId(vtkIdType id);
404  void Reset();
405 
406  vtkPriorityQueue *Queue;
407  vtkDoubleArray *VertexError;
408 
409  VertexArray *V;
410  TriArray *T;
411 
412  // Use to be static variables used by object
413  vtkPolyData *Mesh; //operate on this data structure
414  double Pt[3]; //least squares plane point
415  double Normal[3]; //least squares plane normal
416  double LoopArea; //the total area of all triangles in a loop
417  double CosAngle; //Cosine of dihedral angle
418  double Tolerance; //Intersection tolerance
419  double X[3]; //coordinates of current point
420  int NumCollapses; //Number of times edge collapses occur
421  int NumMerges; //Number of times vertex merges occur
422  int Split; //Controls whether and when vertex splitting occurs
423  int VertexDegree; //Maximum number of triangles that can use a vertex
424  vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
425  double TheSplitAngle; //Split angle
426  int SplitState; //State of the splitting process
427  double Error; //Maximum allowable surface error
428 
429 private:
430  vtkDecimatePro(const vtkDecimatePro&) VTK_DELETE_FUNCTION;
431  void operator=(const vtkDecimatePro&) VTK_DELETE_FUNCTION;
432 };
433 
434 #endif
435 
436 
void InsertNextTriangle(LocalTri &t)
TriArray(const vtkIdType sz)
vtkIdType GetNumberOfTriangles()
LocalTri & GetTriangle(vtkIdType i)
VertexArray(const vtkIdType sz)
LocalVertex & GetVertex(vtkIdType i)
void InsertNextVertex(LocalVertex &v)
reduce the number of triangles in a mesh
void GetInflectionPoints(double *inflectionPoints)
Get a list of inflection points.
LocalTri * LocalTriPtr
~vtkDecimatePro() override
static vtkDecimatePro * New()
Create object with specified reduction of 90% and feature angle of 15 degrees.
LocalVertex * LocalVertexPtr
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
double * GetInflectionPoints()
Get a list of inflection points.
vtkIdType GetNumberOfInflectionPoints()
Get the number of inflection points.
dynamic, self-adjusting array of double
list of point or cell ids
Definition: vtkIdList.h:37
a simple class to control print indentation
Definition: vtkIndent.h:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
a list of ids arranged in priority order
@ Normal
Definition: vtkX3D.h:45
@ type
Definition: vtkX3D.h:516
@ index
Definition: vtkX3D.h:246
#define VTK_CELL_SIZE
Definition: vtkCell.h:43
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
int vtkIdType
Definition: vtkType.h:287
#define VTK_DOUBLE_MAX
Definition: vtkType.h:163