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

graphics/vtkDecimatePro.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDecimatePro.h,v $
00005   Language:  C++
00006 
00007 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00109 #ifndef __vtkDecimatePro_h
00110 #define __vtkDecimatePro_h
00111 
00112 #include "vtkPolyDataToPolyDataFilter.h"
00113 #include "vtkPriorityQueue.h"
00114 
00115 // Special structures for building loops
00116 typedef struct _vtkProLocalVertex 
00117   {
00118   int     id;
00119   float   x[3];
00120   float   FAngle;
00121   } vtkProLocalVertex, *vtkProLocalVertexPtr;
00122     
00123 typedef struct _vtkProLocalTri
00124   {
00125   int     id;
00126   float   area;
00127   float   n[3];
00128   int     verts[3];
00129   } vtkProLocalTri, *vtkProLocalTriPtr;
00130 
00131 //
00132 // Special classes for manipulating data
00133 //
00134 //BTX - begin tcl exclude
00135 //
00136 class vtkProVertexArray { //;prevent man page generation
00137 public:
00138   vtkProVertexArray(const int sz) 
00139     {this->MaxId = -1; this->Array = new vtkProLocalVertex[sz];};
00140   ~vtkProVertexArray()
00141     {
00142     if (this->Array)
00143       {
00144       delete [] this->Array;
00145       }
00146     };
00147   int GetNumberOfVertices() {return this->MaxId + 1;};
00148   void InsertNextVertex(vtkProLocalVertex& v) 
00149     {this->MaxId++; this->Array[this->MaxId] = v;};
00150   vtkProLocalVertex& GetVertex(int i) {return this->Array[i];};
00151   void Reset() {this->MaxId = -1;};
00152 
00153   vtkProLocalVertex *Array; // pointer to data
00154   int MaxId;             // maximum index inserted thus far
00155 };
00156 
00157 class vtkProTriArray { //;prevent man page generation
00158 public:
00159   vtkProTriArray(const int sz) 
00160     {this->MaxId = -1; this->Array = new vtkProLocalTri[sz];};
00161   ~vtkProTriArray()
00162     {
00163       if (this->Array)
00164    {
00165    delete [] this->Array;
00166    }
00167     };
00168   int GetNumberOfTriangles() {return this->MaxId + 1;};
00169   void InsertNextTriangle(vtkProLocalTri& t) 
00170     {this->MaxId++; this->Array[this->MaxId] = t;};
00171   vtkProLocalTri& GetTriangle(int i) {return this->Array[i];};
00172   void Reset() {this->MaxId = -1;};
00173 
00174   vtkProLocalTri *Array;  // pointer to data
00175   int MaxId;           // maximum index inserted thus far
00176 };
00177 //ETX - end tcl exclude
00178 //
00179 
00180 
00181 class VTK_EXPORT vtkDecimatePro : public vtkPolyDataToPolyDataFilter
00182 {
00183 public:
00184   vtkTypeMacro(vtkDecimatePro,vtkPolyDataToPolyDataFilter);
00185   void PrintSelf(ostream& os, vtkIndent indent);
00186 
00193   static vtkDecimatePro *New();
00194 
00201   vtkSetClampMacro(TargetReduction,float,0.0,1.0);
00202   vtkGetMacro(TargetReduction,float);
00203 
00207   vtkSetMacro(PreserveTopology,int);
00208   vtkGetMacro(PreserveTopology,int);
00209   vtkBooleanMacro(PreserveTopology,int);
00210 
00214   vtkSetClampMacro(FeatureAngle,float,0.0,180.0);
00215   vtkGetMacro(FeatureAngle,float);
00216 
00221   vtkSetMacro(Splitting,int);
00222   vtkGetMacro(Splitting,int);
00223   vtkBooleanMacro(Splitting,int);
00224 
00228   vtkSetClampMacro(SplitAngle,float,0.0,180.0);
00229   vtkGetMacro(SplitAngle,float);
00230 
00237   vtkSetMacro(PreSplitMesh,int);
00238   vtkGetMacro(PreSplitMesh,int);
00239   vtkBooleanMacro(PreSplitMesh,int);
00240 
00245   vtkSetClampMacro(MaximumError,float,0.0,VTK_LARGE_FLOAT);
00246   vtkGetMacro(MaximumError,float);
00247 
00255   vtkSetMacro(AccumulateError,int);
00256   vtkGetMacro(AccumulateError,int);
00257   vtkBooleanMacro(AccumulateError,int);
00258 
00263   vtkSetMacro(ErrorIsAbsolute,int);
00264   vtkGetMacro(ErrorIsAbsolute,int);
00265 
00267   vtkSetClampMacro(AbsoluteError,float,0.0,VTK_LARGE_FLOAT);
00268   vtkGetMacro(AbsoluteError,float);
00269 
00272   vtkSetMacro(BoundaryVertexDeletion,int);
00273   vtkGetMacro(BoundaryVertexDeletion,int);
00274   vtkBooleanMacro(BoundaryVertexDeletion,int);
00275 
00280   vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00281   vtkGetMacro(Degree,int);
00282   
00286   vtkSetClampMacro(InflectionPointRatio,float,1.001,VTK_LARGE_FLOAT);
00287   vtkGetMacro(InflectionPointRatio,float);
00288 
00289 
00295   int GetNumberOfInflectionPoints();
00296 
00301   void GetInflectionPoints(float *inflectionPoints);
00302 
00308   float *GetInflectionPoints();
00309 
00310 protected:
00311   vtkDecimatePro();
00312   ~vtkDecimatePro();
00313   vtkDecimatePro(const vtkDecimatePro&) {};
00314   void operator=(const vtkDecimatePro&) {};
00315 
00316   void Execute();
00317 
00318   float TargetReduction;
00319   float FeatureAngle;
00320   float MaximumError;
00321   float AbsoluteError;
00322   int ErrorIsAbsolute;
00323   int AccumulateError;
00324   float SplitAngle;
00325   int Splitting;
00326   int PreSplitMesh;
00327   int BoundaryVertexDeletion;
00328   int PreserveTopology;
00329   int Degree;
00330   float InflectionPointRatio;
00331   vtkFloatArray *InflectionPoints;
00332 
00333   // to replace a static object
00334   vtkIdList *Neighbors;
00335   vtkPriorityQueue *EdgeLengths;
00336 
00337   void SplitMesh();
00338   int EvaluateVertex(int ptId, unsigned short int numTris, int *tris,
00339                      int fedges[2]);
00340   int FindSplit(int type, int fedges[2], int& pt1, int& pt2,
00341                 vtkIdList *CollapseTris);
00342   int IsValidSplit(int index);
00343   void SplitLoop(int fedges[2], int& n1, int *l1, int& n2, int *l2);
00344   void SplitVertex(int ptId,int type, unsigned short int numTris, int *tris,
00345                    int insert);
00346   int CollapseEdge(int type, int ptId, int collapseId, int pt1, int pt2,
00347                    vtkIdList *CollapseTris);
00348   void DistributeError(float error);
00349 
00350 private:
00351   void InitializeQueue(int numPts);
00352   void DeleteQueue()
00353     {
00354       if (this->Queue)
00355       {
00356        this->Queue->Delete();
00357       }
00358       this->Queue=NULL;};
00359   void Insert(int id, float error= -1.0);
00360   int Pop(float &error);
00361   float DeleteId(int id) {return this->Queue->DeleteId(id);};
00362   void Reset() {this->Queue->Reset();};
00363 
00364   vtkPriorityQueue *Queue;
00365   vtkFloatArray *VertexError;
00366 
00367   vtkProVertexArray *V;
00368   vtkProTriArray *T;
00369 
00370   vtkPointData *TempPD; // temp holder of point data for splitting
00371   // Use to be static variables used by object
00372   vtkPolyData *Mesh; //operate on this data structure
00373   float Pt[3];      //least squares plane point
00374   float Normal[3];  //least squares plane normal
00375   float LoopArea;   //the total area of all triangles in a loop
00376   float CosAngle;   //Cosine of dihedral angle
00377   float Tolerance;  //Intersection tolerance
00378   float X[3];       //coordinates of current point
00379   int NumCollapses; //Number of times edge collapses occur
00380   int NumMerges;    //Number of times vertex merges occur
00381   int Split;        //Controls whether and when vertex splitting occurs
00382   int VertexDegree; //Maximum number of triangles that can use a vertex
00383   int NumberOfRemainingTris; //Number of triangles left in the mesh
00384   float TheSplitAngle; //Split angle
00385   int SplitState;   //State of the splitting process
00386   float Error;      //Maximum allowable surface error
00387 
00388 };
00389 
00390 #endif
00391 
00392 

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