00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00069 #ifndef __vtkGreedyTerrainDecimation_h
00070 #define __vtkGreedyTerrainDecimation_h
00071
00072 #include "vtkStructuredPointsToPolyDataFilter.h"
00073
00074 class vtkPriorityQueue;
00075 class vtkDataArray;
00076 class vtkPointData;
00077 class vtkIdList;
00078 class vtkDoubleArray;
00079
00080
00081 class vtkGreedyTerrainDecimationTerrainInfoType;
00082 class vtkGreedyTerrainDecimationPointInfoType;
00083
00084 #define VTK_ERROR_NUMBER_OF_TRIANGLES 0
00085 #define VTK_ERROR_SPECIFIED_REDUCTION 1
00086 #define VTK_ERROR_ABSOLUTE 2
00087 #define VTK_ERROR_RELATIVE 3
00088
00089 class VTK_HYBRID_EXPORT vtkGreedyTerrainDecimation : public vtkStructuredPointsToPolyDataFilter
00090 {
00091 public:
00092 vtkTypeRevisionMacro(vtkGreedyTerrainDecimation,vtkStructuredPointsToPolyDataFilter);
00093 void PrintSelf(ostream& os, vtkIndent indent);
00094
00096 static vtkGreedyTerrainDecimation* New();
00097
00099
00104 vtkSetClampMacro(ErrorMeasure,int,VTK_ERROR_NUMBER_OF_TRIANGLES,VTK_ERROR_RELATIVE);
00105 vtkGetMacro(ErrorMeasure,int);
00106 void SetErrorMeasureToNumberOfTriangles()
00107 {this->SetErrorMeasure(VTK_ERROR_NUMBER_OF_TRIANGLES);}
00108 void SetErrorMeasureToSpecifiedReduction()
00109 {this->SetErrorMeasure(VTK_ERROR_SPECIFIED_REDUCTION);}
00110 void SetErrorMeasureToAbsoluteError()
00111 {this->SetErrorMeasure(VTK_ERROR_ABSOLUTE);}
00112 void SetErrorMeasureToRelativeError()
00113 {this->SetErrorMeasure(VTK_ERROR_RELATIVE);}
00115
00117
00121 vtkSetClampMacro(NumberOfTriangles,vtkIdType,2,VTK_LONG_MAX);
00122 vtkGetMacro(NumberOfTriangles,vtkIdType);
00124
00126
00129 vtkSetClampMacro(Reduction,double,0.0,1.0);
00130 vtkGetMacro(Reduction,double);
00132
00134
00138 vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
00139 vtkGetMacro(AbsoluteError,double);
00141
00143
00147 vtkSetClampMacro(RelativeError,double,0.0,VTK_DOUBLE_MAX);
00148 vtkGetMacro(RelativeError,double);
00150
00152
00154 vtkSetMacro(BoundaryVertexDeletion,int);
00155 vtkGetMacro(BoundaryVertexDeletion,int);
00156 vtkBooleanMacro(BoundaryVertexDeletion,int);
00158
00159 protected:
00160 vtkGreedyTerrainDecimation();
00161 ~vtkGreedyTerrainDecimation();
00162
00163 void Execute();
00164
00165
00166 int ErrorMeasure;
00167 vtkIdType NumberOfTriangles;
00168 double Reduction;
00169 double AbsoluteError;
00170 double RelativeError;
00171 int BoundaryVertexDeletion;
00172
00173
00174 vtkPolyData *Mesh;
00175 vtkPointData *InputPD;
00176 vtkPointData *OutputPD;
00177 vtkDoubleArray *Points;
00178 vtkDataArray *Heights;
00179 vtkIdType CurrentPointId;
00180 double Tolerance;
00181 vtkIdList *Neighbors;
00182 int Dimensions[3];
00183 double Origin[3];
00184 double Spacing[3];
00185 vtkIdType MaximumNumberOfTriangles;
00186 double Length;
00187
00188
00189 vtkPriorityQueue *TerrainError;
00190 vtkGreedyTerrainDecimationTerrainInfoType *TerrainInfo;
00191 vtkGreedyTerrainDecimationPointInfoType *PointInfo;
00192
00193
00194 void EstimateOutputSize(const vtkIdType numInputPts, vtkIdType &numPts, vtkIdType &numTris);
00195
00196
00197 virtual int SatisfiesErrorMeasure(double error);
00198
00199
00200 void InsertBoundaryVertices();
00201
00202
00203 vtkIdType AddPointToTriangulation(vtkIdType inputPtId);
00204 vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3]);
00205 double *GetPoint(vtkIdType id);
00206 void GetPoint(vtkIdType id, double x[3]);
00207
00208
00209 void GetTerrainPoint(int i, int j, double x[3]);
00210 void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2]);
00211 int InCircle (double x[3], double x1[3], double x2[3], double x3[3]);
00212 vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri,
00213 double tol, vtkIdType nei[3], vtkIdList *neighbors, int& status);
00214 void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2,
00215 vtkIdType tri);
00216
00217 void UpdateTriangles(vtkIdType meshPtId);
00218 void UpdateTriangle(vtkIdType triId, vtkIdType p1, vtkIdType p2, vtkIdType p3);
00219 void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[4]);
00220
00221 int CharacterizeTriangle(int ij1[2], int ij2[2], int ij[3],
00222 int* &min, int* &max, int* &midL, int* &midR,
00223 int* &mid, int mid2[2], double h[3], double &hMin, double &hMax,
00224 double &hL, double &hR);
00225
00226 private:
00227 vtkGreedyTerrainDecimation(const vtkGreedyTerrainDecimation&);
00228 void operator=(const vtkGreedyTerrainDecimation&);
00229
00230 };
00231
00232 #endif
00233