VTK  9.4.20241117
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
156#include "vtkCell.h" // Needed for VTK_CELL_SIZE
157
158VTK_ABI_NAMESPACE_BEGIN
159class vtkDoubleArray;
160class vtkPriorityQueue;
161
162class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
163{
164public:
166 void PrintSelf(ostream& os, vtkIndent indent) override;
167
177
179
188 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
189 vtkGetMacro(TargetReduction, double);
191
193
198 vtkSetMacro(PreserveTopology, vtkTypeBool);
199 vtkGetMacro(PreserveTopology, vtkTypeBool);
200 vtkBooleanMacro(PreserveTopology, vtkTypeBool);
202
204
209 vtkSetClampMacro(FeatureAngle, double, 0.0, 180.0);
210 vtkGetMacro(FeatureAngle, double);
212
214
220 vtkSetMacro(Splitting, vtkTypeBool);
221 vtkGetMacro(Splitting, vtkTypeBool);
222 vtkBooleanMacro(Splitting, vtkTypeBool);
224
226
231 vtkSetClampMacro(SplitAngle, double, 0.0, 180.0);
232 vtkGetMacro(SplitAngle, double);
234
236
244 vtkSetMacro(PreSplitMesh, vtkTypeBool);
245 vtkGetMacro(PreSplitMesh, vtkTypeBool);
246 vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
248
250
256 vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
257 vtkGetMacro(MaximumError, double);
259
261
269 vtkSetMacro(AccumulateError, vtkTypeBool);
270 vtkGetMacro(AccumulateError, vtkTypeBool);
271 vtkBooleanMacro(AccumulateError, vtkTypeBool);
273
275
280 vtkSetMacro(ErrorIsAbsolute, int);
281 vtkGetMacro(ErrorIsAbsolute, int);
283
285
288 vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
289 vtkGetMacro(AbsoluteError, double);
291
293
297 vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
298 vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
299 vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
301
303
309 vtkSetClampMacro(Degree, int, 25, VTK_CELL_SIZE);
310 vtkGetMacro(Degree, int);
312
314
319 vtkSetClampMacro(InflectionPointRatio, double, 1.001, VTK_DOUBLE_MAX);
320 vtkGetMacro(InflectionPointRatio, double);
322
331
338 void GetInflectionPoints(double* inflectionPoints);
339
348
350
355 vtkSetMacro(OutputPointsPrecision, int);
356 vtkGetMacro(OutputPointsPrecision, int);
358
359protected:
361 ~vtkDecimatePro() override;
362
364
380
381 // to replace a static object
384
385 void SplitMesh();
386 int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
388 int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
389 int IsValidSplit(int index);
390 void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
391 void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
392 int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
393 vtkIdList* CollapseTris);
394 void DistributeError(double error);
395
396 //
397 // Special classes for manipulating data
398 //
399 // Special structures for building loops
401 {
402 public:
404 double x[3];
405 double FAngle;
406 };
408
410 {
411 public:
413 double area;
414 double n[3];
415 vtkIdType verts[3];
416 };
418
419 class VertexArray;
420 friend class VertexArray;
422 { //;prevent man page generation
423 public:
425 {
426 this->MaxId = -1;
427 this->Array = new LocalVertex[sz];
428 }
429 ~VertexArray() { delete[] this->Array; }
430 vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
432 {
433 this->MaxId++;
434 this->Array[this->MaxId] = v;
435 }
436 LocalVertex& GetVertex(vtkIdType i) { return this->Array[i]; }
437 void Reset() { this->MaxId = -1; }
438
439 LocalVertex* Array; // pointer to data
440 vtkIdType MaxId; // maximum index inserted thus far
441 };
442
443 class TriArray;
444 friend class TriArray;
446 { //;prevent man page generation
447 public:
449 {
450 this->MaxId = -1;
451 this->Array = new LocalTri[sz];
452 }
453 ~TriArray() { delete[] this->Array; }
454 vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
456 {
457 this->MaxId++;
458 this->Array[this->MaxId] = t;
459 }
460 LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
461 void Reset() { this->MaxId = -1; }
462
463 LocalTri* Array; // pointer to data
464 vtkIdType MaxId; // maximum index inserted thus far
465 };
466
467private:
468 void InitializeQueue(vtkIdType numPts);
469 void DeleteQueue();
470 void Insert(vtkIdType id, double error = -1.0);
471 int Pop(double& error);
472 double DeleteId(vtkIdType id);
473 void Reset();
474
475 vtkPriorityQueue* Queue;
476 vtkDoubleArray* VertexError;
477
478 VertexArray* V;
479 TriArray* T;
480
481 // Use to be static variables used by object
482 vtkPolyData* Mesh; // operate on this data structure
483 double Pt[3]; // least squares plane point
484 double Normal[3]; // least squares plane normal
485 double LoopArea; // the total area of all triangles in a loop
486 double CosAngle; // Cosine of dihedral angle
487 double Tolerance; // Intersection tolerance
488 double X[3]; // coordinates of current point
489 int NumCollapses; // Number of times edge collapses occur
490 int NumMerges; // Number of times vertex merges occur
491 int Split; // Controls whether and when vertex splitting occurs
492 int VertexDegree; // Maximum number of triangles that can use a vertex
493 vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
494 double TheSplitAngle; // Split angle
495 int SplitState; // State of the splitting process
496 double Error; // Maximum allowable surface error
497
498 vtkDecimatePro(const vtkDecimatePro&) = delete;
499 void operator=(const vtkDecimatePro&) = delete;
500};
501
502VTK_ABI_NAMESPACE_END
503#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:315
#define VTK_DOUBLE_MAX
Definition vtkType.h:154