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=========================================================================*/
89#ifndef vtkDecimatePro_h
90#define vtkDecimatePro_h
91
92#include "vtkFiltersCoreModule.h" // For export macro
94
95#include "vtkCell.h" // Needed for VTK_CELL_SIZE
96
97class vtkDoubleArray;
99
100class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
101{
102public:
104 void PrintSelf(ostream& os, vtkIndent indent) override;
105
115
117
126 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
127 vtkGetMacro(TargetReduction, double);
129
131
136 vtkSetMacro(PreserveTopology, vtkTypeBool);
137 vtkGetMacro(PreserveTopology, vtkTypeBool);
138 vtkBooleanMacro(PreserveTopology, vtkTypeBool);
140
142
147 vtkSetClampMacro(FeatureAngle, double, 0.0, 180.0);
148 vtkGetMacro(FeatureAngle, double);
150
152
158 vtkSetMacro(Splitting, vtkTypeBool);
159 vtkGetMacro(Splitting, vtkTypeBool);
160 vtkBooleanMacro(Splitting, vtkTypeBool);
162
164
169 vtkSetClampMacro(SplitAngle, double, 0.0, 180.0);
170 vtkGetMacro(SplitAngle, double);
172
174
182 vtkSetMacro(PreSplitMesh, vtkTypeBool);
183 vtkGetMacro(PreSplitMesh, vtkTypeBool);
184 vtkBooleanMacro(PreSplitMesh, vtkTypeBool);
186
188
194 vtkSetClampMacro(MaximumError, double, 0.0, VTK_DOUBLE_MAX);
195 vtkGetMacro(MaximumError, double);
197
199
207 vtkSetMacro(AccumulateError, vtkTypeBool);
208 vtkGetMacro(AccumulateError, vtkTypeBool);
209 vtkBooleanMacro(AccumulateError, vtkTypeBool);
211
213
218 vtkSetMacro(ErrorIsAbsolute, int);
219 vtkGetMacro(ErrorIsAbsolute, int);
221
223
226 vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
227 vtkGetMacro(AbsoluteError, double);
229
231
235 vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
236 vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
237 vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
239
241
247 vtkSetClampMacro(Degree, int, 25, VTK_CELL_SIZE);
248 vtkGetMacro(Degree, int);
250
252
257 vtkSetClampMacro(InflectionPointRatio, double, 1.001, VTK_DOUBLE_MAX);
258 vtkGetMacro(InflectionPointRatio, double);
260
269
276 void GetInflectionPoints(double* inflectionPoints);
277
286
288
293 vtkSetMacro(OutputPointsPrecision, int);
294 vtkGetMacro(OutputPointsPrecision, int);
296
297protected:
299 ~vtkDecimatePro() override;
300
302
318
319 // to replace a static object
322
323 void SplitMesh();
324 int EvaluateVertex(vtkIdType ptId, vtkIdType numTris, vtkIdType* tris, vtkIdType fedges[2]);
326 int type, vtkIdType fedges[2], vtkIdType& pt1, vtkIdType& pt2, vtkIdList* CollapseTris);
328 void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType* l1, vtkIdType& n2, vtkIdType* l2);
329 void SplitVertex(vtkIdType ptId, int type, vtkIdType numTris, vtkIdType* tris, int insert);
330 int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2,
331 vtkIdList* CollapseTris);
332 void DistributeError(double error);
333
334 //
335 // Special classes for manipulating data
336 //
337 // Special structures for building loops
339 {
340 public:
342 double x[3];
343 double FAngle;
344 };
346
348 {
349 public:
351 double area;
352 double n[3];
353 vtkIdType verts[3];
354 };
356
357 class VertexArray;
358 friend class VertexArray;
360 { //;prevent man page generation
361 public:
363 {
364 this->MaxId = -1;
365 this->Array = new LocalVertex[sz];
366 }
367 ~VertexArray() { delete[] this->Array; }
368 vtkIdType GetNumberOfVertices() { return this->MaxId + 1; }
370 {
371 this->MaxId++;
372 this->Array[this->MaxId] = v;
373 }
374 LocalVertex& GetVertex(vtkIdType i) { return this->Array[i]; }
375 void Reset() { this->MaxId = -1; }
376
377 LocalVertex* Array; // pointer to data
378 vtkIdType MaxId; // maximum index inserted thus far
379 };
380
381 class TriArray;
382 friend class TriArray;
384 { //;prevent man page generation
385 public:
387 {
388 this->MaxId = -1;
389 this->Array = new LocalTri[sz];
390 }
391 ~TriArray() { delete[] this->Array; }
392 vtkIdType GetNumberOfTriangles() { return this->MaxId + 1; }
394 {
395 this->MaxId++;
396 this->Array[this->MaxId] = t;
397 }
398 LocalTri& GetTriangle(vtkIdType i) { return this->Array[i]; }
399 void Reset() { this->MaxId = -1; }
400
401 LocalTri* Array; // pointer to data
402 vtkIdType MaxId; // maximum index inserted thus far
403 };
404
405private:
406 void InitializeQueue(vtkIdType numPts);
407 void DeleteQueue();
408 void Insert(vtkIdType id, double error = -1.0);
409 int Pop(double& error);
410 double DeleteId(vtkIdType id);
411 void Reset();
412
413 vtkPriorityQueue* Queue;
414 vtkDoubleArray* VertexError;
415
416 VertexArray* V;
417 TriArray* T;
418
419 // Use to be static variables used by object
420 vtkPolyData* Mesh; // operate on this data structure
421 double Pt[3]; // least squares plane point
422 double Normal[3]; // least squares plane normal
423 double LoopArea; // the total area of all triangles in a loop
424 double CosAngle; // Cosine of dihedral angle
425 double Tolerance; // Intersection tolerance
426 double X[3]; // coordinates of current point
427 int NumCollapses; // Number of times edge collapses occur
428 int NumMerges; // Number of times vertex merges occur
429 int Split; // Controls whether and when vertex splitting occurs
430 int VertexDegree; // Maximum number of triangles that can use a vertex
431 vtkIdType NumberOfRemainingTris; // Number of triangles left in the mesh
432 double TheSplitAngle; // Split angle
433 int SplitState; // State of the splitting process
434 double Error; // Maximum allowable surface error
435
436private:
437 vtkDecimatePro(const vtkDecimatePro&) = delete;
438 void operator=(const vtkDecimatePro&) = delete;
439};
440
441#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:40
a simple class to control print indentation
Definition: vtkIndent.h:43
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:95
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:49
int vtkIdType
Definition: vtkType.h:332
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165