00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00089
#ifndef __vtkDecimatePro_h
00090
#define __vtkDecimatePro_h
00091
00092
#include "vtkPolyDataToPolyDataFilter.h"
00093
00094
#include "vtkCell.h"
00095
00096
class vtkFloatArray;
00097
class vtkPriorityQueue;
00098
00099 class VTK_GRAPHICS_EXPORT vtkDecimatePro :
public vtkPolyDataToPolyDataFilter
00100 {
00101
public:
00102 vtkTypeRevisionMacro(vtkDecimatePro,
vtkPolyDataToPolyDataFilter);
00103
void PrintSelf(ostream& os,
vtkIndent indent);
00104
00111
static vtkDecimatePro *
New();
00112
00114
00120 vtkSetClampMacro(TargetReduction,
float,0.0,1.0);
00121 vtkGetMacro(TargetReduction,
float);
00123
00125
00128 vtkSetMacro(PreserveTopology,
int);
00129 vtkGetMacro(PreserveTopology,
int);
00130 vtkBooleanMacro(PreserveTopology,
int);
00132
00134
00137 vtkSetClampMacro(FeatureAngle,
float,0.0,180.0);
00138 vtkGetMacro(FeatureAngle,
float);
00140
00142
00146 vtkSetMacro(Splitting,
int);
00147 vtkGetMacro(Splitting,
int);
00148 vtkBooleanMacro(Splitting,
int);
00150
00152
00155 vtkSetClampMacro(SplitAngle,
float,0.0,180.0);
00156 vtkGetMacro(SplitAngle,
float);
00158
00160
00166 vtkSetMacro(PreSplitMesh,
int);
00167 vtkGetMacro(PreSplitMesh,
int);
00168 vtkBooleanMacro(PreSplitMesh,
int);
00170
00172
00176 vtkSetClampMacro(MaximumError,
float,0.0,VTK_LARGE_FLOAT);
00177 vtkGetMacro(MaximumError,
float);
00179
00181
00188 vtkSetMacro(AccumulateError,
int);
00189 vtkGetMacro(AccumulateError,
int);
00190 vtkBooleanMacro(AccumulateError,
int);
00192
00194
00198 vtkSetMacro(ErrorIsAbsolute,
int);
00199 vtkGetMacro(ErrorIsAbsolute,
int);
00201
00203
00204 vtkSetClampMacro(AbsoluteError,
float,0.0,VTK_LARGE_FLOAT);
00205 vtkGetMacro(AbsoluteError,
float);
00207
00209
00211 vtkSetMacro(BoundaryVertexDeletion,
int);
00212 vtkGetMacro(BoundaryVertexDeletion,
int);
00213 vtkBooleanMacro(BoundaryVertexDeletion,
int);
00215
00217
00221 vtkSetClampMacro(Degree,
int,25,VTK_CELL_SIZE);
00222 vtkGetMacro(Degree,
int);
00224
00226
00229 vtkSetClampMacro(InflectionPointRatio,
float,1.001,VTK_LARGE_FLOAT);
00230 vtkGetMacro(InflectionPointRatio,
float);
00232
00233
00239
vtkIdType GetNumberOfInflectionPoints();
00240
00245
void GetInflectionPoints(
float *inflectionPoints);
00246
00252
float *GetInflectionPoints();
00253
00254
protected:
00255 vtkDecimatePro();
00256 ~vtkDecimatePro();
00257
00258
void Execute();
00259
00260 float TargetReduction;
00261 float FeatureAngle;
00262 float MaximumError;
00263 float AbsoluteError;
00264 int ErrorIsAbsolute;
00265 int AccumulateError;
00266 float SplitAngle;
00267 int Splitting;
00268 int PreSplitMesh;
00269 int BoundaryVertexDeletion;
00270 int PreserveTopology;
00271 int Degree;
00272 float InflectionPointRatio;
00273 vtkFloatArray *InflectionPoints;
00274
00275
00276 vtkIdList *Neighbors;
00277 vtkPriorityQueue *EdgeLengths;
00278
00279
void SplitMesh();
00280
int EvaluateVertex(
vtkIdType ptId,
unsigned short int numTris,
00281
vtkIdType *tris,
vtkIdType fedges[2]);
00282
vtkIdType FindSplit(
int type,
vtkIdType fedges[2],
vtkIdType& pt1,
00283
vtkIdType& pt2,
vtkIdList *CollapseTris);
00284
int IsValidSplit(
int index);
00285
void SplitLoop(
vtkIdType fedges[2],
vtkIdType& n1,
vtkIdType *l1,
00286
vtkIdType& n2,
vtkIdType *l2);
00287
void SplitVertex(
vtkIdType ptId,
int type,
unsigned short int numTris,
00288
vtkIdType *tris,
int insert);
00289
int CollapseEdge(
int type,
vtkIdType ptId,
vtkIdType collapseId,
00290
vtkIdType pt1,
vtkIdType pt2,
vtkIdList *CollapseTris);
00291
void DistributeError(
float error);
00292
00293
00294
00295
00296
00297
00298
00299 class LocalVertex
00300 {
00301
public:
00302 vtkIdType id;
00303 float x[3];
00304 float FAngle;
00305 };
00306 typedef LocalVertex *
LocalVertexPtr;
00307
00308 class LocalTri
00309 {
00310
public:
00311 vtkIdType id;
00312 float area;
00313 float n[3];
00314 vtkIdType verts[3];
00315 };
00316 typedef LocalTri *
LocalTriPtr;
00317
00318
class VertexArray;
00319
friend class VertexArray;
00320 class VertexArray {
00321
public:
00322 VertexArray(
const vtkIdType sz)
00323 {this->MaxId = -1; this->Array =
new LocalVertex[sz];};
00324 ~
VertexArray()
00325 {
00326
if (this->Array)
00327 {
00328
delete [] this->Array;
00329 }
00330 };
00331 vtkIdType GetNumberOfVertices() {
return this->MaxId + 1;};
00332 void InsertNextVertex(
LocalVertex& v)
00333 {this->MaxId++; this->Array[this->MaxId] = v;};
00334 LocalVertex& GetVertex(
vtkIdType i) {
return this->Array[i];};
00335 void Reset() {this->MaxId = -1;};
00336
00337 LocalVertex *Array;
00338 vtkIdType MaxId;
00339 };
00340
00341
class TriArray;
00342
friend class TriArray;
00343 class TriArray {
00344
public:
00345 TriArray(
const vtkIdType sz)
00346 {this->MaxId = -1; this->Array =
new LocalTri[sz];};
00347 ~
TriArray()
00348 {
00349
if (this->Array)
00350 {
00351
delete [] this->Array;
00352 }
00353 };
00354 vtkIdType GetNumberOfTriangles() {
return this->MaxId + 1;};
00355 void InsertNextTriangle(
LocalTri& t)
00356 {this->MaxId++; this->Array[this->MaxId] = t;};
00357 LocalTri& GetTriangle(
vtkIdType i) {
return this->Array[i];};
00358 void Reset() {this->MaxId = -1;};
00359
00360 LocalTri *Array;
00361 vtkIdType MaxId;
00362 };
00363
00364
00365
00366
private:
00367
void InitializeQueue(
vtkIdType numPts);
00368
void DeleteQueue();
00369
void Insert(
vtkIdType id,
float error= -1.0);
00370
int Pop(
float &error);
00371
float DeleteId(
vtkIdType id);
00372
void Reset();
00373
00374
vtkPriorityQueue *Queue;
00375
vtkFloatArray *VertexError;
00376
00377
VertexArray *V;
00378
TriArray *T;
00379
00380
00381
vtkPolyData *Mesh;
00382
float Pt[3];
00383
float Normal[3];
00384
float LoopArea;
00385
float CosAngle;
00386
float Tolerance;
00387
float X[3];
00388
int NumCollapses;
00389
int NumMerges;
00390
int Split;
00391
int VertexDegree;
00392
vtkIdType NumberOfRemainingTris;
00393
float TheSplitAngle;
00394
int SplitState;
00395
float Error;
00396
00397
private:
00398 vtkDecimatePro(
const vtkDecimatePro&);
00399
void operator=(
const vtkDecimatePro&);
00400 };
00401
00402
#endif
00403
00404