VTK  9.7.1
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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
77 
78 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
79 
80 VTK_ABI_NAMESPACE_BEGIN
81 class vtkDoubleArray;
82 class vtkPriorityQueue;
83 
84 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkDecimatePro : public vtkPolyDataAlgorithm
85 {
86 public:
88  void PrintSelf(ostream& os, vtkIndent indent) override;
89 
98  static vtkDecimatePro* New();
99 
101 
110  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
111  vtkGetMacro(TargetReduction, double);
113 
115 
120  vtkSetMacro(PreserveTopology, vtkTypeBool);
121  vtkGetMacro(PreserveTopology, vtkTypeBool);
122  vtkBooleanMacro(PreserveTopology, vtkTypeBool);
124 
126 
131  vtkSetClampMacro(FeatureAngle, double, 0.0, 180.0);
132  vtkGetMacro(FeatureAngle, double);
134 
136 
142  vtkSetMacro(Splitting, vtkTypeBool);
143  vtkGetMacro(Splitting, vtkTypeBool);
144  vtkBooleanMacro(Splitting, vtkTypeBool);
146 
148 
153  vtkSetClampMacro(SplitAngle, double, 0.0, 180.0);
154  vtkGetMacro(SplitAngle, double);
156 
158 
166  vtkSetMacro(PreSplitMesh, vtkTypeBool);
167  vtkGetMacro(PreSplitMesh, vtkTypeBool);
168  vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
170 
172 
178  vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
179  vtkGetMacro(MaximumError, double);
181 
183 
191  vtkSetMacro(AccumulateError, vtkTypeBool);
192  vtkGetMacro(AccumulateError, vtkTypeBool);
193  vtkBooleanMacro(AccumulateError, vtkTypeBool);
195 
197 
202  vtkSetMacro(ErrorIsAbsolute, int);
203  vtkGetMacro(ErrorIsAbsolute, int);
205 
207 
210  vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
211  vtkGetMacro(AbsoluteError, double);
213 
215 
219  vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
220  vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
221  vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
223 
225 
231  vtkSetClampMacro(Degree, int, 25, VTK_CELL_SIZE);
232  vtkGetMacro(Degree, int);
234 
236 
241  vtkSetClampMacro(InflectionPointRatio, double, 1.001, VTK_DOUBLE_MAX);
242  vtkGetMacro(InflectionPointRatio, double);
244 
252  vtkIdType GetNumberOfInflectionPoints();
253 
260  void GetInflectionPoints(double* inflectionPoints);
261 
269  double* GetInflectionPoints();
270 
272 
277  vtkSetMacro(OutputPointsPrecision, int);
278  vtkGetMacro(OutputPointsPrecision, int);
280 
281 protected:
282  vtkDecimatePro();
283  ~vtkDecimatePro() override;
284 
286 
288  double FeatureAngle;
289  double MaximumError;
293  double SplitAngle;
298  int Degree;
302 
303  // to replace a static object
306 
307  void SplitMesh();
308  int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
309  vtkIdType FindSplit(
310  int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
311  int IsValidSplit(int index);
312  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
313  void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
314  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
315  vtkIdList* CollapseTris);
316  void DistributeError(double error);
317 
318  //
319  // Special classes for manipulating data
320  //
321  // Special structures for building loops
323  {
324  public:
326  double x[3];
327  double FAngle;
328  };
330 
331  class LocalTri
332  {
333  public:
335  double area;
336  double n[3];
337  vtkIdType verts[3];
338  };
340 
341  class VertexArray;
342  friend class VertexArray;
344  { //;prevent man page generation
345  public:
347  {
348  this->MaxId = -1;
349  this->Array = new LocalVertex[sz];
350  }
351  ~VertexArray() { delete[] this->Array; }
352  vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
354  {
355  this->MaxId++;
356  this->Array[this->MaxId] = v;
357  }
358  LocalVertex& GetVertex(vtkIdType i) { return this->Array[i]; }
359  void Reset() { this->MaxId = -1; }
360 
361  LocalVertex* Array; // pointer to data
362  vtkIdType MaxId; // maximum index inserted thus far
363  };
364 
365  class TriArray;
366  friend class TriArray;
367  class TriArray
368  { //;prevent man page generation
369  public:
370  TriArray(const vtkIdType sz)
371  {
372  this->MaxId = -1;
373  this->Array = new LocalTri[sz];
374  }
375  ~TriArray() { delete[] this->Array; }
376  vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
378  {
379  this->MaxId++;
380  this->Array[this->MaxId] = t;
381  }
382  LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
383  void Reset() { this->MaxId = -1; }
384 
385  LocalTri* Array; // pointer to data
386  vtkIdType MaxId; // maximum index inserted thus far
387  };
388 
389 private:
390  void InitializeQueue(vtkIdType numPts);
391  void DeleteQueue();
392  void Insert(vtkIdType id, double error = -1.0);
393  int Pop(double& error);
394  double DeleteId(vtkIdType id);
395  void Reset();
396 
397  vtkPriorityQueue* Queue;
398  vtkDoubleArray* VertexError;
399 
400  VertexArray* V;
401  TriArray* T;
402 
403  // Use to be static variables used by object
404  vtkPolyData* Mesh; // operate on this data structure
405  double Pt[3]; // least squares plane point
406  double Normal[3]; // least squares plane normal
407  double LoopArea; // the total area of all triangles in a loop
408  double CosAngle; // Cosine of dihedral angle
409  double Tolerance; // Intersection tolerance
410  double X[3]; // coordinates of current point
411  int NumCollapses; // Number of times edge collapses occur
412  int NumMerges; // Number of times vertex merges occur
413  int Split; // Controls whether and when vertex splitting occurs
414  int VertexDegree; // Maximum number of triangles that can use a vertex
415  vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
416  double TheSplitAngle; // Split angle
417  int SplitState; // State of the splitting process
418  double Error; // Maximum allowable surface error
419 
420  vtkDecimatePro(const vtkDecimatePro&) = delete;
421  void operator=(const vtkDecimatePro&) = delete;
422 };
423 
424 VTK_ABI_NAMESPACE_END
425 #endif
vtkTypeBool AccumulateError
vtkTypeBool BoundaryVertexDeletion
LocalTri & GetTriangle(vtkIdType i)
#define VTK_DOUBLE_MAX
Definition: vtkType.h:202
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:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
#define VTK_CELL_SIZE
Definition: vtkCell.h:31
dynamic, self-adjusting array of double
a list of ids arranged in priority order
LocalVertex * LocalVertexPtr
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:64
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:28
list of point or cell ids
Definition: vtkIdList.h:25
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.
#define VTK_MARSHALAUTO
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.