VTK  9.3.0
vtkDecimatePro.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
71 #ifndef vtkDecimatePro_h
72 #define vtkDecimatePro_h
73 
74 #include "vtkFiltersCoreModule.h" // For export macro
75 #include "vtkPolyDataAlgorithm.h"
76 
77 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
78 
79 VTK_ABI_NAMESPACE_BEGIN
80 class vtkDoubleArray;
81 class vtkPriorityQueue;
82 
83 class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
84 {
85 public:
87  void PrintSelf(ostream& os, vtkIndent indent) override;
88 
97  static vtkDecimatePro* New();
98 
100 
109  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
110  vtkGetMacro(TargetReduction, double);
112 
114 
119  vtkSetMacro(PreserveTopology, vtkTypeBool);
120  vtkGetMacro(PreserveTopology, vtkTypeBool);
121  vtkBooleanMacro(PreserveTopology, vtkTypeBool);
123 
125 
130  vtkSetClampMacro(FeatureAngle, double, 0.0, 180.0);
131  vtkGetMacro(FeatureAngle, double);
133 
135 
141  vtkSetMacro(Splitting, vtkTypeBool);
142  vtkGetMacro(Splitting, vtkTypeBool);
143  vtkBooleanMacro(Splitting, vtkTypeBool);
145 
147 
152  vtkSetClampMacro(SplitAngle, double, 0.0, 180.0);
153  vtkGetMacro(SplitAngle, double);
155 
157 
165  vtkSetMacro(PreSplitMesh, vtkTypeBool);
166  vtkGetMacro(PreSplitMesh, vtkTypeBool);
167  vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
169 
171 
177  vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
178  vtkGetMacro(MaximumError, double);
180 
182 
190  vtkSetMacro(AccumulateError, vtkTypeBool);
191  vtkGetMacro(AccumulateError, vtkTypeBool);
192  vtkBooleanMacro(AccumulateError, vtkTypeBool);
194 
196 
201  vtkSetMacro(ErrorIsAbsolute, int);
202  vtkGetMacro(ErrorIsAbsolute, int);
204 
206 
209  vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
210  vtkGetMacro(AbsoluteError, double);
212 
214 
218  vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
219  vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
220  vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
222 
224 
230  vtkSetClampMacro(Degree, int, 25, VTK_CELL_SIZE);
231  vtkGetMacro(Degree, int);
233 
235 
240  vtkSetClampMacro(InflectionPointRatio, double, 1.001, VTK_DOUBLE_MAX);
241  vtkGetMacro(InflectionPointRatio, double);
243 
252 
259  void GetInflectionPoints(double* inflectionPoints);
260 
269 
271 
276  vtkSetMacro(OutputPointsPrecision, int);
277  vtkGetMacro(OutputPointsPrecision, int);
279 
280 protected:
282  ~vtkDecimatePro() override;
283 
285 
287  double FeatureAngle;
288  double MaximumError;
292  double SplitAngle;
297  int Degree;
301 
302  // to replace a static object
305 
306  void SplitMesh();
307  int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
309  int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
310  int IsValidSplit(int index);
311  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
312  void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
313  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
314  vtkIdList* CollapseTris);
315  void DistributeError(double error);
316 
317  //
318  // Special classes for manipulating data
319  //
320  // Special structures for building loops
322  {
323  public:
325  double x[3];
326  double FAngle;
327  };
329 
330  class LocalTri
331  {
332  public:
334  double area;
335  double n[3];
336  vtkIdType verts[3];
337  };
339 
340  class VertexArray;
341  friend class VertexArray;
343  { //;prevent man page generation
344  public:
346  {
347  this->MaxId = -1;
348  this->Array = new LocalVertex[sz];
349  }
350  ~VertexArray() { delete[] this->Array; }
351  vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
353  {
354  this->MaxId++;
355  this->Array[this->MaxId] = v;
356  }
357  LocalVertex& GetVertex(vtkIdType i) { return this->Array[i]; }
358  void Reset() { this->MaxId = -1; }
359 
360  LocalVertex* Array; // pointer to data
361  vtkIdType MaxId; // maximum index inserted thus far
362  };
363 
364  class TriArray;
365  friend class TriArray;
366  class TriArray
367  { //;prevent man page generation
368  public:
369  TriArray(const vtkIdType sz)
370  {
371  this->MaxId = -1;
372  this->Array = new LocalTri[sz];
373  }
374  ~TriArray() { delete[] this->Array; }
375  vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
377  {
378  this->MaxId++;
379  this->Array[this->MaxId] = t;
380  }
381  LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
382  void Reset() { this->MaxId = -1; }
383 
384  LocalTri* Array; // pointer to data
385  vtkIdType MaxId; // maximum index inserted thus far
386  };
387 
388 private:
389  void InitializeQueue(vtkIdType numPts);
390  void DeleteQueue();
391  void Insert(vtkIdType id, double error = -1.0);
392  int Pop(double& error);
393  double DeleteId(vtkIdType id);
394  void Reset();
395 
396  vtkPriorityQueue* Queue;
397  vtkDoubleArray* VertexError;
398 
399  VertexArray* V;
400  TriArray* T;
401 
402  // Use to be static variables used by object
403  vtkPolyData* Mesh; // operate on this data structure
404  double Pt[3]; // least squares plane point
405  double Normal[3]; // least squares plane normal
406  double LoopArea; // the total area of all triangles in a loop
407  double CosAngle; // Cosine of dihedral angle
408  double Tolerance; // Intersection tolerance
409  double X[3]; // coordinates of current point
410  int NumCollapses; // Number of times edge collapses occur
411  int NumMerges; // Number of times vertex merges occur
412  int Split; // Controls whether and when vertex splitting occurs
413  int VertexDegree; // Maximum number of triangles that can use a vertex
414  vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
415  double TheSplitAngle; // Split angle
416  int SplitState; // State of the splitting process
417  double Error; // Maximum allowable surface error
418 
419  vtkDecimatePro(const vtkDecimatePro&) = delete;
420  void operator=(const vtkDecimatePro&) = delete;
421 };
422 
423 VTK_ABI_NAMESPACE_END
424 #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:23
a simple class to control print indentation
Definition: vtkIndent.h:29
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:80
a list of ids arranged in priority order
@ Normal
Definition: vtkX3D.h:45
@ type
Definition: vtkX3D.h:516
@ index
Definition: vtkX3D.h:246
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_CELL_SIZE
Definition: vtkCell.h:31
int vtkIdType
Definition: vtkType.h:315
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154