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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011     THIS CLASS IS PATENTED UNDER UNITED STATES PATENT NUMBER 5,559,388
00012     "Method for Reducting the Complexity of a Polygonal Mesh".
00013     Application of this software for commercial purposes requires 
00014     a license grant from GE. Contact:
00015         Jerald Roehling
00016         GE Licensing
00017         One Independence Way
00018         PO Box 2023
00019         Princeton, N.J. 08540
00020         phone 609-734-9823
00021         e-mail:Roehlinj@gerlmo.ge.com
00022     for more information.
00023 
00024 Redistribution and use in source and binary forms, with or without
00025 modification, are permitted provided that the following conditions are met:
00026 
00027  * Redistributions of source code must retain the above copyright notice,
00028    this list of conditions and the following disclaimer.
00029 
00030  * Redistributions in binary form must reproduce the above copyright notice,
00031    this list of conditions and the following disclaimer in the documentation
00032    and/or other materials provided with the distribution.
00033 
00034  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00035    of any contributors may be used to endorse or promote products derived
00036    from this software without specific prior written permission.
00037 
00038  * Modified source versions must be plainly marked as such, and must not be
00039    misrepresented as being the original software.
00040 
00041 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00042 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00043 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00044 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00045 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00046 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00047 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00048 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00049 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00050 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00051 
00052 =========================================================================*/
00112 #ifndef __vtkDecimate_h
00113 #define __vtkDecimate_h
00114 
00115 #include "vtkPolyDataToPolyDataFilter.h"
00116 #include "vtkMath.h"
00117 #include "vtkTriangle.h"
00118 #include "vtkPlane.h"
00119 #include "vtkPolygon.h"
00120 #include "vtkLine.h"
00121 
00122 #define VTK_NUMBER_STATISTICS 12
00123 
00124 //BTX - begin tcl exclude
00125 // Special structures for building loops
00126 typedef struct _vtkLocalVertex 
00127   {
00128   int     id;
00129   float   x[3];
00130   float   FAngle;
00131   int     deRefs; //monitor memory requirements; new only when necessary
00132   int     newRefs;
00133   } vtkLocalVertex, *vtkLocalVertexPtr;
00134     
00135 typedef struct _vtkLocalTri
00136   {
00137   int     id;
00138   float   area;
00139   float   n[3];
00140   int     verts[3];
00141   } vtkLocalTri, *vtkLocalTriPtr;
00142 
00143 //
00144 // Special classes for manipulating data
00145 //
00146 class vtkVertexArray { //;prevent man page generation
00147 public:
00148   vtkVertexArray(const int sz) 
00149     {this->MaxId = -1; this->Array = new vtkLocalVertex[sz];};
00150   ~vtkVertexArray() {if (this->Array) {delete [] this->Array;}};
00151   int GetNumberOfVertices() {return this->MaxId + 1;};
00152   void InsertNextVertex(vtkLocalVertex& v) 
00153     {this->MaxId++; this->Array[this->MaxId] = v;};
00154   vtkLocalVertex& GetVertex(int i) {return this->Array[i];};
00155   void Reset() {this->MaxId = -1;};
00156 
00157   vtkLocalVertex *Array;  // pointer to data
00158   int MaxId;             // maximum index inserted thus far
00159 };
00160 
00161 class vtkTriArray { //;prevent man page generation
00162 public:
00163   vtkTriArray(const int sz) 
00164     {this->MaxId = -1; this->Array = new vtkLocalTri[sz];};
00165   ~vtkTriArray() {if (this->Array) {delete [] this->Array;}};
00166   int GetNumberOfTriangles() {return this->MaxId + 1;};
00167   void InsertNextTriangle(vtkLocalTri& t) 
00168     {this->MaxId++; this->Array[this->MaxId] = t;};
00169   vtkLocalTri& GetTriangle(int i) {return this->Array[i];};
00170   void Reset() {this->MaxId = -1;};
00171 
00172   vtkLocalTri *Array;  // pointer to data
00173   int MaxId;            // maximum index inserted thus far
00174 };
00175 //ETX - end tcl exclude
00176 //
00177 
00178 
00179 class VTK_EXPORT vtkDecimate : public vtkPolyDataToPolyDataFilter
00180 {
00181 public:
00182   static vtkDecimate *New();
00183   vtkTypeMacro(vtkDecimate,vtkPolyDataToPolyDataFilter);
00184   void PrintSelf(ostream& os, vtkIndent indent);
00185 
00188   vtkSetClampMacro(InitialError,float,0.0,1.0);
00189   vtkGetMacro(InitialError,float);
00190 
00193   vtkSetClampMacro(ErrorIncrement,float,0.0,1.0);
00194   vtkGetMacro(ErrorIncrement,float);
00195 
00198   vtkSetClampMacro(MaximumError,float,0.0,1.0);
00199   vtkGetMacro(MaximumError,float);
00200 
00204   vtkSetClampMacro(TargetReduction,float,0.0,1.0);
00205   vtkGetMacro(TargetReduction,float);
00206 
00209   vtkSetClampMacro(MaximumIterations,int,0,VTK_LARGE_INTEGER);
00210   vtkGetMacro(MaximumIterations,int);
00211 
00214   vtkSetClampMacro(MaximumSubIterations,int,1,VTK_LARGE_INTEGER);
00215   vtkGetMacro(MaximumSubIterations,int);
00216   
00218   vtkSetClampMacro(InitialFeatureAngle,float,0.0,180.0);
00219   vtkGetMacro(InitialFeatureAngle,float);
00220 
00223   vtkSetClampMacro(FeatureAngleIncrement,float,0.0,180.0);
00224   vtkGetMacro(FeatureAngleIncrement,float);
00225 
00227   vtkSetClampMacro(MaximumFeatureAngle,float,0.0,180.0);
00228   vtkGetMacro(MaximumFeatureAngle,float);
00229 
00231   vtkSetMacro(GenerateErrorScalars,int);
00232   vtkGetMacro(GenerateErrorScalars,int);
00233   vtkBooleanMacro(GenerateErrorScalars,int);
00234 
00236   vtkSetMacro(PreserveEdges,int);
00237   vtkGetMacro(PreserveEdges,int);
00238   vtkBooleanMacro(PreserveEdges,int);
00239 
00241   vtkSetMacro(BoundaryVertexDeletion,int);
00242   vtkGetMacro(BoundaryVertexDeletion,int);
00243   vtkBooleanMacro(BoundaryVertexDeletion,int);
00244 
00246   vtkSetClampMacro(AspectRatio,float,1.0,1000.0);
00247   vtkGetMacro(AspectRatio,float);
00248 
00251   vtkSetMacro(PreserveTopology,int);
00252   vtkGetMacro(PreserveTopology,int);
00253   vtkBooleanMacro(PreserveTopology,int);
00254 
00259   vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00260   vtkGetMacro(Degree,int);
00261   
00265   vtkSetClampMacro(MaximumNumberOfSquawks,int,0,VTK_LARGE_INTEGER);
00266   vtkGetMacro(MaximumNumberOfSquawks,int);
00267   
00268 protected:
00269   vtkDecimate();
00270   ~vtkDecimate();
00271   vtkDecimate(const vtkDecimate&) {};
00272   void operator=(const vtkDecimate&) {};
00273 
00274   void Execute();
00275 
00276   float InitialFeatureAngle; // dihedral angle constraint
00277   float FeatureAngleIncrement;
00278   float MaximumFeatureAngle;
00279   int PreserveEdges; // do/don't worry about feature edges
00280   int BoundaryVertexDeletion;  
00281   float InitialError; // decimation error in fraction of bounding box
00282   float ErrorIncrement; // each iteration will bump error this amount
00283   float MaximumError; // maximum error
00284   float TargetReduction; //target reduction of mesh (fraction)
00285   int MaximumIterations; // maximum number of passes over data
00286   int MaximumSubIterations; // maximum non-incrementing passes
00287   float AspectRatio; // control triangle shape during triangulation
00288   int Degree; // maximum number of triangles incident on vertex
00289   int Stats[VTK_NUMBER_STATISTICS]; // keep track of interesting statistics
00290   int GenerateErrorScalars; // turn on/off vertex error scalar generation
00291   int MaximumNumberOfSquawks; //control number of error messages
00292   int PreserveTopology; //control whether mesh topology is preserved
00293   vtkIdList *Neighbors; // to replace static
00294   vtkVertexArray *V; //to replace static
00295   vtkTriArray *T; //to replace static
00296   
00297   void CreateOutput(int numPts, int numTris, int numEliminated, 
00298                     vtkPointData *pd, vtkPoints *inPts);
00299   int BuildLoop(int ptId, unsigned short int nTris, int* tris);
00300   void EvaluateLoop(int& vtype, int& numFEdges, vtkLocalVertexPtr fedges[]);
00301   int CanSplitLoop(vtkLocalVertexPtr fedges[2], int numVerts, 
00302                    vtkLocalVertexPtr verts[], int& n1, vtkLocalVertexPtr l1[], 
00303                    int& n2, vtkLocalVertexPtr l2[], float& ar);
00304   void SplitLoop(vtkLocalVertexPtr fedges[2], int numVerts, 
00305                  vtkLocalVertexPtr *verts, int& n1, vtkLocalVertexPtr *l1, 
00306                  int& n2, vtkLocalVertexPtr *l2);
00307   void Triangulate(int numVerts, vtkLocalVertexPtr verts[]);
00308   int CheckError();
00309 };
00310 
00311 #endif
00312 
00313 

Generated on Wed Nov 21 12:27:09 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001