VTK  9.0.1
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 
260 
267  void GetInflectionPoints(double* inflectionPoints);
268 
277 
279 
284  vtkSetMacro(OutputPointsPrecision, int);
285  vtkGetMacro(OutputPointsPrecision, int);
287 
288 protected:
290  ~vtkDecimatePro() override;
291 
293 
295  double FeatureAngle;
296  double MaximumError;
300  double SplitAngle;
305  int Degree;
309 
310  // to replace a static object
313 
314  void SplitMesh();
315  int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
317  int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
318  int IsValidSplit(int index);
319  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
320  void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
321  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
322  vtkIdList* CollapseTris);
323  void DistributeError(double error);
324 
325  //
326  // Special classes for manipulating data
327  //
328  // Special structures for building loops
330  {
331  public:
333  double x[3];
334  double FAngle;
335  };
337 
338  class LocalTri
339  {
340  public:
342  double area;
343  double n[3];
344  vtkIdType verts[3];
345  };
347 
348  class VertexArray;
349  friend class VertexArray;
351  { //;prevent man page generation
352  public:
354  {
355  this->MaxId = -1;
356  this->Array = new LocalVertex[sz];
357  }
358  ~VertexArray() { delete[] this->Array; }
359  vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
361  {
362  this->MaxId++;
363  this->Array[this->MaxId] = v;
364  }
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
375  { //;prevent man page generation
376  public:
377  TriArray(const vtkIdType sz)
378  {
379  this->MaxId = -1;
380  this->Array = new LocalTri[sz];
381  }
382  ~TriArray() { delete[] this->Array; }
383  vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
385  {
386  this->MaxId++;
387  this->Array[this->MaxId] = t;
388  }
389  LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
390  void Reset() { this->MaxId = -1; }
391 
392  LocalTri* Array; // pointer to data
393  vtkIdType MaxId; // maximum index inserted thus far
394  };
395 
396 private:
397  void InitializeQueue(vtkIdType numPts);
398  void DeleteQueue();
399  void Insert(vtkIdType id, double error = -1.0);
400  int Pop(double& error);
401  double DeleteId(vtkIdType id);
402  void Reset();
403 
404  vtkPriorityQueue* Queue;
405  vtkDoubleArray* VertexError;
406 
407  VertexArray* V;
408  TriArray* T;
409 
410  // Use to be static variables used by object
411  vtkPolyData* Mesh; // operate on this data structure
412  double Pt[3]; // least squares plane point
413  double Normal[3]; // least squares plane normal
414  double LoopArea; // the total area of all triangles in a loop
415  double CosAngle; // Cosine of dihedral angle
416  double Tolerance; // Intersection tolerance
417  double X[3]; // coordinates of current point
418  int NumCollapses; // Number of times edge collapses occur
419  int NumMerges; // Number of times vertex merges occur
420  int Split; // Controls whether and when vertex splitting occurs
421  int VertexDegree; // Maximum number of triangles that can use a vertex
422  vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
423  double TheSplitAngle; // Split angle
424  int SplitState; // State of the splitting process
425  double Error; // Maximum allowable surface error
426 
427 private:
428  vtkDecimatePro(const vtkDecimatePro&) = delete;
429  void operator=(const vtkDecimatePro&) = delete;
430 };
431 
432 #endif
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
double TargetReduction
void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType *tris, int insert)
void GetInflectionPoints(double *inflectionPoints)
Get a list of inflection points.
int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris)
LocalTri * LocalTriPtr
vtkDoubleArray * InflectionPoints
~vtkDecimatePro() override
vtkIdList * Neighbors
static vtkDecimatePro * New()
Create object with specified reduction of 90% and feature angle of 15 degrees.
void DistributeError(double error)
LocalVertex * LocalVertexPtr
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int IsValidSplit(int index)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType *tris, vtkIdType fedges[2])
vtkTypeBool PreserveTopology
double * GetInflectionPoints()
Get a list of inflection points.
double InflectionPointRatio
vtkIdType GetNumberOfInflectionPoints()
Get the number of inflection points.
vtkTypeBool BoundaryVertexDeletion
vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType &pt1, vtkIdType &pt2, vtkIdList *CollapseTris)
vtkPriorityQueue * EdgeLengths
vtkTypeBool Splitting
vtkTypeBool PreSplitMesh
vtkTypeBool AccumulateError
void SplitLoop(vtkIdType fedges[2], vtkIdType &n1, vtkIdType *l1, vtkIdType &n2, vtkIdType *l2)
dynamic, self-adjusting array of double
list of point or cell ids
Definition: vtkIdList.h:31
a simple class to control print indentation
Definition: vtkIndent.h:34
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:85
a list of ids arranged in priority order
@ Normal
Definition: vtkX3D.h:51
@ type
Definition: vtkX3D.h:522
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_CELL_SIZE
Definition: vtkCell.h:40
int vtkIdType
Definition: vtkType.h:338
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165