VTK
vtkGreedyTerrainDecimation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGreedyTerrainDecimation.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
69 #ifndef vtkGreedyTerrainDecimation_h
70 #define vtkGreedyTerrainDecimation_h
71 
72 #include "vtkFiltersHybridModule.h" // For export macro
73 #include "vtkPolyDataAlgorithm.h"
74 
75 class vtkPriorityQueue;
76 class vtkDataArray;
77 class vtkPointData;
78 class vtkIdList;
79 class vtkDoubleArray;
80 class vtkFloatArray;
81 
82 //PIMPL Encapsulation for STL containers
83 class vtkGreedyTerrainDecimationTerrainInfoType;
84 class vtkGreedyTerrainDecimationPointInfoType;
85 
86 #define VTK_ERROR_NUMBER_OF_TRIANGLES 0
87 #define VTK_ERROR_SPECIFIED_REDUCTION 1
88 #define VTK_ERROR_ABSOLUTE 2
89 #define VTK_ERROR_RELATIVE 3
90 
92 {
93 public:
95  void PrintSelf(ostream& os, vtkIndent indent);
96 
99 
101 
106  vtkSetClampMacro(ErrorMeasure,int,VTK_ERROR_NUMBER_OF_TRIANGLES,VTK_ERROR_RELATIVE);
107  vtkGetMacro(ErrorMeasure,int);
109  {this->SetErrorMeasure(VTK_ERROR_NUMBER_OF_TRIANGLES);}
111  {this->SetErrorMeasure(VTK_ERROR_SPECIFIED_REDUCTION);}
113  {this->SetErrorMeasure(VTK_ERROR_ABSOLUTE);}
115  {this->SetErrorMeasure(VTK_ERROR_RELATIVE);}
117 
119 
123  vtkSetClampMacro(NumberOfTriangles,vtkIdType,2,VTK_ID_MAX);
124  vtkGetMacro(NumberOfTriangles,vtkIdType);
126 
128 
131  vtkSetClampMacro(Reduction,double,0.0,1.0);
132  vtkGetMacro(Reduction,double);
134 
136 
140  vtkSetClampMacro(AbsoluteError,double,0.0,VTK_DOUBLE_MAX);
141  vtkGetMacro(AbsoluteError,double);
143 
145 
149  vtkSetClampMacro(RelativeError,double,0.0,VTK_DOUBLE_MAX);
150  vtkGetMacro(RelativeError,double);
152 
154 
156  vtkSetMacro(BoundaryVertexDeletion,int);
157  vtkGetMacro(BoundaryVertexDeletion,int);
158  vtkBooleanMacro(BoundaryVertexDeletion,int);
160 
162 
163  vtkSetMacro(ComputeNormals, int);
164  vtkGetMacro(ComputeNormals, int);
165  vtkBooleanMacro(ComputeNormals, int);
167 
168 protected:
171 
174 
177  void ComputePointNormal(int i, int j, float n[3]);
178 
179  //ivars that the API addresses
182  double Reduction;
185  int BoundaryVertexDeletion; //Can we delete boundary vertices?
186 
187  //Used for convenience
194  double Tolerance;
196  int Dimensions[3];
197  double Origin[3];
198  double Spacing[3];
200  double Length;
201 
202  //Bookeeping arrays
203  vtkPriorityQueue *TerrainError; //errors for each pt in height field
204  vtkGreedyTerrainDecimationTerrainInfoType *TerrainInfo; //owning triangle for each pt
205  vtkGreedyTerrainDecimationPointInfoType *PointInfo; //map mesh pt id to input pt id
206 
207  //Make a guess at initial allocation
208  void EstimateOutputSize(const vtkIdType numInputPts, vtkIdType &numPts, vtkIdType &numTris);
209 
210  //Returns non-zero if the error measure is satisfied.
211  virtual int SatisfiesErrorMeasure(double error);
212 
213  //Insert all the boundary vertices into the TIN
214  void InsertBoundaryVertices();
215 
216  //Insert a point into the triangulation; get a point from the triangulation
217  vtkIdType AddPointToTriangulation(vtkIdType inputPtId);
218  vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3]);
219  double *GetPoint(vtkIdType id);
220  void GetPoint(vtkIdType id, double x[3]);
221 
222  //Helper functions
223  void GetTerrainPoint(int i, int j, double x[3]);
224  void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2]);
225  int InCircle (double x[3], double x1[3], double x2[3], double x3[3]);
226  vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri,
227  double tol, vtkIdType nei[3], vtkIdList *neighbors, int& status);
228  void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2,
229  vtkIdType tri, int depth);
230 
231  void UpdateTriangles(vtkIdType meshPtId); //update all points connected to this point
232  void UpdateTriangle(vtkIdType triId, vtkIdType p1, vtkIdType p2, vtkIdType p3);
233  void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[4]);
234 
235  int CharacterizeTriangle(int ij1[2], int ij2[2], int ij[3],
236  int* &min, int* &max, int* &midL, int* &midR,
237  int* &mid, int mid2[2], double h[3], double &hMin, double &hMax,
238  double &hL, double &hR);
239 
240 private:
241  vtkGreedyTerrainDecimation(const vtkGreedyTerrainDecimation&); // Not implemented.
242  void operator=(const vtkGreedyTerrainDecimation&); // Not implemented.
243 
244 };
245 
246 #endif
#define VTK_ERROR_SPECIFIED_REDUCTION
virtual int FillInputPortInformation(int port, vtkInformation *info)
represent and manipulate point attribute data
Definition: vtkPointData.h:36
#define VTK_DOUBLE_MAX
Definition: vtkType.h:140
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
vtkGreedyTerrainDecimationPointInfoType * PointInfo
int vtkIdType
Definition: vtkType.h:247
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
dynamic, self-adjusting array of double
a list of ids arranged in priority order
static vtkPolyDataAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent)
Superclass for algorithms that produce only polydata as output.
#define VTK_ERROR_ABSOLUTE
a simple class to control print indentation
Definition: vtkIndent.h:38
#define VTKFILTERSHYBRID_EXPORT
list of point or cell ids
Definition: vtkIdList.h:35
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkGreedyTerrainDecimationTerrainInfoType * TerrainInfo
#define VTK_ERROR_NUMBER_OF_TRIANGLES
#define VTK_ID_MAX
Definition: vtkType.h:251
#define VTK_ERROR_RELATIVE
Store zero or more vtkInformation instances.
reduce height field (represented as image) to reduced TIN
#define max(a, b)