00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00113 #ifndef __vtkDecimatePro_h
00114 #define __vtkDecimatePro_h
00115
00116 #include "vtkPolyDataToPolyDataFilter.h"
00117 #include "vtkPriorityQueue.h"
00118
00119
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
00137
00138
00139
00140 class vtkProVertexArray {
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;
00158 vtkIdType MaxId;
00159 };
00160
00161 class vtkProTriArray {
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;
00179 vtkIdType MaxId;
00180 };
00181
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
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
00400 vtkPolyData *Mesh;
00401 float Pt[3];
00402 float Normal[3];
00403 float LoopArea;
00404 float CosAngle;
00405 float Tolerance;
00406 float X[3];
00407 int NumCollapses;
00408 int NumMerges;
00409 int Split;
00410 int VertexDegree;
00411 vtkIdType NumberOfRemainingTris;
00412 float TheSplitAngle;
00413 int SplitState;
00414 float Error;
00415
00416 private:
00417 vtkDecimatePro(const vtkDecimatePro&);
00418 void operator=(const vtkDecimatePro&);
00419 };
00420
00421 #endif
00422
00423