Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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   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      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      THIS CLASS IS PATENTED UNDER UNITED STATES PATENT NUMBER 4,710,876
00030      "System and Method for the Display of Surface Structures Contained
00031      Within the Interior Region of a Solid Body".
00032      Application of this software for commercial purposes requires 
00033      a license grant from GE. Contact:
00034 
00035          Carl B. Horton
00036          Sr. Counsel, Intellectual Property
00037          3000 N. Grandview Blvd., W-710
00038          Waukesha, WI  53188
00039          Phone:  (262) 513-4022
00040          E-Mail: Carl.Horton@med.ge.com
00041 
00042      for more information.
00043 
00044 =========================================================================*/
00118 #ifndef __vtkDecimate_h
00119 #define __vtkDecimate_h
00120 
00121 #include "vtkPolyDataToPolyDataFilter.h"
00122 
00123 #include "vtkCell.h" // Needed for VTK_CELL_SIZE
00124 
00125 #define VTK_NUMBER_STATISTICS 12
00126 
00127 class vtkIdList;
00128 
00129 class VTK_PATENTED_EXPORT vtkDecimate : public vtkPolyDataToPolyDataFilter
00130 {
00131 public:
00132   static vtkDecimate *New();
00133   vtkTypeRevisionMacro(vtkDecimate,vtkPolyDataToPolyDataFilter);
00134   void PrintSelf(ostream& os, vtkIndent indent);
00135 
00137 
00139   vtkSetClampMacro(InitialError,float,0.0,1.0);
00140   vtkGetMacro(InitialError,float);
00142 
00144 
00146   vtkSetClampMacro(ErrorIncrement,float,0.0,1.0);
00147   vtkGetMacro(ErrorIncrement,float);
00149 
00151 
00153   vtkSetClampMacro(MaximumError,float,0.0,1.0);
00154   vtkGetMacro(MaximumError,float);
00156 
00158 
00161   vtkSetClampMacro(TargetReduction,float,0.0,1.0);
00162   vtkGetMacro(TargetReduction,float);
00164 
00166 
00168   vtkSetClampMacro(MaximumIterations,int,0,VTK_LARGE_INTEGER);
00169   vtkGetMacro(MaximumIterations,int);
00171 
00173 
00175   vtkSetClampMacro(MaximumSubIterations,int,1,VTK_LARGE_INTEGER);
00176   vtkGetMacro(MaximumSubIterations,int);
00178   
00180 
00181   vtkSetClampMacro(InitialFeatureAngle,float,0.0,180.0);
00182   vtkGetMacro(InitialFeatureAngle,float);
00184 
00186 
00188   vtkSetClampMacro(FeatureAngleIncrement,float,0.0,180.0);
00189   vtkGetMacro(FeatureAngleIncrement,float);
00191 
00193 
00194   vtkSetClampMacro(MaximumFeatureAngle,float,0.0,180.0);
00195   vtkGetMacro(MaximumFeatureAngle,float);
00197 
00199 
00200   vtkSetMacro(GenerateErrorScalars,int);
00201   vtkGetMacro(GenerateErrorScalars,int);
00202   vtkBooleanMacro(GenerateErrorScalars,int);
00204 
00206 
00207   vtkSetMacro(PreserveEdges,int);
00208   vtkGetMacro(PreserveEdges,int);
00209   vtkBooleanMacro(PreserveEdges,int);
00211 
00213 
00214   vtkSetMacro(BoundaryVertexDeletion,int);
00215   vtkGetMacro(BoundaryVertexDeletion,int);
00216   vtkBooleanMacro(BoundaryVertexDeletion,int);
00218 
00220 
00221   vtkSetClampMacro(AspectRatio,float,1.0,1000.0);
00222   vtkGetMacro(AspectRatio,float);
00224 
00226 
00228   vtkSetMacro(PreserveTopology,int);
00229   vtkGetMacro(PreserveTopology,int);
00230   vtkBooleanMacro(PreserveTopology,int);
00232 
00234 
00238   vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00239   vtkGetMacro(Degree,int);
00241   
00243 
00246   vtkSetClampMacro(MaximumNumberOfSquawks,int,0,VTK_LARGE_INTEGER);
00247   vtkGetMacro(MaximumNumberOfSquawks,int);
00249   
00250 protected:
00251 
00252   //
00253   // Special classes for manipulating data
00254   //
00255   //BTX - begin tcl exclude
00256   //
00257   // Special structures for building loops
00258   class LocalVertex
00259   {
00260   public:
00261     vtkIdType     id;
00262     float   x[3];
00263     float   FAngle;
00264     int     deRefs; //monitor memory requirements; new only when necessary
00265     int     newRefs;
00266   };
00267   typedef LocalVertex *LocalVertexPtr;
00268     
00269   class LocalTri
00270   {
00271   public:
00272     vtkIdType     id;
00273     float   area;
00274     float   n[3];
00275     vtkIdType     verts[3];
00276   };
00277   typedef LocalTri *LocalTriPtr;
00278 
00279   class VertexArray;
00280   friend class VertexArray;
00281   class VertexArray { //;prevent man page generation
00282   public:
00283     VertexArray(const vtkIdType sz) 
00284       {this->MaxId = -1; this->Array = new LocalVertex[sz];};
00285     ~VertexArray() {if (this->Array) {delete [] this->Array;}};
00286     vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00287     void InsertNextVertex(LocalVertex& v) 
00288       {this->MaxId++; this->Array[this->MaxId] = v;};
00289     LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00290     void Reset() {this->MaxId = -1;};
00291 
00292     LocalVertex *Array;  // pointer to data
00293     vtkIdType MaxId;             // maximum index inserted thus far
00294   };
00295 
00296   class TriArray;
00297   friend class TriArray;
00298   class TriArray { //;prevent man page generation
00299   public:
00300     TriArray(const vtkIdType sz) 
00301       {this->MaxId = -1; this->Array = new LocalTri[sz];};
00302     ~TriArray() {if (this->Array) {delete [] this->Array;}};
00303     vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00304     void InsertNextTriangle(LocalTri& t) 
00305       {this->MaxId++; this->Array[this->MaxId] = t;};
00306     LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00307     void Reset() {this->MaxId = -1;};
00308 
00309     LocalTri *Array;  // pointer to data
00310     vtkIdType MaxId;            // maximum index inserted thus far
00311   };
00312   //ETX - end tcl exclude
00313   //
00314 
00315   vtkDecimate();
00316   ~vtkDecimate();
00317 
00318   void Execute();
00319 
00320   float InitialFeatureAngle; // dihedral angle constraint
00321   float FeatureAngleIncrement;
00322   float MaximumFeatureAngle;
00323   int PreserveEdges; // do/don't worry about feature edges
00324   int BoundaryVertexDeletion;  
00325   float InitialError; // decimation error in fraction of bounding box
00326   float ErrorIncrement; // each iteration will bump error this amount
00327   float MaximumError; // maximum error
00328   float TargetReduction; //target reduction of mesh (fraction)
00329   int MaximumIterations; // maximum number of passes over data
00330   int MaximumSubIterations; // maximum non-incrementing passes
00331   float AspectRatio; // control triangle shape during triangulation
00332   int Degree; // maximum number of triangles incident on vertex
00333   int Stats[VTK_NUMBER_STATISTICS]; // keep track of interesting statistics
00334   int GenerateErrorScalars; // turn on/off vertex error scalar generation
00335   int MaximumNumberOfSquawks; //control number of error messages
00336   int PreserveTopology; //control whether mesh topology is preserved
00337   vtkIdList *Neighbors; // to replace static
00338   VertexArray *V; //to replace static
00339   TriArray *T; //to replace static
00340   
00341   void CreateOutput(vtkIdType numPts, vtkIdType numTris,
00342                     vtkIdType numEliminated, vtkPointData *pd,
00343                     vtkPoints *inPts);
00344   int BuildLoop(vtkIdType ptId, unsigned short int nTris, vtkIdType* tris);
00345   void EvaluateLoop(int& vtype, vtkIdType& numFEdges,
00346                     LocalVertexPtr fedges[]);
00347   int CanSplitLoop(LocalVertexPtr fedges[2], vtkIdType numVerts, 
00348                    LocalVertexPtr verts[], vtkIdType& n1,
00349                    LocalVertexPtr l1[], vtkIdType& n2,
00350                    LocalVertexPtr l2[], float& ar);
00351   void SplitLoop(LocalVertexPtr fedges[2], vtkIdType numVerts, 
00352                  LocalVertexPtr *verts, vtkIdType& n1,
00353                  LocalVertexPtr *l1, vtkIdType& n2, LocalVertexPtr *l2);
00354   void Triangulate(vtkIdType numVerts, LocalVertexPtr verts[]);
00355   int CheckError();
00356 private:
00357   vtkDecimate(const vtkDecimate&);  // Not implemented.
00358   void operator=(const vtkDecimate&);  // Not implemented.
00359 };
00360 
00361 #endif
00362 
00363