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 =========================================================================*/
80 #ifndef vtkDecimatePro_h
81 #define vtkDecimatePro_h
82 
83 #include "vtkFiltersCoreModule.h" // For export macro
84 #include "vtkPolyDataAlgorithm.h"
85 
86 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
87 
88 class vtkDoubleArray;
89 class vtkPriorityQueue;
90 
91 class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
92 {
93 public:
95  void PrintSelf(ostream& os, vtkIndent indent) override;
96 
105  static vtkDecimatePro *New();
106 
108 
117  vtkSetClampMacro(TargetReduction,double,0.0,1.0);
118  vtkGetMacro(TargetReduction,double);
120 
122 
127  vtkSetMacro(PreserveTopology,vtkTypeBool);
128  vtkGetMacro(PreserveTopology,vtkTypeBool);
129  vtkBooleanMacro(PreserveTopology,vtkTypeBool);
131 
133 
138  vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
139  vtkGetMacro(FeatureAngle,double);
141 
143 
149  vtkSetMacro(Splitting,vtkTypeBool);
150  vtkGetMacro(Splitting,vtkTypeBool);
151  vtkBooleanMacro(Splitting,vtkTypeBool);
153 
155 
160  vtkSetClampMacro(SplitAngle,double,0.0,180.0);
161  vtkGetMacro(SplitAngle,double);
163 
165 
173  vtkSetMacro(PreSplitMesh,vtkTypeBool);
174  vtkGetMacro(PreSplitMesh,vtkTypeBool);
175  vtkBooleanMacro(PreSplitMesh,vtkTypeBool);
177 
179 
185  vtkSetClampMacro(MaximumError,double,0.0,VTK_DOUBLE_MAX);
186  vtkGetMacro(MaximumError,double);
188 
190 
198  vtkSetMacro(AccumulateError,vtkTypeBool);
199  vtkGetMacro(AccumulateError,vtkTypeBool);
200  vtkBooleanMacro(AccumulateError,vtkTypeBool);
202 
204 
209  vtkSetMacro(ErrorIsAbsolute,int);
210  vtkGetMacro(ErrorIsAbsolute,int);
212 
214 
217  vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
218  vtkGetMacro(AbsoluteError,double);
220 
222 
226  vtkSetMacro(BoundaryVertexDeletion,vtkTypeBool);
227  vtkGetMacro(BoundaryVertexDeletion,vtkTypeBool);
228  vtkBooleanMacro(BoundaryVertexDeletion,vtkTypeBool);
230 
232 
238  vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
239  vtkGetMacro(Degree,int);
241 
243 
248  vtkSetClampMacro(InflectionPointRatio,double,1.001,VTK_DOUBLE_MAX);
249  vtkGetMacro(InflectionPointRatio,double);
251 
252 
260  vtkIdType GetNumberOfInflectionPoints();
261 
268  void GetInflectionPoints(double *inflectionPoints);
269 
277  double *GetInflectionPoints();
278 
280 
285  vtkSetMacro(OutputPointsPrecision,int);
286  vtkGetMacro(OutputPointsPrecision,int);
288 
289 protected:
290  vtkDecimatePro();
291  ~vtkDecimatePro() override;
292 
294 
296  double FeatureAngle;
297  double MaximumError;
301  double SplitAngle;
306  int Degree;
310 
311  // to replace a static object
314 
315  void SplitMesh();
316  int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
317  vtkIdType *tris, vtkIdType fedges[2]);
318  vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
319  vtkIdType& pt2, vtkIdList *CollapseTris);
320  int IsValidSplit(int index);
321  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
322  vtkIdType& n2, vtkIdType *l2);
323  void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
324  vtkIdType *tris, int insert);
325  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
326  vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
327  void DistributeError(double error);
328 
329  //
330  // Special classes for manipulating data
331  //
332  // Special structures for building loops
334  {
335  public:
337  double x[3];
338  double FAngle;
339  };
341 
342  class LocalTri
343  {
344  public:
346  double area;
347  double n[3];
348  vtkIdType verts[3];
349  };
351 
352  class VertexArray;
353  friend class VertexArray;
354  class VertexArray { //;prevent man page generation
355  public:
357  {this->MaxId = -1; this->Array = new LocalVertex[sz];};
359  {
360  delete [] this->Array;
361  };
362  vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
364  {this->MaxId++; this->Array[this->MaxId] = v;};
365  LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
366  void Reset() {this->MaxId = -1;};
367 
368  LocalVertex *Array; // pointer to data
369  vtkIdType MaxId; // maximum index inserted thus far
370  };
371 
372  class TriArray;
373  friend class TriArray;
374  class TriArray { //;prevent man page generation
375  public:
376  TriArray(const vtkIdType sz)
377  {this->MaxId = -1; this->Array = new LocalTri[sz];};
379  {
380  delete [] this->Array;
381  };
382  vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
384  {this->MaxId++; this->Array[this->MaxId] = t;};
385  LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
386  void Reset() {this->MaxId = -1;};
387 
388  LocalTri *Array; // pointer to data
389  vtkIdType MaxId; // maximum index inserted thus far
390  };
391 
392 private:
393  void InitializeQueue(vtkIdType numPts);
394  void DeleteQueue();
395  void Insert(vtkIdType id, double error= -1.0);
396  int Pop(double &error);
397  double DeleteId(vtkIdType id);
398  void Reset();
399 
400  vtkPriorityQueue *Queue;
401  vtkDoubleArray *VertexError;
402 
403  VertexArray *V;
404  TriArray *T;
405 
406  // Use to be static variables used by object
407  vtkPolyData *Mesh; //operate on this data structure
408  double Pt[3]; //least squares plane point
409  double Normal[3]; //least squares plane normal
410  double LoopArea; //the total area of all triangles in a loop
411  double CosAngle; //Cosine of dihedral angle
412  double Tolerance; //Intersection tolerance
413  double X[3]; //coordinates of current point
414  int NumCollapses; //Number of times edge collapses occur
415  int NumMerges; //Number of times vertex merges occur
416  int Split; //Controls whether and when vertex splitting occurs
417  int VertexDegree; //Maximum number of triangles that can use a vertex
418  vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
419  double TheSplitAngle; //Split angle
420  int SplitState; //State of the splitting process
421  double Error; //Maximum allowable surface error
422 
423 private:
424  vtkDecimatePro(const vtkDecimatePro&) = delete;
425  void operator=(const vtkDecimatePro&) = delete;
426 };
427 
428 #endif
429 
430 
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:79
#define VTK_CELL_SIZE
Definition: vtkCell.h:40
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:33
list of point or cell ids
Definition: vtkIdList.h:30
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.