00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00101 #ifndef __vtkDecimatePro_h
00102 #define __vtkDecimatePro_h
00103
00104 #include "vtkPolyDataToPolyDataFilter.h"
00105
00106 #include "vtkCell.h"
00107
00108 class vtkFloatArray;
00109 class vtkPriorityQueue;
00110
00111 class VTK_GRAPHICS_EXPORT vtkDecimatePro : public vtkPolyDataToPolyDataFilter
00112 {
00113 public:
00114 vtkTypeRevisionMacro(vtkDecimatePro,vtkPolyDataToPolyDataFilter);
00115 void PrintSelf(ostream& os, vtkIndent indent);
00116
00123 static vtkDecimatePro *New();
00124
00126
00132 vtkSetClampMacro(TargetReduction,float,0.0,1.0);
00133 vtkGetMacro(TargetReduction,float);
00135
00137
00140 vtkSetMacro(PreserveTopology,int);
00141 vtkGetMacro(PreserveTopology,int);
00142 vtkBooleanMacro(PreserveTopology,int);
00144
00146
00149 vtkSetClampMacro(FeatureAngle,float,0.0,180.0);
00150 vtkGetMacro(FeatureAngle,float);
00152
00154
00158 vtkSetMacro(Splitting,int);
00159 vtkGetMacro(Splitting,int);
00160 vtkBooleanMacro(Splitting,int);
00162
00164
00167 vtkSetClampMacro(SplitAngle,float,0.0,180.0);
00168 vtkGetMacro(SplitAngle,float);
00170
00172
00178 vtkSetMacro(PreSplitMesh,int);
00179 vtkGetMacro(PreSplitMesh,int);
00180 vtkBooleanMacro(PreSplitMesh,int);
00182
00184
00188 vtkSetClampMacro(MaximumError,float,0.0,VTK_LARGE_FLOAT);
00189 vtkGetMacro(MaximumError,float);
00191
00193
00200 vtkSetMacro(AccumulateError,int);
00201 vtkGetMacro(AccumulateError,int);
00202 vtkBooleanMacro(AccumulateError,int);
00204
00206
00210 vtkSetMacro(ErrorIsAbsolute,int);
00211 vtkGetMacro(ErrorIsAbsolute,int);
00213
00215
00216 vtkSetClampMacro(AbsoluteError,float,0.0,VTK_LARGE_FLOAT);
00217 vtkGetMacro(AbsoluteError,float);
00219
00221
00223 vtkSetMacro(BoundaryVertexDeletion,int);
00224 vtkGetMacro(BoundaryVertexDeletion,int);
00225 vtkBooleanMacro(BoundaryVertexDeletion,int);
00227
00229
00233 vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00234 vtkGetMacro(Degree,int);
00236
00238
00241 vtkSetClampMacro(InflectionPointRatio,float,1.001,VTK_LARGE_FLOAT);
00242 vtkGetMacro(InflectionPointRatio,float);
00244
00245
00251 vtkIdType GetNumberOfInflectionPoints();
00252
00257 void GetInflectionPoints(float *inflectionPoints);
00258
00264 float *GetInflectionPoints();
00265
00266 protected:
00267 vtkDecimatePro();
00268 ~vtkDecimatePro();
00269
00270 void Execute();
00271
00272 float TargetReduction;
00273 float FeatureAngle;
00274 float MaximumError;
00275 float AbsoluteError;
00276 int ErrorIsAbsolute;
00277 int AccumulateError;
00278 float SplitAngle;
00279 int Splitting;
00280 int PreSplitMesh;
00281 int BoundaryVertexDeletion;
00282 int PreserveTopology;
00283 int Degree;
00284 float InflectionPointRatio;
00285 vtkFloatArray *InflectionPoints;
00286
00287
00288 vtkIdList *Neighbors;
00289 vtkPriorityQueue *EdgeLengths;
00290
00291 void SplitMesh();
00292 int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
00293 vtkIdType *tris, vtkIdType fedges[2]);
00294 vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
00295 vtkIdType& pt2, vtkIdList *CollapseTris);
00296 int IsValidSplit(int index);
00297 void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
00298 vtkIdType& n2, vtkIdType *l2);
00299 void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
00300 vtkIdType *tris, int insert);
00301 int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
00302 vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
00303 void DistributeError(float error);
00304
00305
00306
00307
00308
00309
00310
00311 class LocalVertex
00312 {
00313 public:
00314 vtkIdType id;
00315 float x[3];
00316 float FAngle;
00317 };
00318 typedef LocalVertex *LocalVertexPtr;
00319
00320 class LocalTri
00321 {
00322 public:
00323 vtkIdType id;
00324 float area;
00325 float n[3];
00326 vtkIdType verts[3];
00327 };
00328 typedef LocalTri *LocalTriPtr;
00329
00330 class VertexArray;
00331 friend class VertexArray;
00332 class VertexArray {
00333 public:
00334 VertexArray(const vtkIdType sz)
00335 {this->MaxId = -1; this->Array = new LocalVertex[sz];};
00336 ~VertexArray()
00337 {
00338 if (this->Array)
00339 {
00340 delete [] this->Array;
00341 }
00342 };
00343 vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00344 void InsertNextVertex(LocalVertex& v)
00345 {this->MaxId++; this->Array[this->MaxId] = v;};
00346 LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00347 void Reset() {this->MaxId = -1;};
00348
00349 LocalVertex *Array;
00350 vtkIdType MaxId;
00351 };
00352
00353 class TriArray;
00354 friend class TriArray;
00355 class TriArray {
00356 public:
00357 TriArray(const vtkIdType sz)
00358 {this->MaxId = -1; this->Array = new LocalTri[sz];};
00359 ~TriArray()
00360 {
00361 if (this->Array)
00362 {
00363 delete [] this->Array;
00364 }
00365 };
00366 vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00367 void InsertNextTriangle(LocalTri& t)
00368 {this->MaxId++; this->Array[this->MaxId] = t;};
00369 LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00370 void Reset() {this->MaxId = -1;};
00371
00372 LocalTri *Array;
00373 vtkIdType MaxId;
00374 };
00375
00376
00377
00378 private:
00379 void InitializeQueue(vtkIdType numPts);
00380 void DeleteQueue();
00381 void Insert(vtkIdType id, float error= -1.0);
00382 int Pop(float &error);
00383 float DeleteId(vtkIdType id);
00384 void Reset();
00385
00386 vtkPriorityQueue *Queue;
00387 vtkFloatArray *VertexError;
00388
00389 VertexArray *V;
00390 TriArray *T;
00391
00392
00393 vtkPolyData *Mesh;
00394 float Pt[3];
00395 float Normal[3];
00396 float LoopArea;
00397 float CosAngle;
00398 float Tolerance;
00399 float X[3];
00400 int NumCollapses;
00401 int NumMerges;
00402 int Split;
00403 int VertexDegree;
00404 vtkIdType NumberOfRemainingTris;
00405 float TheSplitAngle;
00406 int SplitState;
00407 float Error;
00408
00409 private:
00410 vtkDecimatePro(const vtkDecimatePro&);
00411 void operator=(const vtkDecimatePro&);
00412 };
00413
00414 #endif
00415
00416