VTK  9.1.0
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=========================================================================*/
149#ifndef vtkDecimatePro_h
150#define vtkDecimatePro_h
151
152#include "vtkFiltersCoreModule.h" // For export macro
153#include "vtkPolyDataAlgorithm.h"
154
155#include "vtkCell.h" // Needed for VTK_CELL_SIZE
156
157class vtkDoubleArray;
158class vtkPriorityQueue;
159
160class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
161{
162public:
164 void PrintSelf(ostream& os, vtkIndent indent) override;
165
175
177
186 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
187 vtkGetMacro(TargetReduction, double);
189
191
196 vtkSetMacro(PreserveTopology, vtkTypeBool);
197 vtkGetMacro(PreserveTopology, vtkTypeBool);
198 vtkBooleanMacro(PreserveTopology, vtkTypeBool);
200
202
207 vtkSetClampMacro(FeatureAngle, double, 0.0, 180.0);
208 vtkGetMacro(FeatureAngle, double);
210
212
218 vtkSetMacro(Splitting, vtkTypeBool);
219 vtkGetMacro(Splitting, vtkTypeBool);
220 vtkBooleanMacro(Splitting, vtkTypeBool);
222
224
229 vtkSetClampMacro(SplitAngle, double, 0.0, 180.0);
230 vtkGetMacro(SplitAngle, double);
232
234
242 vtkSetMacro(PreSplitMesh, vtkTypeBool);
243 vtkGetMacro(PreSplitMesh, vtkTypeBool);
244 vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
246
248
254 vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
255 vtkGetMacro(MaximumError, double);
257
259
267 vtkSetMacro(AccumulateError, vtkTypeBool);
268 vtkGetMacro(AccumulateError, vtkTypeBool);
269 vtkBooleanMacro(AccumulateError, vtkTypeBool);
271
273
278 vtkSetMacro(ErrorIsAbsolute, int);
279 vtkGetMacro(ErrorIsAbsolute, int);
281
283
286 vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
287 vtkGetMacro(AbsoluteError, double);
289
291
295 vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
296 vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
297 vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
299
301
307 vtkSetClampMacro(Degree, int, 25, VTK_CELL_SIZE);
308 vtkGetMacro(Degree, int);
310
312
317 vtkSetClampMacro(InflectionPointRatio, double, 1.001, VTK_DOUBLE_MAX);
318 vtkGetMacro(InflectionPointRatio, double);
320
329
336 void GetInflectionPoints(double* inflectionPoints);
337
346
348
353 vtkSetMacro(OutputPointsPrecision, int);
354 vtkGetMacro(OutputPointsPrecision, int);
356
357protected:
359 ~vtkDecimatePro() override;
360
362
378
379 // to replace a static object
382
383 void SplitMesh();
384 int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
386 int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
388 void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
389 void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
390 int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
391 vtkIdList* CollapseTris);
392 void DistributeError(double error);
393
394 //
395 // Special classes for manipulating data
396 //
397 // Special structures for building loops
399 {
400 public:
402 double x[3];
403 double FAngle;
404 };
406
408 {
409 public:
411 double area;
412 double n[3];
413 vtkIdType verts[3];
414 };
416
417 class VertexArray;
418 friend class VertexArray;
420 { //;prevent man page generation
421 public:
423 {
424 this->MaxId = -1;
425 this->Array = new LocalVertex[sz];
426 }
427 ~VertexArray() { delete[] this->Array; }
428 vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
430 {
431 this->MaxId++;
432 this->Array[this->MaxId] = v;
433 }
434 LocalVertex& GetVertex(vtkIdType i) { return this->Array[i]; }
435 void Reset() { this->MaxId = -1; }
436
437 LocalVertex* Array; // pointer to data
438 vtkIdType MaxId; // maximum index inserted thus far
439 };
440
441 class TriArray;
442 friend class TriArray;
444 { //;prevent man page generation
445 public:
447 {
448 this->MaxId = -1;
449 this->Array = new LocalTri[sz];
450 }
451 ~TriArray() { delete[] this->Array; }
452 vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
454 {
455 this->MaxId++;
456 this->Array[this->MaxId] = t;
457 }
458 LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
459 void Reset() { this->MaxId = -1; }
460
461 LocalTri* Array; // pointer to data
462 vtkIdType MaxId; // maximum index inserted thus far
463 };
464
465private:
466 void InitializeQueue(vtkIdType numPts);
467 void DeleteQueue();
468 void Insert(vtkIdType id, double error = -1.0);
469 int Pop(double& error);
470 double DeleteId(vtkIdType id);
471 void Reset();
472
473 vtkPriorityQueue* Queue;
474 vtkDoubleArray* VertexError;
475
476 VertexArray* V;
477 TriArray* T;
478
479 // Use to be static variables used by object
480 vtkPolyData* Mesh; // operate on this data structure
481 double Pt[3]; // least squares plane point
482 double Normal[3]; // least squares plane normal
483 double LoopArea; // the total area of all triangles in a loop
484 double CosAngle; // Cosine of dihedral angle
485 double Tolerance; // Intersection tolerance
486 double X[3]; // coordinates of current point
487 int NumCollapses; // Number of times edge collapses occur
488 int NumMerges; // Number of times vertex merges occur
489 int Split; // Controls whether and when vertex splitting occurs
490 int VertexDegree; // Maximum number of triangles that can use a vertex
491 vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
492 double TheSplitAngle; // Split angle
493 int SplitState; // State of the splitting process
494 double Error; // Maximum allowable surface error
495
496private:
497 vtkDecimatePro(const vtkDecimatePro&) = delete;
498 void operator=(const vtkDecimatePro&) = delete;
499};
500
501#endif
void InsertNextTriangle(LocalTri &t)
LocalTri & GetTriangle(vtkIdType i)
TriArray(const vtkIdType sz)
vtkIdType GetNumberOfTriangles()
VertexArray(const vtkIdType sz)
LocalVertex & GetVertex(vtkIdType i)
void InsertNextVertex(LocalVertex &v)
reduce the number of triangles in a mesh
double TargetReduction
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:140
a simple class to control print indentation
Definition: vtkIndent.h:113
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:195
a list of ids arranged in priority order
@ Normal
Definition: vtkX3D.h:51
@ type
Definition: vtkX3D.h:522
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_CELL_SIZE
Definition: vtkCell.h:129
int vtkIdType
Definition: vtkType.h:332
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165