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
00040
00041
00042
00043
00044
00118 #ifndef __vtkDecimate_h
00119 #define __vtkDecimate_h
00120
00121 #include "vtkPolyDataToPolyDataFilter.h"
00122
00123 #include "vtkCell.h"
00124
00125 #define VTK_NUMBER_STATISTICS 12
00126
00127 class vtkIdList;
00128
00129 class VTK_PATENTED_EXPORT vtkDecimate : public vtkPolyDataToPolyDataFilter
00130 {
00131 public:
00132 static vtkDecimate *New();
00133 vtkTypeRevisionMacro(vtkDecimate,vtkPolyDataToPolyDataFilter);
00134 void PrintSelf(ostream& os, vtkIndent indent);
00135
00137
00139 vtkSetClampMacro(InitialError,float,0.0,1.0);
00140 vtkGetMacro(InitialError,float);
00142
00144
00146 vtkSetClampMacro(ErrorIncrement,float,0.0,1.0);
00147 vtkGetMacro(ErrorIncrement,float);
00149
00151
00153 vtkSetClampMacro(MaximumError,float,0.0,1.0);
00154 vtkGetMacro(MaximumError,float);
00156
00158
00161 vtkSetClampMacro(TargetReduction,float,0.0,1.0);
00162 vtkGetMacro(TargetReduction,float);
00164
00166
00168 vtkSetClampMacro(MaximumIterations,int,0,VTK_LARGE_INTEGER);
00169 vtkGetMacro(MaximumIterations,int);
00171
00173
00175 vtkSetClampMacro(MaximumSubIterations,int,1,VTK_LARGE_INTEGER);
00176 vtkGetMacro(MaximumSubIterations,int);
00178
00180
00181 vtkSetClampMacro(InitialFeatureAngle,float,0.0,180.0);
00182 vtkGetMacro(InitialFeatureAngle,float);
00184
00186
00188 vtkSetClampMacro(FeatureAngleIncrement,float,0.0,180.0);
00189 vtkGetMacro(FeatureAngleIncrement,float);
00191
00193
00194 vtkSetClampMacro(MaximumFeatureAngle,float,0.0,180.0);
00195 vtkGetMacro(MaximumFeatureAngle,float);
00197
00199
00200 vtkSetMacro(GenerateErrorScalars,int);
00201 vtkGetMacro(GenerateErrorScalars,int);
00202 vtkBooleanMacro(GenerateErrorScalars,int);
00204
00206
00207 vtkSetMacro(PreserveEdges,int);
00208 vtkGetMacro(PreserveEdges,int);
00209 vtkBooleanMacro(PreserveEdges,int);
00211
00213
00214 vtkSetMacro(BoundaryVertexDeletion,int);
00215 vtkGetMacro(BoundaryVertexDeletion,int);
00216 vtkBooleanMacro(BoundaryVertexDeletion,int);
00218
00220
00221 vtkSetClampMacro(AspectRatio,float,1.0,1000.0);
00222 vtkGetMacro(AspectRatio,float);
00224
00226
00228 vtkSetMacro(PreserveTopology,int);
00229 vtkGetMacro(PreserveTopology,int);
00230 vtkBooleanMacro(PreserveTopology,int);
00232
00234
00238 vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00239 vtkGetMacro(Degree,int);
00241
00243
00246 vtkSetClampMacro(MaximumNumberOfSquawks,int,0,VTK_LARGE_INTEGER);
00247 vtkGetMacro(MaximumNumberOfSquawks,int);
00249
00250 protected:
00251
00252
00253
00254
00255
00256
00257
00258 class LocalVertex
00259 {
00260 public:
00261 vtkIdType id;
00262 float x[3];
00263 float FAngle;
00264 int deRefs;
00265 int newRefs;
00266 };
00267 typedef LocalVertex *LocalVertexPtr;
00268
00269 class LocalTri
00270 {
00271 public:
00272 vtkIdType id;
00273 float area;
00274 float n[3];
00275 vtkIdType verts[3];
00276 };
00277 typedef LocalTri *LocalTriPtr;
00278
00279 class VertexArray;
00280 friend class VertexArray;
00281 class VertexArray {
00282 public:
00283 VertexArray(const vtkIdType sz)
00284 {this->MaxId = -1; this->Array = new LocalVertex[sz];};
00285 ~VertexArray() {if (this->Array) {delete [] this->Array;}};
00286 vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00287 void InsertNextVertex(LocalVertex& v)
00288 {this->MaxId++; this->Array[this->MaxId] = v;};
00289 LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00290 void Reset() {this->MaxId = -1;};
00291
00292 LocalVertex *Array;
00293 vtkIdType MaxId;
00294 };
00295
00296 class TriArray;
00297 friend class TriArray;
00298 class TriArray {
00299 public:
00300 TriArray(const vtkIdType sz)
00301 {this->MaxId = -1; this->Array = new LocalTri[sz];};
00302 ~TriArray() {if (this->Array) {delete [] this->Array;}};
00303 vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00304 void InsertNextTriangle(LocalTri& t)
00305 {this->MaxId++; this->Array[this->MaxId] = t;};
00306 LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00307 void Reset() {this->MaxId = -1;};
00308
00309 LocalTri *Array;
00310 vtkIdType MaxId;
00311 };
00312
00313
00314
00315 vtkDecimate();
00316 ~vtkDecimate();
00317
00318 void Execute();
00319
00320 float InitialFeatureAngle;
00321 float FeatureAngleIncrement;
00322 float MaximumFeatureAngle;
00323 int PreserveEdges;
00324 int BoundaryVertexDeletion;
00325 float InitialError;
00326 float ErrorIncrement;
00327 float MaximumError;
00328 float TargetReduction;
00329 int MaximumIterations;
00330 int MaximumSubIterations;
00331 float AspectRatio;
00332 int Degree;
00333 int Stats[VTK_NUMBER_STATISTICS];
00334 int GenerateErrorScalars;
00335 int MaximumNumberOfSquawks;
00336 int PreserveTopology;
00337 vtkIdList *Neighbors;
00338 VertexArray *V;
00339 TriArray *T;
00340
00341 void CreateOutput(vtkIdType numPts, vtkIdType numTris,
00342 vtkIdType numEliminated, vtkPointData *pd,
00343 vtkPoints *inPts);
00344 int BuildLoop(vtkIdType ptId, unsigned short int nTris, vtkIdType* tris);
00345 void EvaluateLoop(int& vtype, vtkIdType& numFEdges,
00346 LocalVertexPtr fedges[]);
00347 int CanSplitLoop(LocalVertexPtr fedges[2], vtkIdType numVerts,
00348 LocalVertexPtr verts[], vtkIdType& n1,
00349 LocalVertexPtr l1[], vtkIdType& n2,
00350 LocalVertexPtr l2[], float& ar);
00351 void SplitLoop(LocalVertexPtr fedges[2], vtkIdType numVerts,
00352 LocalVertexPtr *verts, vtkIdType& n1,
00353 LocalVertexPtr *l1, vtkIdType& n2, LocalVertexPtr *l2);
00354 void Triangulate(vtkIdType numVerts, LocalVertexPtr verts[]);
00355 int CheckError();
00356 private:
00357 vtkDecimate(const vtkDecimate&);
00358 void operator=(const vtkDecimate&);
00359 };
00360
00361 #endif
00362
00363