VTK  9.6.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
70
71#ifndef vtkDecimatePro_h
72#define vtkDecimatePro_h
73
74#include "vtkFiltersCoreModule.h" // For export macro
76#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
77
78#include "vtkCell.h" // Needed for VTK_CELL_SIZE
79
80VTK_ABI_NAMESPACE_BEGIN
81class vtkDoubleArray;
83
84class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkDecimatePro : public vtkPolyDataAlgorithm
85{
86public:
88 void PrintSelf(ostream& os, vtkIndent indent) override;
89
99
101
110 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
111 vtkGetMacro(TargetReduction, double);
113
115
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
168 vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
170
172
178 vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
179 vtkGetMacro(MaximumError, double);
181
183
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
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
253
260 void GetInflectionPoints(double* inflectionPoints);
261
270
272
277 vtkSetMacro(OutputPointsPrecision, int);
278 vtkGetMacro(OutputPointsPrecision, int);
280
281protected:
283 ~vtkDecimatePro() override;
284
286
302
303 // to replace a static object
306
307 void SplitMesh();
308 int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
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
332 {
333 public:
335 double area;
336 double n[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;
368 { //;prevent man page generation
369 public:
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
389private:
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
424VTK_ABI_NAMESPACE_END
425#endif
vtkIdType id
double n[3]
vtkIdType verts[3]
TriArray(const vtkIdType sz)
LocalTri * Array
void InsertNextTriangle(LocalTri &t)
vtkIdType GetNumberOfTriangles()
LocalTri & GetTriangle(vtkIdType i)
vtkIdType MaxId
vtkIdType GetNumberOfVertices()
LocalVertex & GetVertex(vtkIdType i)
VertexArray(const vtkIdType sz)
LocalVertex * Array
vtkIdType MaxId
void InsertNextVertex(LocalVertex &v)
reduce the number of triangles in a mesh
dynamic, self-adjusting array of double
list of point or cell ids
Definition vtkIdList.h:24
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
a list of ids arranged in priority order
int vtkTypeBool
Definition vtkABI.h:64
static vtkBiQuadraticQuadraticHexahedron * New()
void PrintSelf(ostream &os, vtkIndent indent) override
#define VTK_CELL_SIZE
Definition vtkCell.h:31
void Reset()
Initializes the field list to empty.
int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType *tris, vtkIdType fedges[2])
double TargetReduction
vtkTypeBool AccumulateError
vtkTypeBool PreSplitMesh
void SplitLoop(vtkIdType fedges[2], vtkIdType &n1, vtkIdType *l1, vtkIdType &n2, vtkIdType *l2)
int IsValidSplit(int index)
double AbsoluteError
double MaximumError
int ErrorIsAbsolute
vtkIdList * Neighbors
vtkDecimatePro()
vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType &pt1, vtkIdType &pt2, vtkIdList *CollapseTris)
void DistributeError(double error)
void SplitMesh()
~vtkDecimatePro() override
vtkTypeBool BoundaryVertexDeletion
LocalTri * LocalTriPtr
int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris)
vtkDoubleArray * InflectionPoints
double InflectionPointRatio
double SplitAngle
vtkIdType GetNumberOfInflectionPoints()
Get the number of inflection points.
vtkTypeBool PreserveTopology
int Degree
double FeatureAngle
vtkPriorityQueue * EdgeLengths
vtkTypeBool Splitting
int OutputPointsPrecision
void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType *tris, int insert)
LocalVertex * LocalVertexPtr
double * GetInflectionPoints()
Get a list of inflection points.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int vtkIdType
Definition vtkType.h:368
#define VTK_DOUBLE_MAX
Definition vtkType.h:207
#define VTK_MARSHALAUTO
#define vtkPolyDataAlgorithm