VTK  9.5.20250904
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
150#ifndef vtkDecimatePro_h
151#define vtkDecimatePro_h
152
153#include "vtkFiltersCoreModule.h" // For export macro
154#include "vtkPolyDataAlgorithm.h"
155#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
156
157#include "vtkCell.h" // Needed for VTK_CELL_SIZE
158
159VTK_ABI_NAMESPACE_BEGIN
160class vtkDoubleArray;
161class vtkPriorityQueue;
162
163class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkDecimatePro : public vtkPolyDataAlgorithm
164{
165public:
167 void PrintSelf(ostream& os, vtkIndent indent) override;
168
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
360protected:
362 ~vtkDecimatePro() override;
363
365
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
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;
447 { //;prevent man page generation
448 public:
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
468private:
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 vtkDecimatePro(const vtkDecimatePro&) = delete;
500 void operator=(const vtkDecimatePro&) = delete;
501};
502
503VTK_ABI_NAMESPACE_END
504#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:133
a simple class to control print indentation
Definition vtkIndent.h:108
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
a list of ids arranged in priority order
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_CELL_SIZE
Definition vtkCell.h:110
int vtkIdType
Definition vtkType.h:332
#define VTK_DOUBLE_MAX
Definition vtkType.h:171
#define VTK_MARSHALAUTO