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
00109 #ifndef __vtkDecimatePro_h
00110 #define __vtkDecimatePro_h
00111
00112 #include "vtkPolyDataToPolyDataFilter.h"
00113 #include "vtkPriorityQueue.h"
00114
00115
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
00133
00134
00135
00136 class vtkProVertexArray {
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;
00154 int MaxId;
00155 };
00156
00157 class vtkProTriArray {
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;
00175 int MaxId;
00176 };
00177
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
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;
00371
00372 vtkPolyData *Mesh;
00373 float Pt[3];
00374 float Normal[3];
00375 float LoopArea;
00376 float CosAngle;
00377 float Tolerance;
00378 float X[3];
00379 int NumCollapses;
00380 int NumMerges;
00381 int Split;
00382 int VertexDegree;
00383 int NumberOfRemainingTris;
00384 float TheSplitAngle;
00385 int SplitState;
00386 float Error;
00387
00388 };
00389
00390 #endif
00391
00392