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

Patented/vtkDecimate.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDecimate.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 
00015      THIS CLASS IS PATENTED UNDER UNITED STATES PATENT NUMBER 5,559,388
00016      "Method for Reducting the Complexity of a Polygonal Mesh".
00017      Application of this software for commercial purposes requires 
00018      a license grant from GE. Contact:
00019 
00020          Carl B. Horton
00021          Sr. Counsel, Intellectual Property
00022          3000 N. Grandview Blvd., W-710
00023          Waukesha, WI  53188
00024          Phone:  (262) 513-4022
00025          E-Mail: Carl.Horton@med.ge.com
00026 
00027      for more information.
00028 
00029 =========================================================================*/
00087 #ifndef __vtkDecimate_h
00088 #define __vtkDecimate_h
00089 
00090 #include "vtkPolyDataToPolyDataFilter.h"
00091 
00092 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
00093 
00094 #define VTK_NUMBER_STATISTICS 12
00095 
00096 class vtkIdList;
00097 
00098 class VTK_PATENTED_EXPORT vtkDecimate : public vtkPolyDataToPolyDataFilter
00099 {
00100 public:
00101   static vtkDecimate *New();
00102   vtkTypeRevisionMacro(vtkDecimate,vtkPolyDataToPolyDataFilter);
00103   void PrintSelf(ostream& os, vtkIndent indent);
00104 
00106 
00108   vtkSetClampMacro(InitialError,double,0.0,1.0);
00109   vtkGetMacro(InitialError,double);
00111 
00113 
00115   vtkSetClampMacro(ErrorIncrement,double,0.0,1.0);
00116   vtkGetMacro(ErrorIncrement,double);
00118 
00120 
00122   vtkSetClampMacro(MaximumError,double,0.0,1.0);
00123   vtkGetMacro(MaximumError,double);
00125 
00127 
00130   vtkSetClampMacro(TargetReduction,double,0.0,1.0);
00131   vtkGetMacro(TargetReduction,double);
00133 
00135 
00137   vtkSetClampMacro(MaximumIterations,int,0,VTK_LARGE_INTEGER);
00138   vtkGetMacro(MaximumIterations,int);
00140 
00142 
00144   vtkSetClampMacro(MaximumSubIterations,int,1,VTK_LARGE_INTEGER);
00145   vtkGetMacro(MaximumSubIterations,int);
00147   
00149 
00150   vtkSetClampMacro(InitialFeatureAngle,double,0.0,180.0);
00151   vtkGetMacro(InitialFeatureAngle,double);
00153 
00155 
00157   vtkSetClampMacro(FeatureAngleIncrement,double,0.0,180.0);
00158   vtkGetMacro(FeatureAngleIncrement,double);
00160 
00162 
00163   vtkSetClampMacro(MaximumFeatureAngle,double,0.0,180.0);
00164   vtkGetMacro(MaximumFeatureAngle,double);
00166 
00168 
00169   vtkSetMacro(GenerateErrorScalars,int);
00170   vtkGetMacro(GenerateErrorScalars,int);
00171   vtkBooleanMacro(GenerateErrorScalars,int);
00173 
00175 
00176   vtkSetMacro(PreserveEdges,int);
00177   vtkGetMacro(PreserveEdges,int);
00178   vtkBooleanMacro(PreserveEdges,int);
00180 
00182 
00183   vtkSetMacro(BoundaryVertexDeletion,int);
00184   vtkGetMacro(BoundaryVertexDeletion,int);
00185   vtkBooleanMacro(BoundaryVertexDeletion,int);
00187 
00189 
00190   vtkSetClampMacro(AspectRatio,double,1.0,1000.0);
00191   vtkGetMacro(AspectRatio,double);
00193 
00195 
00197   vtkSetMacro(PreserveTopology,int);
00198   vtkGetMacro(PreserveTopology,int);
00199   vtkBooleanMacro(PreserveTopology,int);
00201 
00203 
00207   vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00208   vtkGetMacro(Degree,int);
00210   
00212 
00215   vtkSetClampMacro(MaximumNumberOfSquawks,int,0,VTK_LARGE_INTEGER);
00216   vtkGetMacro(MaximumNumberOfSquawks,int);
00218   
00219 protected:
00220 
00221   //
00222   // Special classes for manipulating data
00223   //
00224   //BTX - begin tcl exclude
00225   //
00226   // Special structures for building loops
00227   class LocalVertex
00228   {
00229   public:
00230     vtkIdType     id;
00231     double   x[3];
00232     double   FAngle;
00233     int     deRefs; //monitor memory requirements; new only when necessary
00234     int     newRefs;
00235   };
00236   typedef LocalVertex *LocalVertexPtr;
00237     
00238   class LocalTri
00239   {
00240   public:
00241     vtkIdType     id;
00242     double   area;
00243     double   n[3];
00244     vtkIdType     verts[3];
00245   };
00246   typedef LocalTri *LocalTriPtr;
00247 
00248   class VertexArray;
00249   friend class VertexArray;
00250   class VertexArray { //;prevent man page generation
00251   public:
00252     VertexArray(const vtkIdType sz) 
00253       {this->MaxId = -1; this->Array = new LocalVertex[sz];};
00254     ~VertexArray() {if (this->Array) {delete [] this->Array;}};
00255     vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00256     void InsertNextVertex(LocalVertex& v) 
00257       {this->MaxId++; this->Array[this->MaxId] = v;};
00258     LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00259     void Reset() {this->MaxId = -1;};
00260 
00261     LocalVertex *Array;  // pointer to data
00262     vtkIdType MaxId;             // maximum index inserted thus far
00263   };
00264 
00265   class TriArray;
00266   friend class TriArray;
00267   class TriArray { //;prevent man page generation
00268   public:
00269     TriArray(const vtkIdType sz) 
00270       {this->MaxId = -1; this->Array = new LocalTri[sz];};
00271     ~TriArray() {if (this->Array) {delete [] this->Array;}};
00272     vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00273     void InsertNextTriangle(LocalTri& t) 
00274       {this->MaxId++; this->Array[this->MaxId] = t;};
00275     LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00276     void Reset() {this->MaxId = -1;};
00277 
00278     LocalTri *Array;  // pointer to data
00279     vtkIdType MaxId;            // maximum index inserted thus far
00280   };
00281   //ETX - end tcl exclude
00282   //
00283 
00284   vtkDecimate();
00285   ~vtkDecimate();
00286 
00287   void Execute();
00288 
00289   double InitialFeatureAngle; // dihedral angle constraint
00290   double FeatureAngleIncrement;
00291   double MaximumFeatureAngle;
00292   int PreserveEdges; // do/don't worry about feature edges
00293   int BoundaryVertexDeletion;  
00294   double InitialError; // decimation error in fraction of bounding box
00295   double ErrorIncrement; // each iteration will bump error this amount
00296   double MaximumError; // maximum error
00297   double TargetReduction; //target reduction of mesh (fraction)
00298   int MaximumIterations; // maximum number of passes over data
00299   int MaximumSubIterations; // maximum non-incrementing passes
00300   double AspectRatio; // control triangle shape during triangulation
00301   int Degree; // maximum number of triangles incident on vertex
00302   int Stats[VTK_NUMBER_STATISTICS]; // keep track of interesting statistics
00303   int GenerateErrorScalars; // turn on/off vertex error scalar generation
00304   int MaximumNumberOfSquawks; //control number of error messages
00305   int PreserveTopology; //control whether mesh topology is preserved
00306   vtkIdList *Neighbors; // to replace static
00307   VertexArray *V; //to replace static
00308   TriArray *T; //to replace static
00309   
00310   void CreateOutput(vtkIdType numPts, vtkIdType numTris,
00311                     vtkIdType numEliminated, vtkPointData *pd,
00312                     vtkPoints *inPts);
00313   int BuildLoop(vtkIdType ptId, unsigned short int nTris, vtkIdType* tris);
00314   void EvaluateLoop(int& vtype, vtkIdType& numFEdges,
00315                     LocalVertexPtr fedges[]);
00316   int CanSplitLoop(LocalVertexPtr fedges[2], vtkIdType numVerts, 
00317                    LocalVertexPtr verts[], vtkIdType& n1,
00318                    LocalVertexPtr l1[], vtkIdType& n2,
00319                    LocalVertexPtr l2[], double& ar);
00320   void SplitLoop(LocalVertexPtr fedges[2], vtkIdType numVerts, 
00321                  LocalVertexPtr *verts, vtkIdType& n1,
00322                  LocalVertexPtr *l1, vtkIdType& n2, LocalVertexPtr *l2);
00323   void Triangulate(vtkIdType numVerts, LocalVertexPtr verts[]);
00324   int CheckError();
00325 private:
00326   vtkDecimate(const vtkDecimate&);  // Not implemented.
00327   void operator=(const vtkDecimate&);  // Not implemented.
00328 };
00329 
00330 #endif
00331 
00332