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 =========================================================================*/
85 #ifndef vtkDecimatePro_h
86 #define vtkDecimatePro_h
87 
88 #include "vtkFiltersCoreModule.h" // For export macro
89 #include "vtkPolyDataAlgorithm.h"
90 
91 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
92 
93 class vtkDoubleArray;
94 class vtkPriorityQueue;
95 
97 {
98 public:
100  void PrintSelf(ostream& os, vtkIndent indent);
101 
108  static vtkDecimatePro *New();
109 
111 
119  vtkSetClampMacro(TargetReduction,double,0.0,1.0);
120  vtkGetMacro(TargetReduction,double);
122 
124 
127  vtkSetMacro(PreserveTopology,int);
128  vtkGetMacro(PreserveTopology,int);
129  vtkBooleanMacro(PreserveTopology,int);
131 
133 
136  vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
137  vtkGetMacro(FeatureAngle,double);
139 
141 
145  vtkSetMacro(Splitting,int);
146  vtkGetMacro(Splitting,int);
147  vtkBooleanMacro(Splitting,int);
149 
151 
154  vtkSetClampMacro(SplitAngle,double,0.0,180.0);
155  vtkGetMacro(SplitAngle,double);
157 
159 
165  vtkSetMacro(PreSplitMesh,int);
166  vtkGetMacro(PreSplitMesh,int);
167  vtkBooleanMacro(PreSplitMesh,int);
169 
171 
175  vtkSetClampMacro(MaximumError,double,0.0,VTK_DOUBLE_MAX);
176  vtkGetMacro(MaximumError,double);
178 
180 
187  vtkSetMacro(AccumulateError,int);
188  vtkGetMacro(AccumulateError,int);
189  vtkBooleanMacro(AccumulateError,int);
191 
193 
197  vtkSetMacro(ErrorIsAbsolute,int);
198  vtkGetMacro(ErrorIsAbsolute,int);
200 
202 
203  vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
204  vtkGetMacro(AbsoluteError,double);
206 
208 
210  vtkSetMacro(BoundaryVertexDeletion,int);
211  vtkGetMacro(BoundaryVertexDeletion,int);
212  vtkBooleanMacro(BoundaryVertexDeletion,int);
214 
216 
221  vtkGetMacro(Degree,int);
223 
225 
228  vtkSetClampMacro(InflectionPointRatio,double,1.001,VTK_DOUBLE_MAX);
229  vtkGetMacro(InflectionPointRatio,double);
231 
232 
239 
244  void GetInflectionPoints(double *inflectionPoints);
245 
252 
254 
257  vtkSetMacro(OutputPointsPrecision,int);
258  vtkGetMacro(OutputPointsPrecision,int);
260 
261 protected:
264 
266 
268  double FeatureAngle;
269  double MaximumError;
273  double SplitAngle;
278  int Degree;
282 
283  // to replace a static object
286 
287  void SplitMesh();
288  int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
289  vtkIdType *tris, vtkIdType fedges[2]);
291  vtkIdType& pt2, vtkIdList *CollapseTris);
292  int IsValidSplit(int index);
293  void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
294  vtkIdType& n2, vtkIdType *l2);
295  void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
296  vtkIdType *tris, int insert);
297  int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
298  vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
299  void DistributeError(double error);
300 
301  //
302  // Special classes for manipulating data
303  //
304  //BTX - begin tcl exclude
305  //
306  // Special structures for building loops
308  {
309  public:
311  double x[3];
312  double FAngle;
313  };
315 
316  class LocalTri
317  {
318  public:
320  double area;
321  double n[3];
322  vtkIdType verts[3];
323  };
325 
326  class VertexArray;
327  friend class VertexArray;
328  class VertexArray { //;prevent man page generation
329  public:
331  {this->MaxId = -1; this->Array = new LocalVertex[sz];};
333  {
334  delete [] this->Array;
335  };
336  vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
338  {this->MaxId++; this->Array[this->MaxId] = v;};
339  LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
340  void Reset() {this->MaxId = -1;};
341 
342  LocalVertex *Array; // pointer to data
343  vtkIdType MaxId; // maximum index inserted thus far
344  };
345 
346  class TriArray;
347  friend class TriArray;
348  class TriArray { //;prevent man page generation
349  public:
350  TriArray(const vtkIdType sz)
351  {this->MaxId = -1; this->Array = new LocalTri[sz];};
353  {
354  delete [] this->Array;
355  };
356  vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
358  {this->MaxId++; this->Array[this->MaxId] = t;};
359  LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
360  void Reset() {this->MaxId = -1;};
361 
362  LocalTri *Array; // pointer to data
363  vtkIdType MaxId; // maximum index inserted thus far
364  };
365  //ETX - end tcl exclude
366  //
367 
368 private:
369  void InitializeQueue(vtkIdType numPts);
370  void DeleteQueue();
371  void Insert(vtkIdType id, double error= -1.0);
372  int Pop(double &error);
373  double DeleteId(vtkIdType id);
374  void Reset();
375 
376  vtkPriorityQueue *Queue;
377  vtkDoubleArray *VertexError;
378 
379  VertexArray *V;
380  TriArray *T;
381 
382  // Use to be static variables used by object
383  vtkPolyData *Mesh; //operate on this data structure
384  double Pt[3]; //least squares plane point
385  double Normal[3]; //least squares plane normal
386  double LoopArea; //the total area of all triangles in a loop
387  double CosAngle; //Cosine of dihedral angle
388  double Tolerance; //Intersection tolerance
389  double X[3]; //coordinates of current point
390  int NumCollapses; //Number of times edge collapses occur
391  int NumMerges; //Number of times vertex merges occur
392  int Split; //Controls whether and when vertex splitting occurs
393  int VertexDegree; //Maximum number of triangles that can use a vertex
394  vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
395  double TheSplitAngle; //Split angle
396  int SplitState; //State of the splitting process
397  double Error; //Maximum allowable surface error
398 
399 private:
400  vtkDecimatePro(const vtkDecimatePro&); // Not implemented.
401  void operator=(const vtkDecimatePro&); // Not implemented.
402 };
403 
404 #endif
405 
406 
vtkDecimatePro::TriArray::~TriArray
~TriArray()
Definition: vtkDecimatePro.h:352
vtkDecimatePro::TriArray::InsertNextTriangle
void InsertNextTriangle(LocalTri &t)
Definition: vtkDecimatePro.h:357
vtkDecimatePro::LocalTriPtr
LocalTri * LocalTriPtr
Definition: vtkDecimatePro.h:324
vtkDecimatePro::AccumulateError
int AccumulateError
Definition: vtkDecimatePro.h:272
vtkDecimatePro::TriArray::Array
LocalTri * Array
Definition: vtkDecimatePro.h:360
vtkDecimatePro::TriArray::GetNumberOfTriangles
vtkIdType GetNumberOfTriangles()
Definition: vtkDecimatePro.h:356
vtkDecimatePro::GetInflectionPoints
double * GetInflectionPoints()
vtkDecimatePro::OutputPointsPrecision
int OutputPointsPrecision
Definition: vtkDecimatePro.h:281
vtkDecimatePro::DistributeError
void DistributeError(double error)
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkDecimatePro::VertexArray::~VertexArray
~VertexArray()
Definition: vtkDecimatePro.h:332
vtkDecimatePro::SplitAngle
double SplitAngle
Definition: vtkDecimatePro.h:273
vtkDecimatePro::TriArray
Definition: vtkDecimatePro.h:348
vtkDecimatePro::VertexArray::MaxId
vtkIdType MaxId
Definition: vtkDecimatePro.h:343
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkDecimatePro::LocalVertexPtr
LocalVertex * LocalVertexPtr
Definition: vtkDecimatePro.h:314
vtkX3D::Normal
@ Normal
Definition: vtkX3D.h:45
vtkDecimatePro::SplitLoop
void SplitLoop(vtkIdType fedges[2], vtkIdType &n1, vtkIdType *l1, vtkIdType &n2, vtkIdType *l2)
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkgl::n
GLclampd n
Definition: vtkgl.h:14370
vtkPriorityQueue
a list of ids arranged in priority order
Definition: vtkPriorityQueue.h:46
vtkgl::v
const GLdouble * v
Definition: vtkgl.h:11595
vtkDecimatePro::TriArray::GetTriangle
LocalTri & GetTriangle(vtkIdType i)
Definition: vtkDecimatePro.h:359
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkDecimatePro::Splitting
int Splitting
Definition: vtkDecimatePro.h:274
vtkDecimatePro::PreserveTopology
int PreserveTopology
Definition: vtkDecimatePro.h:277
vtkDecimatePro::Degree
int Degree
Definition: vtkDecimatePro.h:278
vtkCell.h
vtkDecimatePro::SplitVertex
void SplitVertex(vtkIdType ptId, int type, unsigned short int numTris, vtkIdType *tris, int insert)
vtkFiltersCoreModule.h
vtkDecimatePro::CollapseEdge
int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId, vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris)
vtkPolyDataAlgorithm.h
vtkDecimatePro::vtkDecimatePro
vtkDecimatePro()
vtkDecimatePro
reduce the number of triangles in a mesh
Definition: vtkDecimatePro.h:97
vtkSetClampMacro
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:143
vtkDecimatePro::MaximumError
double MaximumError
Definition: vtkDecimatePro.h:269
vtkDecimatePro::New
static vtkDecimatePro * New()
VTK_CELL_SIZE
#define VTK_CELL_SIZE
Definition: vtkCell.h:45
vtkDecimatePro::LocalTri::id
vtkIdType id
Definition: vtkDecimatePro.h:319
vtkDecimatePro::AbsoluteError
double AbsoluteError
Definition: vtkDecimatePro.h:270
vtkDecimatePro::~vtkDecimatePro
~vtkDecimatePro()
vtkDecimatePro::VertexArray::Reset
void Reset()
Definition: vtkDecimatePro.h:340
vtkDecimatePro::EdgeLengths
vtkPriorityQueue * EdgeLengths
Definition: vtkDecimatePro.h:285
vtkDecimatePro::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
vtkDecimatePro::VertexArray
Definition: vtkDecimatePro.h:328
VTKFILTERSCORE_EXPORT
#define VTKFILTERSCORE_EXPORT
Definition: vtkFiltersCoreModule.h:15
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkDecimatePro::Neighbors
vtkIdList * Neighbors
Definition: vtkDecimatePro.h:284
vtkDecimatePro::PreSplitMesh
int PreSplitMesh
Definition: vtkDecimatePro.h:275
vtkDecimatePro::VertexArray::GetVertex
LocalVertex & GetVertex(vtkIdType i)
Definition: vtkDecimatePro.h:339
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkDecimatePro::LocalTri::area
double area
Definition: vtkDecimatePro.h:320
vtkDecimatePro::VertexArray::InsertNextVertex
void InsertNextVertex(LocalVertex &v)
Definition: vtkDecimatePro.h:337
vtkDecimatePro::TargetReduction
double TargetReduction
Definition: vtkDecimatePro.h:267
vtkDecimatePro::InflectionPointRatio
double InflectionPointRatio
Definition: vtkDecimatePro.h:279
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkDecimatePro::VertexArray::Array
LocalVertex * Array
Definition: vtkDecimatePro.h:340
vtkDecimatePro::TriArray::TriArray
TriArray(const vtkIdType sz)
Definition: vtkDecimatePro.h:350
vtkDecimatePro::BoundaryVertexDeletion
int BoundaryVertexDeletion
Definition: vtkDecimatePro.h:276
vtkDecimatePro::InflectionPoints
vtkDoubleArray * InflectionPoints
Definition: vtkDecimatePro.h:280
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkDecimatePro::GetNumberOfInflectionPoints
vtkIdType GetNumberOfInflectionPoints()
vtkDecimatePro::LocalVertex
Definition: vtkDecimatePro.h:308
vtkgl::index
GLuint index
Definition: vtkgl.h:11983
vtkDecimatePro::ErrorIsAbsolute
int ErrorIsAbsolute
Definition: vtkDecimatePro.h:271
vtkgl::t
GLdouble GLdouble t
Definition: vtkgl.h:11602
vtkDecimatePro::FindSplit
vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType &pt1, vtkIdType &pt2, vtkIdList *CollapseTris)
vtkDecimatePro::LocalVertex::FAngle
double FAngle
Definition: vtkDecimatePro.h:312
vtkDecimatePro::FeatureAngle
double FeatureAngle
Definition: vtkDecimatePro.h:268
vtkDecimatePro::TriArray::MaxId
vtkIdType MaxId
Definition: vtkDecimatePro.h:363
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkDecimatePro::VertexArray::VertexArray
VertexArray(const vtkIdType sz)
Definition: vtkDecimatePro.h:330
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:49
vtkDecimatePro::VertexArray::GetNumberOfVertices
vtkIdType GetNumberOfVertices()
Definition: vtkDecimatePro.h:336
vtkDecimatePro::TriArray::Reset
void Reset()
Definition: vtkDecimatePro.h:360
vtkDecimatePro::EvaluateVertex
int EvaluateVertex(vtkIdType ptId, unsigned short int numTris, vtkIdType *tris, vtkIdType fedges[2])
vtkDecimatePro::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkgl::type
GLuint GLuint GLsizei GLenum type
Definition: vtkgl.h:11315
vtkDecimatePro::LocalVertex::id
vtkIdType id
Definition: vtkDecimatePro.h:310
vtkDecimatePro::GetInflectionPoints
void GetInflectionPoints(double *inflectionPoints)
vtkDecimatePro::IsValidSplit
int IsValidSplit(int index)
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:142
vtkDecimatePro::SplitMesh
void SplitMesh()
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:44
vtkDecimatePro::LocalTri
Definition: vtkDecimatePro.h:317