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 =========================================================================*/
00113 #ifndef __vtkDecimatePro_h
00114 #define __vtkDecimatePro_h
00115 
00116 #include "vtkPolyDataToPolyDataFilter.h"
00117 #include "vtkPriorityQueue.h"
00118 
00119 // Special structures for building loops
00120 typedef struct _vtkProLocalVertex 
00121   {
00122   vtkIdType     id;
00123   float   x[3];
00124   float   FAngle;
00125   } vtkProLocalVertex, *vtkProLocalVertexPtr;
00126     
00127 typedef struct _vtkProLocalTri
00128   {
00129   vtkIdType     id;
00130   float   area;
00131   float   n[3];
00132   vtkIdType     verts[3];
00133   } vtkProLocalTri, *vtkProLocalTriPtr;
00134 
00135 //
00136 // Special classes for manipulating data
00137 //
00138 //BTX - begin tcl exclude
00139 //
00140 class vtkProVertexArray { //;prevent man page generation
00141 public:
00142   vtkProVertexArray(const vtkIdType sz) 
00143     {this->MaxId = -1; this->Array = new vtkProLocalVertex[sz];};
00144   ~vtkProVertexArray()
00145     {
00146     if (this->Array)
00147       {
00148       delete [] this->Array;
00149       }
00150     };
00151   vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00152   void InsertNextVertex(vtkProLocalVertex& v) 
00153     {this->MaxId++; this->Array[this->MaxId] = v;};
00154   vtkProLocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00155   void Reset() {this->MaxId = -1;};
00156 
00157   vtkProLocalVertex *Array; // pointer to data
00158   vtkIdType MaxId;             // maximum index inserted thus far
00159 };
00160 
00161 class vtkProTriArray { //;prevent man page generation
00162 public:
00163   vtkProTriArray(const vtkIdType sz) 
00164     {this->MaxId = -1; this->Array = new vtkProLocalTri[sz];};
00165   ~vtkProTriArray()
00166     {
00167       if (this->Array)
00168         {
00169         delete [] this->Array;
00170         }
00171     };
00172   vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00173   void InsertNextTriangle(vtkProLocalTri& t) 
00174     {this->MaxId++; this->Array[this->MaxId] = t;};
00175   vtkProLocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00176   void Reset() {this->MaxId = -1;};
00177 
00178   vtkProLocalTri *Array;  // pointer to data
00179   vtkIdType MaxId;           // maximum index inserted thus far
00180 };
00181 //ETX - end tcl exclude
00182 //
00183 
00184 
00185 class VTK_GRAPHICS_EXPORT vtkDecimatePro : public vtkPolyDataToPolyDataFilter
00186 {
00187 public:
00188   vtkTypeMacro(vtkDecimatePro,vtkPolyDataToPolyDataFilter);
00189   void PrintSelf(ostream& os, vtkIndent indent);
00190 
00197   static vtkDecimatePro *New();
00198 
00200 
00206   vtkSetClampMacro(TargetReduction,float,0.0,1.0);
00207   vtkGetMacro(TargetReduction,float);
00209 
00211 
00214   vtkSetMacro(PreserveTopology,int);
00215   vtkGetMacro(PreserveTopology,int);
00216   vtkBooleanMacro(PreserveTopology,int);
00218 
00220 
00223   vtkSetClampMacro(FeatureAngle,float,0.0,180.0);
00224   vtkGetMacro(FeatureAngle,float);
00226 
00228 
00232   vtkSetMacro(Splitting,int);
00233   vtkGetMacro(Splitting,int);
00234   vtkBooleanMacro(Splitting,int);
00236 
00238 
00241   vtkSetClampMacro(SplitAngle,float,0.0,180.0);
00242   vtkGetMacro(SplitAngle,float);
00244 
00246 
00252   vtkSetMacro(PreSplitMesh,int);
00253   vtkGetMacro(PreSplitMesh,int);
00254   vtkBooleanMacro(PreSplitMesh,int);
00256 
00258 
00262   vtkSetClampMacro(MaximumError,float,0.0,VTK_LARGE_FLOAT);
00263   vtkGetMacro(MaximumError,float);
00265 
00267 
00274   vtkSetMacro(AccumulateError,int);
00275   vtkGetMacro(AccumulateError,int);
00276   vtkBooleanMacro(AccumulateError,int);
00278 
00280 
00284   vtkSetMacro(ErrorIsAbsolute,int);
00285   vtkGetMacro(ErrorIsAbsolute,int);
00287 
00289 
00290   vtkSetClampMacro(AbsoluteError,float,0.0,VTK_LARGE_FLOAT);
00291   vtkGetMacro(AbsoluteError,float);
00293 
00295 
00297   vtkSetMacro(BoundaryVertexDeletion,int);
00298   vtkGetMacro(BoundaryVertexDeletion,int);
00299   vtkBooleanMacro(BoundaryVertexDeletion,int);
00301 
00303 
00307   vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00308   vtkGetMacro(Degree,int);
00310   
00312 
00315   vtkSetClampMacro(InflectionPointRatio,float,1.001,VTK_LARGE_FLOAT);
00316   vtkGetMacro(InflectionPointRatio,float);
00318 
00319 
00325   vtkIdType GetNumberOfInflectionPoints();
00326 
00331   void GetInflectionPoints(float *inflectionPoints);
00332 
00338   float *GetInflectionPoints();
00339 
00340 protected:
00341   vtkDecimatePro();
00342   ~vtkDecimatePro();
00343 
00344   void Execute();
00345 
00346   float TargetReduction;
00347   float FeatureAngle;
00348   float MaximumError;
00349   float AbsoluteError;
00350   int ErrorIsAbsolute;
00351   int AccumulateError;
00352   float SplitAngle;
00353   int Splitting;
00354   int PreSplitMesh;
00355   int BoundaryVertexDeletion;
00356   int PreserveTopology;
00357   int Degree;
00358   float InflectionPointRatio;
00359   vtkFloatArray *InflectionPoints;
00360 
00361   // to replace a static object
00362   vtkIdList *Neighbors;
00363   vtkPriorityQueue *EdgeLengths;
00364 
00365   void SplitMesh();
00366   int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
00367                      vtkIdType *tris, vtkIdType fedges[2]);
00368   vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
00369                       vtkIdType& pt2, vtkIdList *CollapseTris);
00370   int IsValidSplit(int index);
00371   void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
00372                  vtkIdType& n2, vtkIdType *l2);
00373   void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
00374                    vtkIdType *tris, int insert);
00375   int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
00376                    vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
00377   void DistributeError(float error);
00378 
00379 private:
00380   void InitializeQueue(vtkIdType numPts);
00381   void DeleteQueue()
00382     {
00383       if (this->Queue)
00384       {
00385        this->Queue->Delete();
00386       }
00387       this->Queue=NULL;};
00388   void Insert(vtkIdType id, float error= -1.0);
00389   int Pop(float &error);
00390   float DeleteId(vtkIdType id) {return this->Queue->DeleteId(id);};
00391   void Reset() {this->Queue->Reset();};
00392 
00393   vtkPriorityQueue *Queue;
00394   vtkFloatArray *VertexError;
00395 
00396   vtkProVertexArray *V;
00397   vtkProTriArray *T;
00398 
00399   // Use to be static variables used by object
00400   vtkPolyData *Mesh; //operate on this data structure
00401   float Pt[3];      //least squares plane point
00402   float Normal[3];  //least squares plane normal
00403   float LoopArea;   //the total area of all triangles in a loop
00404   float CosAngle;   //Cosine of dihedral angle
00405   float Tolerance;  //Intersection tolerance
00406   float X[3];       //coordinates of current point
00407   int NumCollapses; //Number of times edge collapses occur
00408   int NumMerges;    //Number of times vertex merges occur
00409   int Split;        //Controls whether and when vertex splitting occurs
00410   int VertexDegree; //Maximum number of triangles that can use a vertex
00411   vtkIdType NumberOfRemainingTris; //Number of triangles left in the mesh
00412   float TheSplitAngle; //Split angle
00413   int SplitState;   //State of the splitting process
00414   float Error;      //Maximum allowable surface error
00415 
00416 private:
00417   vtkDecimatePro(const vtkDecimatePro&);  // Not implemented.
00418   void operator=(const vtkDecimatePro&);  // Not implemented.
00419 };
00420 
00421 #endif
00422 
00423 

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