00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00082 #ifndef __vtkDecimatePro_h
00083 #define __vtkDecimatePro_h
00084
00085 #include "vtkPolyDataAlgorithm.h"
00086
00087 #include "vtkCell.h"
00088
00089 class vtkDoubleArray;
00090 class vtkPriorityQueue;
00091
00092 class VTK_GRAPHICS_EXPORT vtkDecimatePro : public vtkPolyDataAlgorithm
00093 {
00094 public:
00095 vtkTypeRevisionMacro(vtkDecimatePro,vtkPolyDataAlgorithm);
00096 void PrintSelf(ostream& os, vtkIndent indent);
00097
00104 static vtkDecimatePro *New();
00105
00107
00115 vtkSetClampMacro(TargetReduction,double,0.0,1.0);
00116 vtkGetMacro(TargetReduction,double);
00118
00120
00123 vtkSetMacro(PreserveTopology,int);
00124 vtkGetMacro(PreserveTopology,int);
00125 vtkBooleanMacro(PreserveTopology,int);
00127
00129
00132 vtkSetClampMacro(FeatureAngle,double,0.0,180.0);
00133 vtkGetMacro(FeatureAngle,double);
00135
00137
00141 vtkSetMacro(Splitting,int);
00142 vtkGetMacro(Splitting,int);
00143 vtkBooleanMacro(Splitting,int);
00145
00147
00150 vtkSetClampMacro(SplitAngle,double,0.0,180.0);
00151 vtkGetMacro(SplitAngle,double);
00153
00155
00161 vtkSetMacro(PreSplitMesh,int);
00162 vtkGetMacro(PreSplitMesh,int);
00163 vtkBooleanMacro(PreSplitMesh,int);
00165
00167
00171 vtkSetClampMacro(MaximumError,double,0.0,VTK_DOUBLE_MAX);
00172 vtkGetMacro(MaximumError,double);
00174
00176
00183 vtkSetMacro(AccumulateError,int);
00184 vtkGetMacro(AccumulateError,int);
00185 vtkBooleanMacro(AccumulateError,int);
00187
00189
00193 vtkSetMacro(ErrorIsAbsolute,int);
00194 vtkGetMacro(ErrorIsAbsolute,int);
00196
00198
00199 vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
00200 vtkGetMacro(AbsoluteError,double);
00202
00204
00206 vtkSetMacro(BoundaryVertexDeletion,int);
00207 vtkGetMacro(BoundaryVertexDeletion,int);
00208 vtkBooleanMacro(BoundaryVertexDeletion,int);
00210
00212
00216 vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00217 vtkGetMacro(Degree,int);
00219
00221
00224 vtkSetClampMacro(InflectionPointRatio,double,1.001,VTK_DOUBLE_MAX);
00225 vtkGetMacro(InflectionPointRatio,double);
00227
00228
00234 vtkIdType GetNumberOfInflectionPoints();
00235
00240 void GetInflectionPoints(double *inflectionPoints);
00241
00247 double *GetInflectionPoints();
00248
00249 protected:
00250 vtkDecimatePro();
00251 ~vtkDecimatePro();
00252
00253 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00254
00255 double TargetReduction;
00256 double FeatureAngle;
00257 double MaximumError;
00258 double AbsoluteError;
00259 int ErrorIsAbsolute;
00260 int AccumulateError;
00261 double SplitAngle;
00262 int Splitting;
00263 int PreSplitMesh;
00264 int BoundaryVertexDeletion;
00265 int PreserveTopology;
00266 int Degree;
00267 double InflectionPointRatio;
00268 vtkDoubleArray *InflectionPoints;
00269
00270
00271 vtkIdList *Neighbors;
00272 vtkPriorityQueue *EdgeLengths;
00273
00274 void SplitMesh();
00275 int EvaluateVertex(vtkIdType ptId, unsigned short int numTris,
00276 vtkIdType *tris, vtkIdType fedges[2]);
00277 vtkIdType FindSplit(int type, vtkIdType fedges[2], vtkIdType& pt1,
00278 vtkIdType& pt2, vtkIdList *CollapseTris);
00279 int IsValidSplit(int index);
00280 void SplitLoop(vtkIdType fedges[2], vtkIdType& n1, vtkIdType *l1,
00281 vtkIdType& n2, vtkIdType *l2);
00282 void SplitVertex(vtkIdType ptId,int type, unsigned short int numTris,
00283 vtkIdType *tris, int insert);
00284 int CollapseEdge(int type, vtkIdType ptId, vtkIdType collapseId,
00285 vtkIdType pt1, vtkIdType pt2, vtkIdList *CollapseTris);
00286 void DistributeError(double error);
00287
00288
00289
00290
00291
00292
00293
00294 class LocalVertex
00295 {
00296 public:
00297 vtkIdType id;
00298 double x[3];
00299 double FAngle;
00300 };
00301 typedef LocalVertex *LocalVertexPtr;
00302
00303 class LocalTri
00304 {
00305 public:
00306 vtkIdType id;
00307 double area;
00308 double n[3];
00309 vtkIdType verts[3];
00310 };
00311 typedef LocalTri *LocalTriPtr;
00312
00313 class VertexArray;
00314 friend class VertexArray;
00315 class VertexArray {
00316 public:
00317 VertexArray(const vtkIdType sz)
00318 {this->MaxId = -1; this->Array = new LocalVertex[sz];};
00319 ~VertexArray()
00320 {
00321 if (this->Array)
00322 {
00323 delete [] this->Array;
00324 }
00325 };
00326 vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00327 void InsertNextVertex(LocalVertex& v)
00328 {this->MaxId++; this->Array[this->MaxId] = v;};
00329 LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00330 void Reset() {this->MaxId = -1;};
00331
00332 LocalVertex *Array;
00333 vtkIdType MaxId;
00334 };
00335
00336 class TriArray;
00337 friend class TriArray;
00338 class TriArray {
00339 public:
00340 TriArray(const vtkIdType sz)
00341 {this->MaxId = -1; this->Array = new LocalTri[sz];};
00342 ~TriArray()
00343 {
00344 if (this->Array)
00345 {
00346 delete [] this->Array;
00347 }
00348 };
00349 vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00350 void InsertNextTriangle(LocalTri& t)
00351 {this->MaxId++; this->Array[this->MaxId] = t;};
00352 LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00353 void Reset() {this->MaxId = -1;};
00354
00355 LocalTri *Array;
00356 vtkIdType MaxId;
00357 };
00358
00359
00360
00361 private:
00362 void InitializeQueue(vtkIdType numPts);
00363 void DeleteQueue();
00364 void Insert(vtkIdType id, double error= -1.0);
00365 int Pop(double &error);
00366 double DeleteId(vtkIdType id);
00367 void Reset();
00368
00369 vtkPriorityQueue *Queue;
00370 vtkDoubleArray *VertexError;
00371
00372 VertexArray *V;
00373 TriArray *T;
00374
00375
00376 vtkPolyData *Mesh;
00377 double Pt[3];
00378 double Normal[3];
00379 double LoopArea;
00380 double CosAngle;
00381 double Tolerance;
00382 double X[3];
00383 int NumCollapses;
00384 int NumMerges;
00385 int Split;
00386 int VertexDegree;
00387 vtkIdType NumberOfRemainingTris;
00388 double TheSplitAngle;
00389 int SplitState;
00390 double Error;
00391
00392 private:
00393 vtkDecimatePro(const vtkDecimatePro&);
00394 void operator=(const vtkDecimatePro&);
00395 };
00396
00397 #endif
00398
00399