VTK
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 =========================================================================*/
80 #ifndef vtkDecimatePro_h
81 #define vtkDecimatePro_h
82 
83 #include "vtkFiltersCoreModule.h" // For export macro
84 #include "vtkPolyDataAlgorithm.h"
85 
86 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
87 
88 class vtkDoubleArray;
89 class vtkPriorityQueue;
90 
91 class VTKFILTERSCORE_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
92 {
93 public:
95  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
96 
105  static vtkDecimatePro *New();
106 
108 
117  vtkSetClampMacro(TargetReduction,double,0.0,1.0);
118  vtkGetMacro(TargetReduction,double);
120 
122 
127  vtkSetMacro(PreserveTopology,int);
128  vtkGetMacro(PreserveTopology,int);
129  vtkBooleanMacro(PreserveTopology,int);
131 
133 
138  vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
139  vtkGetMacro(FeatureAngle,double);
141 
143 
149  vtkSetMacro(Splitting,int);
150  vtkGetMacro(Splitting,int);
151  vtkBooleanMacro(Splitting,int);
153 
155 
160  vtkSetClampMacro(SplitAngle,double,0.0,180.0);
161  vtkGetMacro(SplitAngle,double);
163 
165 
173  vtkSetMacro(PreSplitMesh,int);
174  vtkGetMacro(PreSplitMesh,int);
175  vtkBooleanMacro(PreSplitMesh,int);
177 
179 
185  vtkSetClampMacro(MaximumError,double,0.0,VTK_DOUBLE_MAX);
186  vtkGetMacro(MaximumError,double);
188 
190 
198  vtkSetMacro(AccumulateError,int);
199  vtkGetMacro(AccumulateError,int);
200  vtkBooleanMacro(AccumulateError,int);
202 
204 
209  vtkSetMacro(ErrorIsAbsolute,int);
210  vtkGetMacro(ErrorIsAbsolute,int);
212 
214 
217  vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
218  vtkGetMacro(AbsoluteError,double);
220 
222 
226  vtkSetMacro(BoundaryVertexDeletion,int);
227  vtkGetMacro(BoundaryVertexDeletion,int);
228  vtkBooleanMacro(BoundaryVertexDeletion,int);
230 
232 
238  vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
239  vtkGetMacro(Degree,int);
241 
243 
248  vtkSetClampMacro(InflectionPointRatio,double,1.001,VTK_DOUBLE_MAX);
249  vtkGetMacro(InflectionPointRatio,double);
251 
252 
260  vtkIdType GetNumberOfInflectionPoints();
261 
268  void GetInflectionPoints(double *inflectionPoints);
269 
277  double *GetInflectionPoints();
278 
280 
285  vtkSetMacro(OutputPointsPrecision,int);
286  vtkGetMacro(OutputPointsPrecision,int);
288 
289 protected:
290  vtkDecimatePro();
291  ~vtkDecimatePro() VTK_OVERRIDE;
292 
293  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
294 
295  double TargetReduction;
296  double FeatureAngle;
297  double MaximumError;
298  double AbsoluteError;
299  int ErrorIsAbsolute;
300  int AccumulateError;
301  double SplitAngle;
302  int Splitting;
303  int PreSplitMesh;
304  int BoundaryVertexDeletion;
305  int PreserveTopology;
306  int Degree;
307  double InflectionPointRatio;
308  vtkDoubleArray *InflectionPoints;
309  int OutputPointsPrecision;
310 
311  // to replace a static object
312  vtkIdList *Neighbors;
313  vtkPriorityQueue *EdgeLengths;
314 
315  void SplitMesh();
316  int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
317  vtkIdType *tris, vtkIdType fedges[2]);
318  vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
319  vtkIdType& pt2, vtkIdList *CollapseTris);
320  int IsValidSplit(int index);
321  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
322  vtkIdType& n2, vtkIdType *l2);
323  void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
324  vtkIdType *tris, int insert);
325  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
326  vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
327  void DistributeError(double error);
328 
329  //
330  // Special classes for manipulating data
331  //
332  // Special structures for building loops
334  {
335  public:
337  double x[3];
338  double FAngle;
339  };
341 
342  class LocalTri
343  {
344  public:
346  double area;
347  double n[3];
348  vtkIdType verts[3];
349  };
351 
352  class VertexArray;
353  friend class VertexArray;
354  class VertexArray { //;prevent man page generation
355  public:
357  {this->MaxId = -1; this->Array = new LocalVertex[sz];};
359  {
360  delete [] this->Array;
361  };
362  vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
364  {this->MaxId++; this->Array[this->MaxId] = v;};
365  LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
366  void Reset() {this->MaxId = -1;};
367 
368  LocalVertex *Array; // pointer to data
369  vtkIdType MaxId; // maximum index inserted thus far
370  };
371 
372  class TriArray;
373  friend class TriArray;
374  class TriArray { //;prevent man page generation
375  public:
376  TriArray(const vtkIdType sz)
377  {this->MaxId = -1; this->Array = new LocalTri[sz];};
379  {
380  delete [] this->Array;
381  };
382  vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
384  {this->MaxId++; this->Array[this->MaxId] = t;};
385  LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
386  void Reset() {this->MaxId = -1;};
387 
388  LocalTri *Array; // pointer to data
389  vtkIdType MaxId; // maximum index inserted thus far
390  };
391 
392 private:
393  void InitializeQueue(vtkIdType numPts);
394  void DeleteQueue();
395  void Insert(vtkIdType id, double error= -1.0);
396  int Pop(double &error);
397  double DeleteId(vtkIdType id);
398  void Reset();
399 
400  vtkPriorityQueue *Queue;
401  vtkDoubleArray *VertexError;
402 
403  VertexArray *V;
404  TriArray *T;
405 
406  // Use to be static variables used by object
407  vtkPolyData *Mesh; //operate on this data structure
408  double Pt[3]; //least squares plane point
409  double Normal[3]; //least squares plane normal
410  double LoopArea; //the total area of all triangles in a loop
411  double CosAngle; //Cosine of dihedral angle
412  double Tolerance; //Intersection tolerance
413  double X[3]; //coordinates of current point
414  int NumCollapses; //Number of times edge collapses occur
415  int NumMerges; //Number of times vertex merges occur
416  int Split; //Controls whether and when vertex splitting occurs
417  int VertexDegree; //Maximum number of triangles that can use a vertex
418  vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
419  double TheSplitAngle; //Split angle
420  int SplitState; //State of the splitting process
421  double Error; //Maximum allowable surface error
422 
423 private:
424  vtkDecimatePro(const vtkDecimatePro&) VTK_DELETE_FUNCTION;
425  void operator=(const vtkDecimatePro&) VTK_DELETE_FUNCTION;
426 };
427 
428 #endif
429 
430 
LocalTri & GetTriangle(vtkIdType i)
#define VTK_DOUBLE_MAX
Definition: vtkType.h:167
void InsertNextTriangle(LocalTri &t)
Store vtkAlgorithm input/output information.
LocalTri * LocalTriPtr
int vtkIdType
Definition: vtkType.h:345
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
#define VTK_CELL_SIZE
Definition: vtkCell.h:40
dynamic, self-adjusting array of double
a list of ids arranged in priority order
LocalVertex * LocalVertexPtr
static vtkPolyDataAlgorithm * New()
LocalVertex & GetVertex(vtkIdType i)
TriArray(const vtkIdType sz)
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:33
list of point or cell ids
Definition: vtkIdList.h:30
void InsertNextVertex(LocalVertex &v)
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
VertexArray(const vtkIdType sz)
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
reduce the number of triangles in a mesh
vtkIdType GetNumberOfTriangles()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.