VTK  9.0.20210725
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
vtkDecimatePro::TriArray::~TriArray
~TriArray()
Definition: vtkDecimatePro.h:382
vtkDecimatePro::TriArray::InsertNextTriangle
void InsertNextTriangle(LocalTri &t)
Definition: vtkDecimatePro.h:384
vtkDecimatePro::LocalTriPtr
LocalTri * LocalTriPtr
Definition: vtkDecimatePro.h:346
vtkDecimatePro::TriArray::Array
LocalTri * Array
Definition: vtkDecimatePro.h:392
vtkDecimatePro::TriArray::GetNumberOfTriangles
vtkIdType GetNumberOfTriangles()
Definition: vtkDecimatePro.h:383
vtkDecimatePro::GetInflectionPoints
double * GetInflectionPoints()
Get a list of inflection points.
vtkDecimatePro::OutputPointsPrecision
int OutputPointsPrecision
Definition: vtkDecimatePro.h:308
vtkDecimatePro::PreSplitMesh
vtkTypeBool PreSplitMesh
Definition: vtkDecimatePro.h:302
vtkDecimatePro::DistributeError
void DistributeError(double error)
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkDecimatePro::VertexArray::~VertexArray
~VertexArray()
Definition: vtkDecimatePro.h:358
vtkDecimatePro::SplitAngle
double SplitAngle
Definition: vtkDecimatePro.h:300
vtkDecimatePro::TriArray
Definition: vtkDecimatePro.h:375
vtkDecimatePro::VertexArray::MaxId
vtkIdType MaxId
Definition: vtkDecimatePro.h:369
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:36
vtkDecimatePro::LocalVertexPtr
LocalVertex * LocalVertexPtr
Definition: vtkDecimatePro.h:336
vtkDecimatePro::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkX3D::Normal
@ Normal
Definition: vtkX3D.h:51
vtkDecimatePro::SplitLoop
void SplitLoop(vtkIdType fedges[2], vtkIdType &n1, vtkIdType *l1, vtkIdType &n2, vtkIdType *l2)
vtkPriorityQueue
a list of ids arranged in priority order
Definition: vtkPriorityQueue.h:47
vtkDecimatePro::TriArray::GetTriangle
LocalTri & GetTriangle(vtkIdType i)
Definition: vtkDecimatePro.h:389
vtkDecimatePro::BoundaryVertexDeletion
vtkTypeBool BoundaryVertexDeletion
Definition: vtkDecimatePro.h:303
vtkDecimatePro::Degree
int Degree
Definition: vtkDecimatePro.h:305
vtkCell.h
vtkDecimatePro::CollapseEdge
int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris)
vtkPolyDataAlgorithm.h
vtkDecimatePro::vtkDecimatePro
vtkDecimatePro()
vtkDecimatePro
reduce the number of triangles in a mesh
Definition: vtkDecimatePro.h:92
vtkDecimatePro::MaximumError
double MaximumError
Definition: vtkDecimatePro.h:296
vtkDecimatePro::New
static vtkDecimatePro * New()
Create object with specified reduction of 90% and feature angle of 15 degrees.
VTK_CELL_SIZE
#define VTK_CELL_SIZE
Definition: vtkCell.h:40
vtkDecimatePro::LocalTri::id
vtkIdType id
Definition: vtkDecimatePro.h:341
vtkDecimatePro::AbsoluteError
double AbsoluteError
Definition: vtkDecimatePro.h:297
vtkDecimatePro::VertexArray::Reset
void Reset()
Definition: vtkDecimatePro.h:366
vtkDecimatePro::EdgeLengths
vtkPriorityQueue * EdgeLengths
Definition: vtkDecimatePro.h:312
vtkDecimatePro::VertexArray
Definition: vtkDecimatePro.h:351
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkDecimatePro::SplitVertex
void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType *tris, int insert)
vtkDecimatePro::Neighbors
vtkIdList * Neighbors
Definition: vtkDecimatePro.h:311
vtkDecimatePro::VertexArray::GetVertex
LocalVertex & GetVertex(vtkIdType i)
Definition: vtkDecimatePro.h:365
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:31
vtkDecimatePro::LocalTri::area
double area
Definition: vtkDecimatePro.h:342
vtkDecimatePro::VertexArray::InsertNextVertex
void InsertNextVertex(LocalVertex &v)
Definition: vtkDecimatePro.h:360
vtkDecimatePro::TargetReduction
double TargetReduction
Definition: vtkDecimatePro.h:294
vtkDecimatePro::InflectionPointRatio
double InflectionPointRatio
Definition: vtkDecimatePro.h:306
vtkDecimatePro::~vtkDecimatePro
~vtkDecimatePro() override
vtkDecimatePro::VertexArray::Array
LocalVertex * Array
Definition: vtkDecimatePro.h:368
vtkDecimatePro::TriArray::TriArray
TriArray(const vtkIdType sz)
Definition: vtkDecimatePro.h:377
vtkDecimatePro::InflectionPoints
vtkDoubleArray * InflectionPoints
Definition: vtkDecimatePro.h:307
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:74
vtkDecimatePro::Splitting
vtkTypeBool Splitting
Definition: vtkDecimatePro.h:301
vtkDecimatePro::GetNumberOfInflectionPoints
vtkIdType GetNumberOfInflectionPoints()
Get the number of inflection points.
vtkDecimatePro::EvaluateVertex
int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType *tris, vtkIdType fedges[2])
vtkDecimatePro::LocalVertex
Definition: vtkDecimatePro.h:330
vtkDecimatePro::ErrorIsAbsolute
int ErrorIsAbsolute
Definition: vtkDecimatePro.h:298
vtkDecimatePro::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkDecimatePro::FindSplit
vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType &pt1, vtkIdType &pt2, vtkIdList *CollapseTris)
vtkDecimatePro::LocalVertex::FAngle
double FAngle
Definition: vtkDecimatePro.h:334
vtkDecimatePro::AccumulateError
vtkTypeBool AccumulateError
Definition: vtkDecimatePro.h:299
vtkDecimatePro::FeatureAngle
double FeatureAngle
Definition: vtkDecimatePro.h:295
vtkDecimatePro::TriArray::MaxId
vtkIdType MaxId
Definition: vtkDecimatePro.h:393
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
vtkDecimatePro::VertexArray::VertexArray
VertexArray(const vtkIdType sz)
Definition: vtkDecimatePro.h:353
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:36
vtkDecimatePro::VertexArray::GetNumberOfVertices
vtkIdType GetNumberOfVertices()
Definition: vtkDecimatePro.h:359
vtkDecimatePro::TriArray::Reset
void Reset()
Definition: vtkDecimatePro.h:390
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkDecimatePro::LocalVertex::id
vtkIdType id
Definition: vtkDecimatePro.h:332
vtkDecimatePro::GetInflectionPoints
void GetInflectionPoints(double *inflectionPoints)
Get a list of inflection points.
vtkDecimatePro::IsValidSplit
int IsValidSplit(int index)
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkDecimatePro::SplitMesh
void SplitMesh()
vtkDecimatePro::PreserveTopology
vtkTypeBool PreserveTopology
Definition: vtkDecimatePro.h:304
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:42
vtkDecimatePro::LocalTri
Definition: vtkDecimatePro.h:339