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