Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# Graphics/vtkDecimatePro.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkDecimatePro.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00100 #ifndef __vtkDecimatePro_h
    00101 #define __vtkDecimatePro_h
    00102
    00103 #include "vtkPolyDataToPolyDataFilter.h"
    00104
    00105 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
    00106
    00107 class vtkFloatArray;
    00108 class vtkPriorityQueue;
    00109
    00110 class VTK_GRAPHICS_EXPORT vtkDecimatePro : public vtkPolyDataToPolyDataFilter
    00111 {
    00112 public:
    00113   vtkTypeRevisionMacro(vtkDecimatePro,vtkPolyDataToPolyDataFilter);
    00114   void PrintSelf(ostream& os, vtkIndent indent);
    00115
    00122   static vtkDecimatePro *New();
    00123
    00125
    00131   vtkSetClampMacro(TargetReduction,float,0.0,1.0);
    00132   vtkGetMacro(TargetReduction,float);
    00134
    00136
    00139   vtkSetMacro(PreserveTopology,int);
    00140   vtkGetMacro(PreserveTopology,int);
    00141   vtkBooleanMacro(PreserveTopology,int);
    00143
    00145
    00148   vtkSetClampMacro(FeatureAngle,float,0.0,180.0);
    00149   vtkGetMacro(FeatureAngle,float);
    00151
    00153
    00157   vtkSetMacro(Splitting,int);
    00158   vtkGetMacro(Splitting,int);
    00159   vtkBooleanMacro(Splitting,int);
    00161
    00163
    00166   vtkSetClampMacro(SplitAngle,float,0.0,180.0);
    00167   vtkGetMacro(SplitAngle,float);
    00169
    00171
    00177   vtkSetMacro(PreSplitMesh,int);
    00178   vtkGetMacro(PreSplitMesh,int);
    00179   vtkBooleanMacro(PreSplitMesh,int);
    00181
    00183
    00187   vtkSetClampMacro(MaximumError,float,0.0,VTK_LARGE_FLOAT);
    00188   vtkGetMacro(MaximumError,float);
    00190
    00192
    00199   vtkSetMacro(AccumulateError,int);
    00200   vtkGetMacro(AccumulateError,int);
    00201   vtkBooleanMacro(AccumulateError,int);
    00203
    00205
    00209   vtkSetMacro(ErrorIsAbsolute,int);
    00210   vtkGetMacro(ErrorIsAbsolute,int);
    00212
    00214
    00215   vtkSetClampMacro(AbsoluteError,float,0.0,VTK_LARGE_FLOAT);
    00216   vtkGetMacro(AbsoluteError,float);
    00218
    00220
    00222   vtkSetMacro(BoundaryVertexDeletion,int);
    00223   vtkGetMacro(BoundaryVertexDeletion,int);
    00224   vtkBooleanMacro(BoundaryVertexDeletion,int);
    00226
    00228
    00232   vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
    00233   vtkGetMacro(Degree,int);
    00235
    00237
    00240   vtkSetClampMacro(InflectionPointRatio,float,1.001,VTK_LARGE_FLOAT);
    00241   vtkGetMacro(InflectionPointRatio,float);
    00243
    00244
    00250   vtkIdType GetNumberOfInflectionPoints();
    00251
    00256   void GetInflectionPoints(float *inflectionPoints);
    00257
    00263   float *GetInflectionPoints();
    00264
    00265 protected:
    00266   vtkDecimatePro();
    00267   ~vtkDecimatePro();
    00268
    00269   void Execute();
    00270
    00271   float TargetReduction;
    00272   float FeatureAngle;
    00273   float MaximumError;
    00274   float AbsoluteError;
    00275   int ErrorIsAbsolute;
    00276   int AccumulateError;
    00277   float SplitAngle;
    00278   int Splitting;
    00279   int PreSplitMesh;
    00280   int BoundaryVertexDeletion;
    00281   int PreserveTopology;
    00282   int Degree;
    00283   float InflectionPointRatio;
    00284   vtkFloatArray *InflectionPoints;
    00285
    00286   // to replace a static object
    00287   vtkIdList *Neighbors;
    00288   vtkPriorityQueue *EdgeLengths;
    00289
    00290   void SplitMesh();
    00291   int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
    00292                      vtkIdType *tris, vtkIdType fedges[2]);
    00293   vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
    00294                       vtkIdType& pt2, vtkIdList *CollapseTris);
    00295   int IsValidSplit(int index);
    00296   void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
    00297                  vtkIdType& n2, vtkIdType *l2);
    00298   void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
    00299                    vtkIdType *tris, int insert);
    00300   int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
    00301                    vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
    00302   void DistributeError(float error);
    00303
    00304   //
    00305   // Special classes for manipulating data
    00306   //
    00307   //BTX - begin tcl exclude
    00308   //
    00309   // Special structures for building loops
    00310   class LocalVertex
    00311   {
    00312   public:
    00313     vtkIdType     id;
    00314     float   x[3];
    00315     float   FAngle;
    00316   };
    00317   typedef LocalVertex *LocalVertexPtr;
    00318
    00319   class LocalTri
    00320   {
    00321   public:
    00322     vtkIdType     id;
    00323     float   area;
    00324     float   n[3];
    00325     vtkIdType     verts[3];
    00326   };
    00327   typedef LocalTri *LocalTriPtr;
    00328
    00329   class VertexArray;
    00330   friend class VertexArray;
    00331   class VertexArray { //;prevent man page generation
    00332   public:
    00333     VertexArray(const vtkIdType sz)
    00334       {this->MaxId = -1; this->Array = new LocalVertex[sz];};
    00335     ~VertexArray()
    00336       {
    00337         if (this->Array)
    00338           {
    00339           delete [] this->Array;
    00340           }
    00341       };
    00342     vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
    00343     void InsertNextVertex(LocalVertex& v)
    00344       {this->MaxId++; this->Array[this->MaxId] = v;};
    00345     LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
    00346     void Reset() {this->MaxId = -1;};
    00347
    00348     LocalVertex *Array; // pointer to data
    00349     vtkIdType MaxId;             // maximum index inserted thus far
    00350   };
    00351
    00352   class TriArray;
    00353   friend class TriArray;
    00354   class TriArray { //;prevent man page generation
    00355   public:
    00356     TriArray(const vtkIdType sz)
    00357       {this->MaxId = -1; this->Array = new LocalTri[sz];};
    00358     ~TriArray()
    00359       {
    00360         if (this->Array)
    00361           {
    00362           delete [] this->Array;
    00363           }
    00364       };
    00365     vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
    00366     void InsertNextTriangle(LocalTri& t)
    00367       {this->MaxId++; this->Array[this->MaxId] = t;};
    00368     LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
    00369     void Reset() {this->MaxId = -1;};
    00370
    00371     LocalTri *Array;  // pointer to data
    00372     vtkIdType MaxId;           // maximum index inserted thus far
    00373   };
    00374   //ETX - end tcl exclude
    00375   //
    00376
    00377 private:
    00378   void InitializeQueue(vtkIdType numPts);
    00379   void DeleteQueue();
    00380   void Insert(vtkIdType id, float error= -1.0);
    00381   int Pop(float &error);
    00382   float DeleteId(vtkIdType id);
    00383   void Reset();
    00384
    00385   vtkPriorityQueue *Queue;
    00386   vtkFloatArray *VertexError;
    00387
    00388   VertexArray *V;
    00389   TriArray *T;
    00390
    00391   // Use to be static variables used by object
    00392   vtkPolyData *Mesh; //operate on this data structure
    00393   float Pt[3];      //least squares plane point
    00394   float Normal[3];  //least squares plane normal
    00395   float LoopArea;   //the total area of all triangles in a loop
    00396   float CosAngle;   //Cosine of dihedral angle
    00397   float Tolerance;  //Intersection tolerance
    00398   float X[3];       //coordinates of current point
    00399   int NumCollapses; //Number of times edge collapses occur
    00400   int NumMerges;    //Number of times vertex merges occur
    00401   int Split;        //Controls whether and when vertex splitting occurs
    00402   int VertexDegree; //Maximum number of triangles that can use a vertex
    00403   vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
    00404   float TheSplitAngle; //Split angle
    00405   int SplitState;   //State of the splitting process
    00406   float Error;      //Maximum allowable surface error
    00407
    00408 private:
    00409   vtkDecimatePro(const vtkDecimatePro&);  // Not implemented.
    00410   void operator=(const vtkDecimatePro&);  // Not implemented.
    00411 };
    00412
    00413 #endif
    00414
    00415