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