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
00112 #ifndef __vtkDecimate_h
00113 #define __vtkDecimate_h
00114
00115 #include "vtkPolyDataToPolyDataFilter.h"
00116 #include "vtkMath.h"
00117 #include "vtkTriangle.h"
00118 #include "vtkPlane.h"
00119 #include "vtkPolygon.h"
00120 #include "vtkLine.h"
00121
00122 #define VTK_NUMBER_STATISTICS 12
00123
00124
00125
00126 typedef struct _vtkLocalVertex
00127 {
00128 int id;
00129 float x[3];
00130 float FAngle;
00131 int deRefs;
00132 int newRefs;
00133 } vtkLocalVertex, *vtkLocalVertexPtr;
00134
00135 typedef struct _vtkLocalTri
00136 {
00137 int id;
00138 float area;
00139 float n[3];
00140 int verts[3];
00141 } vtkLocalTri, *vtkLocalTriPtr;
00142
00143
00144
00145
00146 class vtkVertexArray {
00147 public:
00148 vtkVertexArray(const int sz)
00149 {this->MaxId = -1; this->Array = new vtkLocalVertex[sz];};
00150 ~vtkVertexArray() {if (this->Array) {delete [] this->Array;}};
00151 int GetNumberOfVertices() {return this->MaxId + 1;};
00152 void InsertNextVertex(vtkLocalVertex& v)
00153 {this->MaxId++; this->Array[this->MaxId] = v;};
00154 vtkLocalVertex& GetVertex(int i) {return this->Array[i];};
00155 void Reset() {this->MaxId = -1;};
00156
00157 vtkLocalVertex *Array;
00158 int MaxId;
00159 };
00160
00161 class vtkTriArray {
00162 public:
00163 vtkTriArray(const int sz)
00164 {this->MaxId = -1; this->Array = new vtkLocalTri[sz];};
00165 ~vtkTriArray() {if (this->Array) {delete [] this->Array;}};
00166 int GetNumberOfTriangles() {return this->MaxId + 1;};
00167 void InsertNextTriangle(vtkLocalTri& t)
00168 {this->MaxId++; this->Array[this->MaxId] = t;};
00169 vtkLocalTri& GetTriangle(int i) {return this->Array[i];};
00170 void Reset() {this->MaxId = -1;};
00171
00172 vtkLocalTri *Array;
00173 int MaxId;
00174 };
00175
00176
00177
00178
00179 class VTK_EXPORT vtkDecimate : public vtkPolyDataToPolyDataFilter
00180 {
00181 public:
00182 static vtkDecimate *New();
00183 vtkTypeMacro(vtkDecimate,vtkPolyDataToPolyDataFilter);
00184 void PrintSelf(ostream& os, vtkIndent indent);
00185
00188 vtkSetClampMacro(InitialError,float,0.0,1.0);
00189 vtkGetMacro(InitialError,float);
00190
00193 vtkSetClampMacro(ErrorIncrement,float,0.0,1.0);
00194 vtkGetMacro(ErrorIncrement,float);
00195
00198 vtkSetClampMacro(MaximumError,float,0.0,1.0);
00199 vtkGetMacro(MaximumError,float);
00200
00204 vtkSetClampMacro(TargetReduction,float,0.0,1.0);
00205 vtkGetMacro(TargetReduction,float);
00206
00209 vtkSetClampMacro(MaximumIterations,int,0,VTK_LARGE_INTEGER);
00210 vtkGetMacro(MaximumIterations,int);
00211
00214 vtkSetClampMacro(MaximumSubIterations,int,1,VTK_LARGE_INTEGER);
00215 vtkGetMacro(MaximumSubIterations,int);
00216
00218 vtkSetClampMacro(InitialFeatureAngle,float,0.0,180.0);
00219 vtkGetMacro(InitialFeatureAngle,float);
00220
00223 vtkSetClampMacro(FeatureAngleIncrement,float,0.0,180.0);
00224 vtkGetMacro(FeatureAngleIncrement,float);
00225
00227 vtkSetClampMacro(MaximumFeatureAngle,float,0.0,180.0);
00228 vtkGetMacro(MaximumFeatureAngle,float);
00229
00231 vtkSetMacro(GenerateErrorScalars,int);
00232 vtkGetMacro(GenerateErrorScalars,int);
00233 vtkBooleanMacro(GenerateErrorScalars,int);
00234
00236 vtkSetMacro(PreserveEdges,int);
00237 vtkGetMacro(PreserveEdges,int);
00238 vtkBooleanMacro(PreserveEdges,int);
00239
00241 vtkSetMacro(BoundaryVertexDeletion,int);
00242 vtkGetMacro(BoundaryVertexDeletion,int);
00243 vtkBooleanMacro(BoundaryVertexDeletion,int);
00244
00246 vtkSetClampMacro(AspectRatio,float,1.0,1000.0);
00247 vtkGetMacro(AspectRatio,float);
00248
00251 vtkSetMacro(PreserveTopology,int);
00252 vtkGetMacro(PreserveTopology,int);
00253 vtkBooleanMacro(PreserveTopology,int);
00254
00259 vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00260 vtkGetMacro(Degree,int);
00261
00265 vtkSetClampMacro(MaximumNumberOfSquawks,int,0,VTK_LARGE_INTEGER);
00266 vtkGetMacro(MaximumNumberOfSquawks,int);
00267
00268 protected:
00269 vtkDecimate();
00270 ~vtkDecimate();
00271 vtkDecimate(const vtkDecimate&) {};
00272 void operator=(const vtkDecimate&) {};
00273
00274 void Execute();
00275
00276 float InitialFeatureAngle;
00277 float FeatureAngleIncrement;
00278 float MaximumFeatureAngle;
00279 int PreserveEdges;
00280 int BoundaryVertexDeletion;
00281 float InitialError;
00282 float ErrorIncrement;
00283 float MaximumError;
00284 float TargetReduction;
00285 int MaximumIterations;
00286 int MaximumSubIterations;
00287 float AspectRatio;
00288 int Degree;
00289 int Stats[VTK_NUMBER_STATISTICS];
00290 int GenerateErrorScalars;
00291 int MaximumNumberOfSquawks;
00292 int PreserveTopology;
00293 vtkIdList *Neighbors;
00294 vtkVertexArray *V;
00295 vtkTriArray *T;
00296
00297 void CreateOutput(int numPts, int numTris, int numEliminated,
00298 vtkPointData *pd, vtkPoints *inPts);
00299 int BuildLoop(int ptId, unsigned short int nTris, int* tris);
00300 void EvaluateLoop(int& vtype, int& numFEdges, vtkLocalVertexPtr fedges[]);
00301 int CanSplitLoop(vtkLocalVertexPtr fedges[2], int numVerts,
00302 vtkLocalVertexPtr verts[], int& n1, vtkLocalVertexPtr l1[],
00303 int& n2, vtkLocalVertexPtr l2[], float& ar);
00304 void SplitLoop(vtkLocalVertexPtr fedges[2], int numVerts,
00305 vtkLocalVertexPtr *verts, int& n1, vtkLocalVertexPtr *l1,
00306 int& n2, vtkLocalVertexPtr *l2);
00307 void Triangulate(int numVerts, vtkLocalVertexPtr verts[]);
00308 int CheckError();
00309 };
00310
00311 #endif
00312
00313