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
00099 #ifndef __vtkDecimate_h
00100 #define __vtkDecimate_h
00101
00102 #include "vtkPolyDataToPolyDataFilter.h"
00103
00104 #include "vtkCell.h"
00105
00106 #define VTK_NUMBER_STATISTICS 12
00107
00108 class vtkIdList;
00109
00110 class VTK_PATENTED_EXPORT vtkDecimate : public vtkPolyDataToPolyDataFilter
00111 {
00112 public:
00113 static vtkDecimate *New();
00114 vtkTypeRevisionMacro(vtkDecimate,vtkPolyDataToPolyDataFilter);
00115 void PrintSelf(ostream& os, vtkIndent indent);
00116
00118
00120 vtkSetClampMacro(InitialError,double,0.0,1.0);
00121 vtkGetMacro(InitialError,double);
00123
00125
00127 vtkSetClampMacro(ErrorIncrement,double,0.0,1.0);
00128 vtkGetMacro(ErrorIncrement,double);
00130
00132
00134 vtkSetClampMacro(MaximumError,double,0.0,1.0);
00135 vtkGetMacro(MaximumError,double);
00137
00139
00142 vtkSetClampMacro(TargetReduction,double,0.0,1.0);
00143 vtkGetMacro(TargetReduction,double);
00145
00147
00149 vtkSetClampMacro(MaximumIterations,int,0,VTK_LARGE_INTEGER);
00150 vtkGetMacro(MaximumIterations,int);
00152
00154
00156 vtkSetClampMacro(MaximumSubIterations,int,1,VTK_LARGE_INTEGER);
00157 vtkGetMacro(MaximumSubIterations,int);
00159
00161
00162 vtkSetClampMacro(InitialFeatureAngle,double,0.0,180.0);
00163 vtkGetMacro(InitialFeatureAngle,double);
00165
00167
00169 vtkSetClampMacro(FeatureAngleIncrement,double,0.0,180.0);
00170 vtkGetMacro(FeatureAngleIncrement,double);
00172
00174
00175 vtkSetClampMacro(MaximumFeatureAngle,double,0.0,180.0);
00176 vtkGetMacro(MaximumFeatureAngle,double);
00178
00180
00181 vtkSetMacro(GenerateErrorScalars,int);
00182 vtkGetMacro(GenerateErrorScalars,int);
00183 vtkBooleanMacro(GenerateErrorScalars,int);
00185
00187
00188 vtkSetMacro(PreserveEdges,int);
00189 vtkGetMacro(PreserveEdges,int);
00190 vtkBooleanMacro(PreserveEdges,int);
00192
00194
00195 vtkSetMacro(BoundaryVertexDeletion,int);
00196 vtkGetMacro(BoundaryVertexDeletion,int);
00197 vtkBooleanMacro(BoundaryVertexDeletion,int);
00199
00201
00202 vtkSetClampMacro(AspectRatio,double,1.0,1000.0);
00203 vtkGetMacro(AspectRatio,double);
00205
00207
00209 vtkSetMacro(PreserveTopology,int);
00210 vtkGetMacro(PreserveTopology,int);
00211 vtkBooleanMacro(PreserveTopology,int);
00213
00215
00219 vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
00220 vtkGetMacro(Degree,int);
00222
00224
00227 vtkSetClampMacro(MaximumNumberOfSquawks,int,0,VTK_LARGE_INTEGER);
00228 vtkGetMacro(MaximumNumberOfSquawks,int);
00230
00231 protected:
00232
00233
00234
00235
00236
00237
00238
00239 class LocalVertex
00240 {
00241 public:
00242 vtkIdType id;
00243 double x[3];
00244 double FAngle;
00245 int deRefs;
00246 int newRefs;
00247 };
00248 typedef LocalVertex *LocalVertexPtr;
00249
00250 class LocalTri
00251 {
00252 public:
00253 vtkIdType id;
00254 double area;
00255 double n[3];
00256 vtkIdType verts[3];
00257 };
00258 typedef LocalTri *LocalTriPtr;
00259
00260 class VertexArray;
00261 friend class VertexArray;
00262 class VertexArray {
00263 public:
00264 VertexArray(const vtkIdType sz)
00265 {this->MaxId = -1; this->Array = new LocalVertex[sz];};
00266 ~VertexArray() {if (this->Array) {delete [] this->Array;}};
00267 vtkIdType GetNumberOfVertices() {return this->MaxId + 1;};
00268 void InsertNextVertex(LocalVertex& v)
00269 {this->MaxId++; this->Array[this->MaxId] = v;};
00270 LocalVertex& GetVertex(vtkIdType i) {return this->Array[i];};
00271 void Reset() {this->MaxId = -1;};
00272
00273 LocalVertex *Array;
00274 vtkIdType MaxId;
00275 };
00276
00277 class TriArray;
00278 friend class TriArray;
00279 class TriArray {
00280 public:
00281 TriArray(const vtkIdType sz)
00282 {this->MaxId = -1; this->Array = new LocalTri[sz];};
00283 ~TriArray() {if (this->Array) {delete [] this->Array;}};
00284 vtkIdType GetNumberOfTriangles() {return this->MaxId + 1;};
00285 void InsertNextTriangle(LocalTri& t)
00286 {this->MaxId++; this->Array[this->MaxId] = t;};
00287 LocalTri& GetTriangle(vtkIdType i) {return this->Array[i];};
00288 void Reset() {this->MaxId = -1;};
00289
00290 LocalTri *Array;
00291 vtkIdType MaxId;
00292 };
00293
00294
00295
00296 vtkDecimate();
00297 ~vtkDecimate();
00298
00299 void Execute();
00300
00301 double InitialFeatureAngle;
00302 double FeatureAngleIncrement;
00303 double MaximumFeatureAngle;
00304 int PreserveEdges;
00305 int BoundaryVertexDeletion;
00306 double InitialError;
00307 double ErrorIncrement;
00308 double MaximumError;
00309 double TargetReduction;
00310 int MaximumIterations;
00311 int MaximumSubIterations;
00312 double AspectRatio;
00313 int Degree;
00314 int Stats[VTK_NUMBER_STATISTICS];
00315 int GenerateErrorScalars;
00316 int MaximumNumberOfSquawks;
00317 int PreserveTopology;
00318 vtkIdList *Neighbors;
00319 VertexArray *V;
00320 TriArray *T;
00321
00322 void CreateOutput(vtkIdType numPts, vtkIdType numTris,
00323 vtkIdType numEliminated, vtkPointData *pd,
00324 vtkPoints *inPts);
00325 int BuildLoop(vtkIdType ptId, unsigned short int nTris, vtkIdType* tris);
00326 void EvaluateLoop(int& vtype, vtkIdType& numFEdges,
00327 LocalVertexPtr fedges[]);
00328 int CanSplitLoop(LocalVertexPtr fedges[2], vtkIdType numVerts,
00329 LocalVertexPtr verts[], vtkIdType& n1,
00330 LocalVertexPtr l1[], vtkIdType& n2,
00331 LocalVertexPtr l2[], double& ar);
00332 void SplitLoop(LocalVertexPtr fedges[2], vtkIdType numVerts,
00333 LocalVertexPtr *verts, vtkIdType& n1,
00334 LocalVertexPtr *l1, vtkIdType& n2, LocalVertexPtr *l2);
00335 void Triangulate(vtkIdType numVerts, LocalVertexPtr verts[]);
00336 int CheckError();
00337 private:
00338 vtkDecimate(const vtkDecimate&);
00339 void operator=(const vtkDecimate&);
00340 };
00341
00342 #endif
00343
00344