VTK  9.2.6
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 =========================================================================*/
92 #ifndef vtkDecimatePro_h
93 #define vtkDecimatePro_h
94 
95 #include "vtkFiltersCoreModule.h" // For export macro
96 #include "vtkPolyDataAlgorithm.h"
97 
98 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
99 
100 class vtkDoubleArray;
101 class vtkPriorityQueue;
102 
103 class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
104 {
105 public:
107  void PrintSelf(ostream& os, vtkIndent indent) override;
108 
117  static vtkDecimatePro* New();
118 
120 
129  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
130  vtkGetMacro(TargetReduction, double);
132 
134 
139  vtkSetMacro(PreserveTopology, vtkTypeBool);
140  vtkGetMacro(PreserveTopology, vtkTypeBool);
141  vtkBooleanMacro(PreserveTopology, vtkTypeBool);
143 
145 
150  vtkSetClampMacro(FeatureAngle, double, 0.0, 180.0);
151  vtkGetMacro(FeatureAngle, double);
153 
155 
161  vtkSetMacro(Splitting, vtkTypeBool);
162  vtkGetMacro(Splitting, vtkTypeBool);
163  vtkBooleanMacro(Splitting, vtkTypeBool);
165 
167 
172  vtkSetClampMacro(SplitAngle, double, 0.0, 180.0);
173  vtkGetMacro(SplitAngle, double);
175 
177 
185  vtkSetMacro(PreSplitMesh, vtkTypeBool);
186  vtkGetMacro(PreSplitMesh, vtkTypeBool);
187  vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
189 
191 
197  vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
198  vtkGetMacro(MaximumError, double);
200 
202 
210  vtkSetMacro(AccumulateError, vtkTypeBool);
211  vtkGetMacro(AccumulateError, vtkTypeBool);
212  vtkBooleanMacro(AccumulateError, vtkTypeBool);
214 
216 
221  vtkSetMacro(ErrorIsAbsolute, int);
222  vtkGetMacro(ErrorIsAbsolute, int);
224 
226 
229  vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
230  vtkGetMacro(AbsoluteError, double);
232 
234 
238  vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
239  vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
240  vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
242 
244 
250  vtkSetClampMacro(Degree, int, 25, VTK_CELL_SIZE);
251  vtkGetMacro(Degree, int);
253 
255 
260  vtkSetClampMacro(InflectionPointRatio, double, 1.001, VTK_DOUBLE_MAX);
261  vtkGetMacro(InflectionPointRatio, double);
263 
272 
279  void GetInflectionPoints(double* inflectionPoints);
280 
289 
291 
296  vtkSetMacro(OutputPointsPrecision, int);
297  vtkGetMacro(OutputPointsPrecision, int);
299 
300 protected:
302  ~vtkDecimatePro() override;
303 
305 
307  double FeatureAngle;
308  double MaximumError;
312  double SplitAngle;
317  int Degree;
321 
322  // to replace a static object
325 
326  void SplitMesh();
327  int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
329  int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
330  int IsValidSplit(int index);
331  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
332  void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
333  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
334  vtkIdList* CollapseTris);
335  void DistributeError(double error);
336 
337  //
338  // Special classes for manipulating data
339  //
340  // Special structures for building loops
342  {
343  public:
345  double x[3];
346  double FAngle;
347  };
349 
350  class LocalTri
351  {
352  public:
354  double area;
355  double n[3];
356  vtkIdType verts[3];
357  };
359 
360  class VertexArray;
361  friend class VertexArray;
363  { //;prevent man page generation
364  public:
366  {
367  this->MaxId = -1;
368  this->Array = new LocalVertex[sz];
369  }
370  ~VertexArray() { delete[] this->Array; }
371  vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
373  {
374  this->MaxId++;
375  this->Array[this->MaxId] = v;
376  }
377  LocalVertex& GetVertex(vtkIdType i) { return this->Array[i]; }
378  void Reset() { this->MaxId = -1; }
379 
380  LocalVertex* Array; // pointer to data
381  vtkIdType MaxId; // maximum index inserted thus far
382  };
383 
384  class TriArray;
385  friend class TriArray;
386  class TriArray
387  { //;prevent man page generation
388  public:
389  TriArray(const vtkIdType sz)
390  {
391  this->MaxId = -1;
392  this->Array = new LocalTri[sz];
393  }
394  ~TriArray() { delete[] this->Array; }
395  vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
397  {
398  this->MaxId++;
399  this->Array[this->MaxId] = t;
400  }
401  LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
402  void Reset() { this->MaxId = -1; }
403 
404  LocalTri* Array; // pointer to data
405  vtkIdType MaxId; // maximum index inserted thus far
406  };
407 
408 private:
409  void InitializeQueue(vtkIdType numPts);
410  void DeleteQueue();
411  void Insert(vtkIdType id, double error = -1.0);
412  int Pop(double& error);
413  double DeleteId(vtkIdType id);
414  void Reset();
415 
416  vtkPriorityQueue* Queue;
417  vtkDoubleArray* VertexError;
418 
419  VertexArray* V;
420  TriArray* T;
421 
422  // Use to be static variables used by object
423  vtkPolyData* Mesh; // operate on this data structure
424  double Pt[3]; // least squares plane point
425  double Normal[3]; // least squares plane normal
426  double LoopArea; // the total area of all triangles in a loop
427  double CosAngle; // Cosine of dihedral angle
428  double Tolerance; // Intersection tolerance
429  double X[3]; // coordinates of current point
430  int NumCollapses; // Number of times edge collapses occur
431  int NumMerges; // Number of times vertex merges occur
432  int Split; // Controls whether and when vertex splitting occurs
433  int VertexDegree; // Maximum number of triangles that can use a vertex
434  vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
435  double TheSplitAngle; // Split angle
436  int SplitState; // State of the splitting process
437  double Error; // Maximum allowable surface error
438 
439 private:
440  vtkDecimatePro(const vtkDecimatePro&) = delete;
441  void operator=(const vtkDecimatePro&) = delete;
442 };
443 
444 #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:43
a simple class to control print indentation
Definition: vtkIndent.h:49
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:100
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:52
int vtkIdType
Definition: vtkType.h:332
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165