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) 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,vtkTypeBool);
134  vtkGetMacro(PreserveTopology,vtkTypeBool);
135  vtkBooleanMacro(PreserveTopology,vtkTypeBool);
137 
139 
144  vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
145  vtkGetMacro(FeatureAngle,double);
147 
149 
155  vtkSetMacro(Splitting,vtkTypeBool);
156  vtkGetMacro(Splitting,vtkTypeBool);
157  vtkBooleanMacro(Splitting,vtkTypeBool);
159 
161 
166  vtkSetClampMacro(SplitAngle,double,0.0,180.0);
167  vtkGetMacro(SplitAngle,double);
169 
171 
179  vtkSetMacro(PreSplitMesh,vtkTypeBool);
180  vtkGetMacro(PreSplitMesh,vtkTypeBool);
181  vtkBooleanMacro(PreSplitMesh,vtkTypeBool);
183 
185 
191  vtkSetClampMacro(MaximumError,double,0.0,VTK_DOUBLE_MAX);
192  vtkGetMacro(MaximumError,double);
194 
196 
204  vtkSetMacro(AccumulateError,vtkTypeBool);
205  vtkGetMacro(AccumulateError,vtkTypeBool);
206  vtkBooleanMacro(AccumulateError,vtkTypeBool);
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,vtkTypeBool);
233  vtkGetMacro(BoundaryVertexDeletion,vtkTypeBool);
234  vtkBooleanMacro(BoundaryVertexDeletion,vtkTypeBool);
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 
266  vtkIdType GetNumberOfInflectionPoints();
267 
274  void GetInflectionPoints(double *inflectionPoints);
275 
283  double *GetInflectionPoints();
284 
286 
291  vtkSetMacro(OutputPointsPrecision,int);
292  vtkGetMacro(OutputPointsPrecision,int);
294 
295 protected:
296  vtkDecimatePro();
297  ~vtkDecimatePro() override;
298 
300 
302  double FeatureAngle;
303  double MaximumError;
307  double SplitAngle;
312  int Degree;
316 
317  // to replace a static object
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&) = delete;
431  void operator=(const vtkDecimatePro&) = delete;
432 };
433 
434 #endif
435 
436 
vtkTypeBool AccumulateError
vtkTypeBool BoundaryVertexDeletion
LocalTri & GetTriangle(vtkIdType i)
#define VTK_DOUBLE_MAX
Definition: vtkType.h:169
void InsertNextTriangle(LocalTri &t)
Store vtkAlgorithm input/output information.
LocalTri * LocalTriPtr
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
int vtkIdType
Definition: vtkType.h:347
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
#define VTK_CELL_SIZE
Definition: vtkCell.h:43
dynamic, self-adjusting array of double
a list of ids arranged in priority order
LocalVertex * LocalVertexPtr
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:69
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:39
list of point or cell ids
Definition: vtkIdList.h:36
void InsertNextVertex(LocalVertex &v)
vtkIdList * Neighbors
double InflectionPointRatio
double TargetReduction
vtkTypeBool Splitting
vtkTypeBool PreserveTopology
VertexArray(const vtkIdType sz)
vtkDoubleArray * InflectionPoints
Store zero or more vtkInformation instances.
reduce the number of triangles in a mesh
vtkIdType GetNumberOfTriangles()
vtkPriorityQueue * EdgeLengths
vtkTypeBool PreSplitMesh
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.