Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkDecimatePro.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDecimatePro.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00085 #ifndef __vtkDecimatePro_h
00086 #define __vtkDecimatePro_h
00087 
00088 #include "vtkPolyDataAlgorithm.h"
00089 
00090 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
00091 
00092 class vtkDoubleArray;
00093 class vtkPriorityQueue;
00094 
00095 class VTK_GRAPHICS_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
00096 {
00097 public:
00098   vtkTypeRevisionMacro(vtkDecimatePro,vtkPolyDataAlgorithm);
00099   void PrintSelf(ostream& os, vtkIndent indent);
00100 
00107   static vtkDecimatePro *New();
00108 
00110 
00118   vtkSetClampMacro(TargetReduction,double,0.0,1.0);
00119   vtkGetMacro(TargetReduction,double);
00121 
00123 
00126   vtkSetMacro(PreserveTopology,int);
00127   vtkGetMacro(PreserveTopology,int);
00128   vtkBooleanMacro(PreserveTopology,int);
00130 
00132 
00135   vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
00136   vtkGetMacro(FeatureAngle,double);
00138 
00140 
00144   vtkSetMacro(Splitting,int);
00145   vtkGetMacro(Splitting,int);
00146   vtkBooleanMacro(Splitting,int);
00148 
00150 
00153   vtkSetClampMacro(SplitAngle,double,0.0,180.0);
00154   vtkGetMacro(SplitAngle,double);
00156 
00158 
00164   vtkSetMacro(PreSplitMesh,int);
00165   vtkGetMacro(PreSplitMesh,int);
00166   vtkBooleanMacro(PreSplitMesh,int);
00168 
00170 
00174   vtkSetClampMacro(MaximumError,double,0.0,VTK_DOUBLE_MAX);
00175   vtkGetMacro(MaximumError,double);
00177 
00179 
00186   vtkSetMacro(AccumulateError,int);
00187   vtkGetMacro(AccumulateError,int);
00188   vtkBooleanMacro(AccumulateError,int);
00190 
00192 
00196   vtkSetMacro(ErrorIsAbsolute,int);
00197   vtkGetMacro(ErrorIsAbsolute,int);
00199 
00201 
00202   vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
00203   vtkGetMacro(AbsoluteError,double);
00205 
00207 
00209   vtkSetMacro(BoundaryVertexDeletion,int);
00210   vtkGetMacro(BoundaryVertexDeletion,int);
00211   vtkBooleanMacro(BoundaryVertexDeletion,int);
00213 
00215 
00219   vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00220   vtkGetMacro(Degree,int);
00222   
00224 
00227   vtkSetClampMacro(InflectionPointRatio,double,1.001,VTK_DOUBLE_MAX);
00228   vtkGetMacro(InflectionPointRatio,double);
00230 
00231 
00237   vtkIdType GetNumberOfInflectionPoints();
00238 
00243   void GetInflectionPoints(double *inflectionPoints);
00244 
00250   double *GetInflectionPoints();
00251 
00252 protected:
00253   vtkDecimatePro();
00254   ~vtkDecimatePro();
00255 
00256   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00257 
00258   double TargetReduction;
00259   double FeatureAngle;
00260   double MaximumError;
00261   double AbsoluteError;
00262   int ErrorIsAbsolute;
00263   int AccumulateError;
00264   double SplitAngle;
00265   int Splitting;
00266   int PreSplitMesh;
00267   int BoundaryVertexDeletion;
00268   int PreserveTopology;
00269   int Degree;
00270   double InflectionPointRatio;
00271   vtkDoubleArray *InflectionPoints;
00272 
00273   // to replace a static object
00274   vtkIdList *Neighbors;
00275   vtkPriorityQueue *EdgeLengths;
00276 
00277   void SplitMesh();
00278   int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
00279                      vtkIdType *tris, vtkIdType fedges[2]);
00280   vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
00281                       vtkIdType& pt2, vtkIdList *CollapseTris);
00282   int IsValidSplit(int index);
00283   void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
00284                  vtkIdType& n2, vtkIdType *l2);
00285   void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
00286                    vtkIdType *tris, int insert);
00287   int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
00288                    vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
00289   void DistributeError(double error);
00290 
00291   //
00292   // Special classes for manipulating data
00293   //
00294   //BTX - begin tcl exclude
00295   //
00296   // Special structures for building loops
00297   class LocalVertex
00298   {
00299   public:
00300     vtkIdType     id;
00301     double   x[3];
00302     double   FAngle;
00303   };
00304   typedef LocalVertex *LocalVertexPtr;
00305     
00306   class LocalTri
00307   {
00308   public:
00309     vtkIdType     id;
00310     double   area;
00311     double   n[3];
00312     vtkIdType     verts[3];
00313   };
00314   typedef LocalTri *LocalTriPtr;
00315 
00316   class VertexArray;
00317   friend class VertexArray;
00318   class VertexArray { //;prevent man page generation
00319   public:
00320     VertexArray(const vtkIdType sz) 
00321       {this->MaxId = -1; this->Array = new LocalVertex[sz];};
00322     ~VertexArray()
00323       {
00324         if (this->Array)
00325           {
00326           delete [] this->Array;
00327           }
00328       };
00329     vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00330     void InsertNextVertex(LocalVertex& v) 
00331       {this->MaxId++; this->Array[this->MaxId] = v;};
00332     LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00333     void Reset() {this->MaxId = -1;};
00334 
00335     LocalVertex *Array; // pointer to data
00336     vtkIdType MaxId;             // maximum index inserted thus far
00337   };
00338 
00339   class TriArray;
00340   friend class TriArray;
00341   class TriArray { //;prevent man page generation
00342   public:
00343     TriArray(const vtkIdType sz) 
00344       {this->MaxId = -1; this->Array = new LocalTri[sz];};
00345     ~TriArray()
00346       {
00347         if (this->Array)
00348           {
00349           delete [] this->Array;
00350           }
00351       };
00352     vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00353     void InsertNextTriangle(LocalTri& t) 
00354       {this->MaxId++; this->Array[this->MaxId] = t;};
00355     LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00356     void Reset() {this->MaxId = -1;};
00357 
00358     LocalTri *Array;  // pointer to data
00359     vtkIdType MaxId;           // maximum index inserted thus far
00360   };
00361   //ETX - end tcl exclude
00362   //
00363 
00364 private:
00365   void InitializeQueue(vtkIdType numPts);
00366   void DeleteQueue();
00367   void Insert(vtkIdType id, double error= -1.0);
00368   int Pop(double &error);
00369   double DeleteId(vtkIdType id);
00370   void Reset();
00371 
00372   vtkPriorityQueue *Queue;
00373   vtkDoubleArray *VertexError;
00374 
00375   VertexArray *V;
00376   TriArray *T;
00377 
00378   // Use to be static variables used by object
00379   vtkPolyData *Mesh; //operate on this data structure
00380   double Pt[3];      //least squares plane point
00381   double Normal[3];  //least squares plane normal
00382   double LoopArea;   //the total area of all triangles in a loop
00383   double CosAngle;   //Cosine of dihedral angle
00384   double Tolerance;  //Intersection tolerance
00385   double X[3];       //coordinates of current point
00386   int NumCollapses; //Number of times edge collapses occur
00387   int NumMerges;    //Number of times vertex merges occur
00388   int Split;        //Controls whether and when vertex splitting occurs
00389   int VertexDegree; //Maximum number of triangles that can use a vertex
00390   vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
00391   double TheSplitAngle; //Split angle
00392   int SplitState;   //State of the splitting process
00393   double Error;      //Maximum allowable surface error
00394 
00395 private:
00396   vtkDecimatePro(const vtkDecimatePro&);  // Not implemented.
00397   void operator=(const vtkDecimatePro&);  // Not implemented.
00398 };
00399 
00400 #endif
00401 
00402 

Generated on Mon Jan 21 23:07:24 2008 for VTK by  doxygen 1.4.3-20050530