VTK  9.2.5
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 =========================================================================*/
152 #ifndef vtkDecimatePro_h
153 #define vtkDecimatePro_h
154 
155 #include "vtkFiltersCoreModule.h" // For export macro
156 #include "vtkPolyDataAlgorithm.h"
157 
158 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
159 
160 class vtkDoubleArray;
161 class vtkPriorityQueue;
162 
163 class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
164 {
165 public:
167  void PrintSelf(ostream& os, vtkIndent indent) override;
168 
177  static vtkDecimatePro* New();
178 
180 
189  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
190  vtkGetMacro(TargetReduction, double);
192 
194 
199  vtkSetMacro(PreserveTopology, vtkTypeBool);
200  vtkGetMacro(PreserveTopology, vtkTypeBool);
201  vtkBooleanMacro(PreserveTopology, vtkTypeBool);
203 
205 
210  vtkSetClampMacro(FeatureAngle, double, 0.0, 180.0);
211  vtkGetMacro(FeatureAngle, double);
213 
215 
221  vtkSetMacro(Splitting, vtkTypeBool);
222  vtkGetMacro(Splitting, vtkTypeBool);
223  vtkBooleanMacro(Splitting, vtkTypeBool);
225 
227 
232  vtkSetClampMacro(SplitAngle, double, 0.0, 180.0);
233  vtkGetMacro(SplitAngle, double);
235 
237 
245  vtkSetMacro(PreSplitMesh, vtkTypeBool);
246  vtkGetMacro(PreSplitMesh, vtkTypeBool);
247  vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
249 
251 
257  vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
258  vtkGetMacro(MaximumError, double);
260 
262 
270  vtkSetMacro(AccumulateError, vtkTypeBool);
271  vtkGetMacro(AccumulateError, vtkTypeBool);
272  vtkBooleanMacro(AccumulateError, vtkTypeBool);
274 
276 
281  vtkSetMacro(ErrorIsAbsolute, int);
282  vtkGetMacro(ErrorIsAbsolute, int);
284 
286 
289  vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
290  vtkGetMacro(AbsoluteError, double);
292 
294 
298  vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
299  vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
300  vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
302 
304 
310  vtkSetClampMacro(Degree, int, 25, VTK_CELL_SIZE);
311  vtkGetMacro(Degree, int);
313 
315 
320  vtkSetClampMacro(InflectionPointRatio, double, 1.001, VTK_DOUBLE_MAX);
321  vtkGetMacro(InflectionPointRatio, double);
323 
332 
339  void GetInflectionPoints(double* inflectionPoints);
340 
349 
351 
356  vtkSetMacro(OutputPointsPrecision, int);
357  vtkGetMacro(OutputPointsPrecision, int);
359 
360 protected:
362  ~vtkDecimatePro() override;
363 
365 
367  double FeatureAngle;
368  double MaximumError;
372  double SplitAngle;
377  int Degree;
381 
382  // to replace a static object
385 
386  void SplitMesh();
387  int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
389  int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
390  int IsValidSplit(int index);
391  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
392  void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
393  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
394  vtkIdList* CollapseTris);
395  void DistributeError(double error);
396 
397  //
398  // Special classes for manipulating data
399  //
400  // Special structures for building loops
402  {
403  public:
405  double x[3];
406  double FAngle;
407  };
409 
410  class LocalTri
411  {
412  public:
414  double area;
415  double n[3];
416  vtkIdType verts[3];
417  };
419 
420  class VertexArray;
421  friend class VertexArray;
423  { //;prevent man page generation
424  public:
426  {
427  this->MaxId = -1;
428  this->Array = new LocalVertex[sz];
429  }
430  ~VertexArray() { delete[] this->Array; }
431  vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
433  {
434  this->MaxId++;
435  this->Array[this->MaxId] = v;
436  }
437  LocalVertex& GetVertex(vtkIdType i) { return this->Array[i]; }
438  void Reset() { this->MaxId = -1; }
439 
440  LocalVertex* Array; // pointer to data
441  vtkIdType MaxId; // maximum index inserted thus far
442  };
443 
444  class TriArray;
445  friend class TriArray;
446  class TriArray
447  { //;prevent man page generation
448  public:
449  TriArray(const vtkIdType sz)
450  {
451  this->MaxId = -1;
452  this->Array = new LocalTri[sz];
453  }
454  ~TriArray() { delete[] this->Array; }
455  vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
457  {
458  this->MaxId++;
459  this->Array[this->MaxId] = t;
460  }
461  LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
462  void Reset() { this->MaxId = -1; }
463 
464  LocalTri* Array; // pointer to data
465  vtkIdType MaxId; // maximum index inserted thus far
466  };
467 
468 private:
469  void InitializeQueue(vtkIdType numPts);
470  void DeleteQueue();
471  void Insert(vtkIdType id, double error = -1.0);
472  int Pop(double& error);
473  double DeleteId(vtkIdType id);
474  void Reset();
475 
476  vtkPriorityQueue* Queue;
477  vtkDoubleArray* VertexError;
478 
479  VertexArray* V;
480  TriArray* T;
481 
482  // Use to be static variables used by object
483  vtkPolyData* Mesh; // operate on this data structure
484  double Pt[3]; // least squares plane point
485  double Normal[3]; // least squares plane normal
486  double LoopArea; // the total area of all triangles in a loop
487  double CosAngle; // Cosine of dihedral angle
488  double Tolerance; // Intersection tolerance
489  double X[3]; // coordinates of current point
490  int NumCollapses; // Number of times edge collapses occur
491  int NumMerges; // Number of times vertex merges occur
492  int Split; // Controls whether and when vertex splitting occurs
493  int VertexDegree; // Maximum number of triangles that can use a vertex
494  vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
495  double TheSplitAngle; // Split angle
496  int SplitState; // State of the splitting process
497  double Error; // Maximum allowable surface error
498 
499 private:
500  vtkDecimatePro(const vtkDecimatePro&) = delete;
501  void operator=(const vtkDecimatePro&) = delete;
502 };
503 
504 #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:143
a simple class to control print indentation
Definition: vtkIndent.h:119
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:200
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:132
int vtkIdType
Definition: vtkType.h:332
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165