VTK  9.2.6
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=========================================================================*/
83#ifndef vtkDecimatePro_h
84#define vtkDecimatePro_h
85
86#include "vtkFiltersCoreModule.h" // For export macro
88
89#include "vtkCell.h" // Needed for VTK_CELL_SIZE
90
91class vtkDoubleArray;
93
94class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
95{
96public:
98 void PrintSelf(ostream& os, vtkIndent indent) override;
99
109
111
120 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
121 vtkGetMacro(TargetReduction, double);
123
125
130 vtkSetMacro(PreserveTopology, vtkTypeBool);
131 vtkGetMacro(PreserveTopology, vtkTypeBool);
132 vtkBooleanMacro(PreserveTopology, vtkTypeBool);
134
136
141 vtkSetClampMacro(FeatureAngle, double, 0.0, 180.0);
142 vtkGetMacro(FeatureAngle, double);
144
146
152 vtkSetMacro(Splitting, vtkTypeBool);
153 vtkGetMacro(Splitting, vtkTypeBool);
154 vtkBooleanMacro(Splitting, vtkTypeBool);
156
158
163 vtkSetClampMacro(SplitAngle, double, 0.0, 180.0);
164 vtkGetMacro(SplitAngle, double);
166
168
176 vtkSetMacro(PreSplitMesh, vtkTypeBool);
177 vtkGetMacro(PreSplitMesh, vtkTypeBool);
178 vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
180
182
188 vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
189 vtkGetMacro(MaximumError, double);
191
193
201 vtkSetMacro(AccumulateError, vtkTypeBool);
202 vtkGetMacro(AccumulateError, vtkTypeBool);
203 vtkBooleanMacro(AccumulateError, vtkTypeBool);
205
207
212 vtkSetMacro(ErrorIsAbsolute, int);
213 vtkGetMacro(ErrorIsAbsolute, int);
215
217
220 vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
221 vtkGetMacro(AbsoluteError, double);
223
225
229 vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
230 vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
231 vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
233
235
241 vtkSetClampMacro(Degree, int, 25, VTK_CELL_SIZE);
242 vtkGetMacro(Degree, int);
244
246
251 vtkSetClampMacro(InflectionPointRatio, double, 1.001, VTK_DOUBLE_MAX);
252 vtkGetMacro(InflectionPointRatio, double);
254
263
270 void GetInflectionPoints(double* inflectionPoints);
271
280
282
287 vtkSetMacro(OutputPointsPrecision, int);
288 vtkGetMacro(OutputPointsPrecision, int);
290
291protected:
293 ~vtkDecimatePro() override;
294
296
312
313 // to replace a static object
316
317 void SplitMesh();
318 int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
320 int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
321 int IsValidSplit(int index);
322 void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
323 void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
324 int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
325 vtkIdList* CollapseTris);
326 void DistributeError(double error);
327
328 //
329 // Special classes for manipulating data
330 //
331 // Special structures for building loops
333 {
334 public:
336 double x[3];
337 double FAngle;
338 };
340
342 {
343 public:
345 double area;
346 double n[3];
347 vtkIdType verts[3];
348 };
350
351 class VertexArray;
352 friend class VertexArray;
354 { //;prevent man page generation
355 public:
357 {
358 this->MaxId = -1;
359 this->Array = new LocalVertex[sz];
360 }
361 ~VertexArray() { delete[] this->Array; }
362 vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
364 {
365 this->MaxId++;
366 this->Array[this->MaxId] = v;
367 }
368 LocalVertex& GetVertex(vtkIdType i) { return this->Array[i]; }
369 void Reset() { this->MaxId = -1; }
370
371 LocalVertex* Array; // pointer to data
372 vtkIdType MaxId; // maximum index inserted thus far
373 };
374
375 class TriArray;
376 friend class TriArray;
378 { //;prevent man page generation
379 public:
381 {
382 this->MaxId = -1;
383 this->Array = new LocalTri[sz];
384 }
385 ~TriArray() { delete[] this->Array; }
386 vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
388 {
389 this->MaxId++;
390 this->Array[this->MaxId] = t;
391 }
392 LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
393 void Reset() { this->MaxId = -1; }
394
395 LocalTri* Array; // pointer to data
396 vtkIdType MaxId; // maximum index inserted thus far
397 };
398
399private:
400 void InitializeQueue(vtkIdType numPts);
401 void DeleteQueue();
402 void Insert(vtkIdType id, double error = -1.0);
403 int Pop(double& error);
404 double DeleteId(vtkIdType id);
405 void Reset();
406
407 vtkPriorityQueue* Queue;
408 vtkDoubleArray* VertexError;
409
410 VertexArray* V;
411 TriArray* T;
412
413 // Use to be static variables used by object
414 vtkPolyData* Mesh; // operate on this data structure
415 double Pt[3]; // least squares plane point
416 double Normal[3]; // least squares plane normal
417 double LoopArea; // the total area of all triangles in a loop
418 double CosAngle; // Cosine of dihedral angle
419 double Tolerance; // Intersection tolerance
420 double X[3]; // coordinates of current point
421 int NumCollapses; // Number of times edge collapses occur
422 int NumMerges; // Number of times vertex merges occur
423 int Split; // Controls whether and when vertex splitting occurs
424 int VertexDegree; // Maximum number of triangles that can use a vertex
425 vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
426 double TheSplitAngle; // Split angle
427 int SplitState; // State of the splitting process
428 double Error; // Maximum allowable surface error
429
430private:
431 vtkDecimatePro(const vtkDecimatePro&) = delete;
432 void operator=(const vtkDecimatePro&) = delete;
433};
434
435#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:34
a simple class to control print indentation
Definition: vtkIndent.h:40
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:91
a list of ids arranged in priority order
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_CELL_SIZE
Definition: vtkCell.h:43
int vtkIdType
Definition: vtkType.h:332
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165