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
80#ifndef vtkDecimatePro_h
81#define vtkDecimatePro_h
82
83#include "vtkFiltersCoreModule.h" // For export macro
85
86#include "vtkCell.h" // Needed for VTK_CELL_SIZE
87
88VTK_ABI_NAMESPACE_BEGIN
89class vtkDoubleArray;
91
92class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
93{
94public:
96 void PrintSelf(ostream& os, vtkIndent indent) override;
97
107
109
118 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
119 vtkGetMacro(TargetReduction, double);
121
123
128 vtkSetMacro(PreserveTopology, vtkTypeBool);
129 vtkGetMacro(PreserveTopology, vtkTypeBool);
130 vtkBooleanMacro(PreserveTopology, vtkTypeBool);
132
134
139 vtkSetClampMacro(FeatureAngle, double, 0.0, 180.0);
140 vtkGetMacro(FeatureAngle, double);
142
144
150 vtkSetMacro(Splitting, vtkTypeBool);
151 vtkGetMacro(Splitting, vtkTypeBool);
152 vtkBooleanMacro(Splitting, vtkTypeBool);
154
156
161 vtkSetClampMacro(SplitAngle, double, 0.0, 180.0);
162 vtkGetMacro(SplitAngle, double);
164
166
174 vtkSetMacro(PreSplitMesh, vtkTypeBool);
175 vtkGetMacro(PreSplitMesh, vtkTypeBool);
176 vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
178
180
186 vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
187 vtkGetMacro(MaximumError, double);
189
191
199 vtkSetMacro(AccumulateError, vtkTypeBool);
200 vtkGetMacro(AccumulateError, vtkTypeBool);
201 vtkBooleanMacro(AccumulateError, vtkTypeBool);
203
205
210 vtkSetMacro(ErrorIsAbsolute, int);
211 vtkGetMacro(ErrorIsAbsolute, int);
213
215
218 vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
219 vtkGetMacro(AbsoluteError, double);
221
223
227 vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
228 vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
229 vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
231
233
239 vtkSetClampMacro(Degree, int, 25, VTK_CELL_SIZE);
240 vtkGetMacro(Degree, int);
242
244
249 vtkSetClampMacro(InflectionPointRatio, double, 1.001, VTK_DOUBLE_MAX);
250 vtkGetMacro(InflectionPointRatio, double);
252
261
268 void GetInflectionPoints(double* inflectionPoints);
269
278
280
285 vtkSetMacro(OutputPointsPrecision, int);
286 vtkGetMacro(OutputPointsPrecision, int);
288
289protected:
291 ~vtkDecimatePro() override;
292
294
310
311 // to replace a static object
314
315 void SplitMesh();
316 int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
318 int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
319 int IsValidSplit(int index);
320 void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
321 void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
322 int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
323 vtkIdList* CollapseTris);
324 void DistributeError(double error);
325
326 //
327 // Special classes for manipulating data
328 //
329 // Special structures for building loops
331 {
332 public:
334 double x[3];
335 double FAngle;
336 };
338
340 {
341 public:
343 double area;
344 double n[3];
345 vtkIdType verts[3];
346 };
348
349 class VertexArray;
350 friend class VertexArray;
352 { //;prevent man page generation
353 public:
355 {
356 this->MaxId = -1;
357 this->Array = new LocalVertex[sz];
358 }
359 ~VertexArray() { delete[] this->Array; }
360 vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
362 {
363 this->MaxId++;
364 this->Array[this->MaxId] = v;
365 }
366 LocalVertex& GetVertex(vtkIdType i) { return this->Array[i]; }
367 void Reset() { this->MaxId = -1; }
368
369 LocalVertex* Array; // pointer to data
370 vtkIdType MaxId; // maximum index inserted thus far
371 };
372
373 class TriArray;
374 friend class TriArray;
376 { //;prevent man page generation
377 public:
379 {
380 this->MaxId = -1;
381 this->Array = new LocalTri[sz];
382 }
383 ~TriArray() { delete[] this->Array; }
384 vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
386 {
387 this->MaxId++;
388 this->Array[this->MaxId] = t;
389 }
390 LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
391 void Reset() { this->MaxId = -1; }
392
393 LocalTri* Array; // pointer to data
394 vtkIdType MaxId; // maximum index inserted thus far
395 };
396
397private:
398 void InitializeQueue(vtkIdType numPts);
399 void DeleteQueue();
400 void Insert(vtkIdType id, double error = -1.0);
401 int Pop(double& error);
402 double DeleteId(vtkIdType id);
403 void Reset();
404
405 vtkPriorityQueue* Queue;
406 vtkDoubleArray* VertexError;
407
408 VertexArray* V;
409 TriArray* T;
410
411 // Use to be static variables used by object
412 vtkPolyData* Mesh; // operate on this data structure
413 double Pt[3]; // least squares plane point
414 double Normal[3]; // least squares plane normal
415 double LoopArea; // the total area of all triangles in a loop
416 double CosAngle; // Cosine of dihedral angle
417 double Tolerance; // Intersection tolerance
418 double X[3]; // coordinates of current point
419 int NumCollapses; // Number of times edge collapses occur
420 int NumMerges; // Number of times vertex merges occur
421 int Split; // Controls whether and when vertex splitting occurs
422 int VertexDegree; // Maximum number of triangles that can use a vertex
423 vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
424 double TheSplitAngle; // Split angle
425 int SplitState; // State of the splitting process
426 double Error; // Maximum allowable surface error
427
428 vtkDecimatePro(const vtkDecimatePro&) = delete;
429 void operator=(const vtkDecimatePro&) = delete;
430};
431
432VTK_ABI_NAMESPACE_END
433#endif
void InsertNextTriangle(LocalTri &t)
LocalTri & GetTriangle(vtkIdType i)
TriArray(const vtkIdType sz)
VertexArray(const vtkIdType sz)
LocalVertex & GetVertex(vtkIdType i)
void InsertNextVertex(LocalVertex &v)
reduce the number of triangles in a mesh
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
void DistributeError(double error)
LocalVertex * LocalVertexPtr
static vtkDecimatePro * New()
Create object with specified reduction of 90% and feature angle of 15 degrees.
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 InflectionPointRatio
vtkIdType GetNumberOfInflectionPoints()
Get the number of inflection points.
vtkTypeBool BoundaryVertexDeletion
double * GetInflectionPoints()
Get a list of inflection points.
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:32
a simple class to control print indentation
Definition vtkIndent.h:38
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:89
a list of ids arranged in priority order
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_CELL_SIZE
Definition vtkCell.h:40
int vtkIdType
Definition vtkType.h:315
#define VTK_DOUBLE_MAX
Definition vtkType.h:154