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 
00016         Carl B. Horton
00017         Sr. Counsel, Intellectual Property
00018         3000 N. Grandview Blvd., W-710
00019         Waukesha, WI  53188
00020         Phone:  (262) 513-4022
00021         E-Mail: Carl.Horton@med.ge.com
00022     
00023     for more information.
00024 
00025 Redistribution and use in source and binary forms, with or without
00026 modification, are permitted provided that the following conditions are met:
00027 
00028  * Redistributions of source code must retain the above copyright notice,
00029    this list of conditions and the following disclaimer.
00030 
00031  * Redistributions in binary form must reproduce the above copyright notice,
00032    this list of conditions and the following disclaimer in the documentation
00033    and/or other materials provided with the distribution.
00034 
00035  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00036    of any contributors may be used to endorse or promote products derived
00037    from this software without specific prior written permission.
00038 
00039  * Modified source versions must be plainly marked as such, and must not be
00040    misrepresented as being the original software.
00041 
00042 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00043 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00044 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00045 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00046 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00047 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00048 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00049 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00050 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00051 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00052 
00053 =========================================================================*/
00114 #ifndef __vtkDecimate_h
00115 #define __vtkDecimate_h
00116 
00117 #include "vtkPolyDataToPolyDataFilter.h"
00118 #include "vtkMath.h"
00119 #include "vtkTriangle.h"
00120 #include "vtkPlane.h"
00121 #include "vtkPolygon.h"
00122 #include "vtkLine.h"
00123 
00124 #define VTK_NUMBER_STATISTICS 12
00125 
00126 //BTX - begin tcl exclude
00127 // Special structures for building loops
00128 typedef struct _vtkLocalVertex 
00129   {
00130   vtkIdType     id;
00131   float   x[3];
00132   float   FAngle;
00133   int     deRefs; //monitor memory requirements; new only when necessary
00134   int     newRefs;
00135   } vtkLocalVertex, *vtkLocalVertexPtr;
00136     
00137 typedef struct _vtkLocalTri
00138   {
00139   vtkIdType     id;
00140   float   area;
00141   float   n[3];
00142   vtkIdType     verts[3];
00143 } vtkLocalTri, *vtkLocalTriPtr;
00144 
00145 //
00146 // Special classes for manipulating data
00147 //
00148 class vtkVertexArray { //;prevent man page generation
00149 public:
00150   vtkVertexArray(const vtkIdType sz) 
00151     {this->MaxId = -1; this->Array = new vtkLocalVertex[sz];};
00152   ~vtkVertexArray() {if (this->Array) {delete [] this->Array;}};
00153   vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00154   void InsertNextVertex(vtkLocalVertex& v) 
00155     {this->MaxId++; this->Array[this->MaxId] = v;};
00156   vtkLocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00157   void Reset() {this->MaxId = -1;};
00158 
00159   vtkLocalVertex *Array;  // pointer to data
00160   vtkIdType MaxId;             // maximum index inserted thus far
00161 };
00162 
00163 class vtkTriArray { //;prevent man page generation
00164 public:
00165   vtkTriArray(const vtkIdType sz) 
00166     {this->MaxId = -1; this->Array = new vtkLocalTri[sz];};
00167   ~vtkTriArray() {if (this->Array) {delete [] this->Array;}};
00168   vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00169   void InsertNextTriangle(vtkLocalTri& t) 
00170     {this->MaxId++; this->Array[this->MaxId] = t;};
00171   vtkLocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00172   void Reset() {this->MaxId = -1;};
00173 
00174   vtkLocalTri *Array;  // pointer to data
00175   vtkIdType MaxId;            // maximum index inserted thus far
00176 };
00177 //ETX - end tcl exclude
00178 //
00179 
00180 
00181 class VTK_PATENTED_EXPORT vtkDecimate : public vtkPolyDataToPolyDataFilter
00182 {
00183 public:
00184   static vtkDecimate *New();
00185   vtkTypeMacro(vtkDecimate,vtkPolyDataToPolyDataFilter);
00186   void PrintSelf(ostream& os, vtkIndent indent);
00187 
00189 
00191   vtkSetClampMacro(InitialError,float,0.0,1.0);
00192   vtkGetMacro(InitialError,float);
00194 
00196 
00198   vtkSetClampMacro(ErrorIncrement,float,0.0,1.0);
00199   vtkGetMacro(ErrorIncrement,float);
00201 
00203 
00205   vtkSetClampMacro(MaximumError,float,0.0,1.0);
00206   vtkGetMacro(MaximumError,float);
00208 
00210 
00213   vtkSetClampMacro(TargetReduction,float,0.0,1.0);
00214   vtkGetMacro(TargetReduction,float);
00216 
00218 
00220   vtkSetClampMacro(MaximumIterations,int,0,VTK_LARGE_INTEGER);
00221   vtkGetMacro(MaximumIterations,int);
00223 
00225 
00227   vtkSetClampMacro(MaximumSubIterations,int,1,VTK_LARGE_INTEGER);
00228   vtkGetMacro(MaximumSubIterations,int);
00230   
00232 
00233   vtkSetClampMacro(InitialFeatureAngle,float,0.0,180.0);
00234   vtkGetMacro(InitialFeatureAngle,float);
00236 
00238 
00240   vtkSetClampMacro(FeatureAngleIncrement,float,0.0,180.0);
00241   vtkGetMacro(FeatureAngleIncrement,float);
00243 
00245 
00246   vtkSetClampMacro(MaximumFeatureAngle,float,0.0,180.0);
00247   vtkGetMacro(MaximumFeatureAngle,float);
00249 
00251 
00252   vtkSetMacro(GenerateErrorScalars,int);
00253   vtkGetMacro(GenerateErrorScalars,int);
00254   vtkBooleanMacro(GenerateErrorScalars,int);
00256 
00258 
00259   vtkSetMacro(PreserveEdges,int);
00260   vtkGetMacro(PreserveEdges,int);
00261   vtkBooleanMacro(PreserveEdges,int);
00263 
00265 
00266   vtkSetMacro(BoundaryVertexDeletion,int);
00267   vtkGetMacro(BoundaryVertexDeletion,int);
00268   vtkBooleanMacro(BoundaryVertexDeletion,int);
00270 
00272 
00273   vtkSetClampMacro(AspectRatio,float,1.0,1000.0);
00274   vtkGetMacro(AspectRatio,float);
00276 
00278 
00280   vtkSetMacro(PreserveTopology,int);
00281   vtkGetMacro(PreserveTopology,int);
00282   vtkBooleanMacro(PreserveTopology,int);
00284 
00286 
00290   vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00291   vtkGetMacro(Degree,int);
00293   
00295 
00298   vtkSetClampMacro(MaximumNumberOfSquawks,int,0,VTK_LARGE_INTEGER);
00299   vtkGetMacro(MaximumNumberOfSquawks,int);
00301   
00302 protected:
00303   vtkDecimate();
00304   ~vtkDecimate();
00305 
00306   void Execute();
00307 
00308   float InitialFeatureAngle; // dihedral angle constraint
00309   float FeatureAngleIncrement;
00310   float MaximumFeatureAngle;
00311   int PreserveEdges; // do/don't worry about feature edges
00312   int BoundaryVertexDeletion;  
00313   float InitialError; // decimation error in fraction of bounding box
00314   float ErrorIncrement; // each iteration will bump error this amount
00315   float MaximumError; // maximum error
00316   float TargetReduction; //target reduction of mesh (fraction)
00317   int MaximumIterations; // maximum number of passes over data
00318   int MaximumSubIterations; // maximum non-incrementing passes
00319   float AspectRatio; // control triangle shape during triangulation
00320   int Degree; // maximum number of triangles incident on vertex
00321   int Stats[VTK_NUMBER_STATISTICS]; // keep track of interesting statistics
00322   int GenerateErrorScalars; // turn on/off vertex error scalar generation
00323   int MaximumNumberOfSquawks; //control number of error messages
00324   int PreserveTopology; //control whether mesh topology is preserved
00325   vtkIdList *Neighbors; // to replace static
00326   vtkVertexArray *V; //to replace static
00327   vtkTriArray *T; //to replace static
00328   
00329   void CreateOutput(vtkIdType numPts, vtkIdType numTris,
00330                     vtkIdType numEliminated, vtkPointData *pd,
00331                     vtkPoints *inPts);
00332   int BuildLoop(vtkIdType ptId, unsigned short int nTris, vtkIdType* tris);
00333   void EvaluateLoop(int& vtype, vtkIdType& numFEdges,
00334                     vtkLocalVertexPtr fedges[]);
00335   int CanSplitLoop(vtkLocalVertexPtr fedges[2], vtkIdType numVerts, 
00336                    vtkLocalVertexPtr verts[], vtkIdType& n1,
00337                    vtkLocalVertexPtr l1[], vtkIdType& n2,
00338                    vtkLocalVertexPtr l2[], float& ar);
00339   void SplitLoop(vtkLocalVertexPtr fedges[2], vtkIdType numVerts, 
00340                  vtkLocalVertexPtr *verts, vtkIdType& n1,
00341                  vtkLocalVertexPtr *l1, vtkIdType& n2, vtkLocalVertexPtr *l2);
00342   void Triangulate(vtkIdType numVerts, vtkLocalVertexPtr verts[]);
00343   int CheckError();
00344 private:
00345   vtkDecimate(const vtkDecimate&);  // Not implemented.
00346   void operator=(const vtkDecimate&);  // Not implemented.
00347 };
00348 
00349 #endif
00350 
00351 

Generated on Thu Mar 28 14:19:31 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001