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
00045
00046
00047
00048
00049
00050
00051
00052
00053
00114 #ifndef __vtkDecimate_h
00115 #define __vtkDecimate_h
00116
00117 #include "vtkPolyDataToPolyDataFilter.h"
00118 #include "vtkMath.h"
00119 #include "vtkTriangle.h"
00120 #include "vtkPlane.h"
00121 #include "vtkPolygon.h"
00122 #include "vtkLine.h"
00123
00124 #define VTK_NUMBER_STATISTICS 12
00125
00126
00127
00128 typedef struct _vtkLocalVertex
00129 {
00130 vtkIdType id;
00131 float x[3];
00132 float FAngle;
00133 int deRefs;
00134 int newRefs;
00135 } vtkLocalVertex, *vtkLocalVertexPtr;
00136
00137 typedef struct _vtkLocalTri
00138 {
00139 vtkIdType id;
00140 float area;
00141 float n[3];
00142 vtkIdType verts[3];
00143 } vtkLocalTri, *vtkLocalTriPtr;
00144
00145
00146
00147
00148 class vtkVertexArray {
00149 public:
00150 vtkVertexArray(const vtkIdType sz)
00151 {this->MaxId = -1; this->Array = new vtkLocalVertex[sz];};
00152 ~vtkVertexArray() {if (this->Array) {delete [] this->Array;}};
00153 vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00154 void InsertNextVertex(vtkLocalVertex& v)
00155 {this->MaxId++; this->Array[this->MaxId] = v;};
00156 vtkLocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00157 void Reset() {this->MaxId = -1;};
00158
00159 vtkLocalVertex *Array;
00160 vtkIdType MaxId;
00161 };
00162
00163 class vtkTriArray {
00164 public:
00165 vtkTriArray(const vtkIdType sz)
00166 {this->MaxId = -1; this->Array = new vtkLocalTri[sz];};
00167 ~vtkTriArray() {if (this->Array) {delete [] this->Array;}};
00168 vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00169 void InsertNextTriangle(vtkLocalTri& t)
00170 {this->MaxId++; this->Array[this->MaxId] = t;};
00171 vtkLocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00172 void Reset() {this->MaxId = -1;};
00173
00174 vtkLocalTri *Array;
00175 vtkIdType MaxId;
00176 };
00177
00178
00179
00180
00181 class VTK_PATENTED_EXPORT vtkDecimate : public vtkPolyDataToPolyDataFilter
00182 {
00183 public:
00184 static vtkDecimate *New();
00185 vtkTypeMacro(vtkDecimate,vtkPolyDataToPolyDataFilter);
00186 void PrintSelf(ostream& os, vtkIndent indent);
00187
00189
00191 vtkSetClampMacro(InitialError,float,0.0,1.0);
00192 vtkGetMacro(InitialError,float);
00194
00196
00198 vtkSetClampMacro(ErrorIncrement,float,0.0,1.0);
00199 vtkGetMacro(ErrorIncrement,float);
00201
00203
00205 vtkSetClampMacro(MaximumError,float,0.0,1.0);
00206 vtkGetMacro(MaximumError,float);
00208
00210
00213 vtkSetClampMacro(TargetReduction,float,0.0,1.0);
00214 vtkGetMacro(TargetReduction,float);
00216
00218
00220 vtkSetClampMacro(MaximumIterations,int,0,VTK_LARGE_INTEGER);
00221 vtkGetMacro(MaximumIterations,int);
00223
00225
00227 vtkSetClampMacro(MaximumSubIterations,int,1,VTK_LARGE_INTEGER);
00228 vtkGetMacro(MaximumSubIterations,int);
00230
00232
00233 vtkSetClampMacro(InitialFeatureAngle,float,0.0,180.0);
00234 vtkGetMacro(InitialFeatureAngle,float);
00236
00238
00240 vtkSetClampMacro(FeatureAngleIncrement,float,0.0,180.0);
00241 vtkGetMacro(FeatureAngleIncrement,float);
00243
00245
00246 vtkSetClampMacro(MaximumFeatureAngle,float,0.0,180.0);
00247 vtkGetMacro(MaximumFeatureAngle,float);
00249
00251
00252 vtkSetMacro(GenerateErrorScalars,int);
00253 vtkGetMacro(GenerateErrorScalars,int);
00254 vtkBooleanMacro(GenerateErrorScalars,int);
00256
00258
00259 vtkSetMacro(PreserveEdges,int);
00260 vtkGetMacro(PreserveEdges,int);
00261 vtkBooleanMacro(PreserveEdges,int);
00263
00265
00266 vtkSetMacro(BoundaryVertexDeletion,int);
00267 vtkGetMacro(BoundaryVertexDeletion,int);
00268 vtkBooleanMacro(BoundaryVertexDeletion,int);
00270
00272
00273 vtkSetClampMacro(AspectRatio,float,1.0,1000.0);
00274 vtkGetMacro(AspectRatio,float);
00276
00278
00280 vtkSetMacro(PreserveTopology,int);
00281 vtkGetMacro(PreserveTopology,int);
00282 vtkBooleanMacro(PreserveTopology,int);
00284
00286
00290 vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00291 vtkGetMacro(Degree,int);
00293
00295
00298 vtkSetClampMacro(MaximumNumberOfSquawks,int,0,VTK_LARGE_INTEGER);
00299 vtkGetMacro(MaximumNumberOfSquawks,int);
00301
00302 protected:
00303 vtkDecimate();
00304 ~vtkDecimate();
00305
00306 void Execute();
00307
00308 float InitialFeatureAngle;
00309 float FeatureAngleIncrement;
00310 float MaximumFeatureAngle;
00311 int PreserveEdges;
00312 int BoundaryVertexDeletion;
00313 float InitialError;
00314 float ErrorIncrement;
00315 float MaximumError;
00316 float TargetReduction;
00317 int MaximumIterations;
00318 int MaximumSubIterations;
00319 float AspectRatio;
00320 int Degree;
00321 int Stats[VTK_NUMBER_STATISTICS];
00322 int GenerateErrorScalars;
00323 int MaximumNumberOfSquawks;
00324 int PreserveTopology;
00325 vtkIdList *Neighbors;
00326 vtkVertexArray *V;
00327 vtkTriArray *T;
00328
00329 void CreateOutput(vtkIdType numPts, vtkIdType numTris,
00330 vtkIdType numEliminated, vtkPointData *pd,
00331 vtkPoints *inPts);
00332 int BuildLoop(vtkIdType ptId, unsigned short int nTris, vtkIdType* tris);
00333 void EvaluateLoop(int& vtype, vtkIdType& numFEdges,
00334 vtkLocalVertexPtr fedges[]);
00335 int CanSplitLoop(vtkLocalVertexPtr fedges[2], vtkIdType numVerts,
00336 vtkLocalVertexPtr verts[], vtkIdType& n1,
00337 vtkLocalVertexPtr l1[], vtkIdType& n2,
00338 vtkLocalVertexPtr l2[], float& ar);
00339 void SplitLoop(vtkLocalVertexPtr fedges[2], vtkIdType numVerts,
00340 vtkLocalVertexPtr *verts, vtkIdType& n1,
00341 vtkLocalVertexPtr *l1, vtkIdType& n2, vtkLocalVertexPtr *l2);
00342 void Triangulate(vtkIdType numVerts, vtkLocalVertexPtr verts[]);
00343 int CheckError();
00344 private:
00345 vtkDecimate(const vtkDecimate&);
00346 void operator=(const vtkDecimate&);
00347 };
00348
00349 #endif
00350
00351