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 
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
215 
216  //Insert a point into the triangulation; get a point from the triangulation
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
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
vtkGreedyTerrainDecimation::CharacterizeTriangle
int CharacterizeTriangle(int ij1[2], int ij2[2], int ij[3], int *&min, int *&max, int *&midL, int *&midR, int *&mid, int mid2[2], double h[3], double &hMin, double &hMax, double &hL, double &hR)
vtkGreedyTerrainDecimation::PointInfo
vtkGreedyTerrainDecimationPointInfoType * PointInfo
Definition: vtkGreedyTerrainDecimation.h:205
vtkGreedyTerrainDecimation::GetPoint
void GetPoint(vtkIdType id, double x[3])
vtkGreedyTerrainDecimation::SetErrorMeasureToNumberOfTriangles
void SetErrorMeasureToNumberOfTriangles()
Definition: vtkGreedyTerrainDecimation.h:108
vtkGreedyTerrainDecimation::NumberOfTriangles
vtkIdType NumberOfTriangles
Definition: vtkGreedyTerrainDecimation.h:181
vtkgl::h
GLfloat GLfloat GLfloat GLfloat h
Definition: vtkgl.h:14364
vtkGreedyTerrainDecimation::BoundaryVertexDeletion
int BoundaryVertexDeletion
Definition: vtkGreedyTerrainDecimation.h:185
vtkGreedyTerrainDecimation::GetTerrainPoint
void GetTerrainPoint(int i, int j, double x[3])
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:37
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:49
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkGreedyTerrainDecimation::UpdateTriangle
void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[4])
vtkGreedyTerrainDecimation::UpdateTriangles
void UpdateTriangles(vtkIdType meshPtId)
vtkGreedyTerrainDecimation::OutputPD
vtkPointData * OutputPD
Definition: vtkGreedyTerrainDecimation.h:190
vtkGreedyTerrainDecimation::AddPointToTriangulation
vtkIdType AddPointToTriangulation(vtkIdType inputPtId)
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkGreedyTerrainDecimation::RelativeError
double RelativeError
Definition: vtkGreedyTerrainDecimation.h:184
vtkgl::n
GLclampd n
Definition: vtkgl.h:14370
vtkPriorityQueue
a list of ids arranged in priority order
Definition: vtkPriorityQueue.h:46
vtkGreedyTerrainDecimation::vtkGreedyTerrainDecimation
vtkGreedyTerrainDecimation()
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkGreedyTerrainDecimation::InsertBoundaryVertices
void InsertBoundaryVertices()
VTK_ERROR_ABSOLUTE
#define VTK_ERROR_ABSOLUTE
Definition: vtkGreedyTerrainDecimation.h:88
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkGreedyTerrainDecimation::Heights
vtkDataArray * Heights
Definition: vtkGreedyTerrainDecimation.h:192
vtkGreedyTerrainDecimation::SetErrorMeasureToAbsoluteError
void SetErrorMeasureToAbsoluteError()
Definition: vtkGreedyTerrainDecimation.h:112
vtkGreedyTerrainDecimation::MaximumNumberOfTriangles
vtkIdType MaximumNumberOfTriangles
Definition: vtkGreedyTerrainDecimation.h:199
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:30
vtkGreedyTerrainDecimation::InsertNextPoint
vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3])
vtkGreedyTerrainDecimation::ComputePointNormal
void ComputePointNormal(int i, int j, float n[3])
vtkGreedyTerrainDecimation::AbsoluteError
double AbsoluteError
Definition: vtkGreedyTerrainDecimation.h:183
vtkGreedyTerrainDecimation::EstimateOutputSize
void EstimateOutputSize(const vtkIdType numInputPts, vtkIdType &numPts, vtkIdType &numTris)
vtkPolyDataAlgorithm.h
vtkGreedyTerrainDecimation::ComputeImageCoordinates
void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2])
vtkGreedyTerrainDecimation::InputPD
vtkPointData * InputPD
Definition: vtkGreedyTerrainDecimation.h:189
vtkgl::depth
GLint GLint GLsizei GLsizei GLsizei depth
Definition: vtkgl.h:11316
vtkX3D::port
@ port
Definition: vtkX3D.h:447
vtkSetClampMacro
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:143
vtkGreedyTerrainDecimation
reduce height field (represented as image) to reduced TIN
Definition: vtkGreedyTerrainDecimation.h:92
VTKFILTERSHYBRID_EXPORT
#define VTKFILTERSHYBRID_EXPORT
Definition: vtkFiltersHybridModule.h:15
vtkGreedyTerrainDecimation::Neighbors
vtkIdList * Neighbors
Definition: vtkGreedyTerrainDecimation.h:195
vtkGreedyTerrainDecimation::GetPoint
double * GetPoint(vtkIdType id)
vtkGreedyTerrainDecimation::Points
vtkDoubleArray * Points
Definition: vtkGreedyTerrainDecimation.h:191
vtkGreedyTerrainDecimation::FillInputPortInformation
virtual int FillInputPortInformation(int port, vtkInformation *info)
vtkGreedyTerrainDecimation::Length
double Length
Definition: vtkGreedyTerrainDecimation.h:200
vtkGreedyTerrainDecimation::ComputeNormals
int ComputeNormals
Definition: vtkGreedyTerrainDecimation.h:175
vtkGreedyTerrainDecimation::UpdateTriangle
void UpdateTriangle(vtkIdType triId, vtkIdType p1, vtkIdType p2, vtkIdType p3)
vtkGreedyTerrainDecimation::TerrainError
vtkPriorityQueue * TerrainError
Definition: vtkGreedyTerrainDecimation.h:203
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkGreedyTerrainDecimation::CurrentPointId
vtkIdType CurrentPointId
Definition: vtkGreedyTerrainDecimation.h:193
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkGreedyTerrainDecimation::InCircle
int InCircle(double x[3], double x1[3], double x2[3], double x3[3])
vtkGreedyTerrainDecimation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkGreedyTerrainDecimation::TerrainInfo
vtkGreedyTerrainDecimationTerrainInfoType * TerrainInfo
Definition: vtkGreedyTerrainDecimation.h:204
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkGreedyTerrainDecimation::Reduction
double Reduction
Definition: vtkGreedyTerrainDecimation.h:182
vtkFiltersHybridModule.h
vtkGreedyTerrainDecimation::ErrorMeasure
int ErrorMeasure
Definition: vtkGreedyTerrainDecimation.h:180
vtkGreedyTerrainDecimation::CheckEdge
void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2, vtkIdType tri, int depth)
vtkGreedyTerrainDecimation::SetErrorMeasureToSpecifiedReduction
void SetErrorMeasureToSpecifiedReduction()
Definition: vtkGreedyTerrainDecimation.h:110
VTK_ID_MAX
#define VTK_ID_MAX
Definition: vtkType.h:278
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkGreedyTerrainDecimation::SetErrorMeasureToRelativeError
void SetErrorMeasureToRelativeError()
Definition: vtkGreedyTerrainDecimation.h:114
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:49
vtkGreedyTerrainDecimation::Mesh
vtkPolyData * Mesh
Definition: vtkGreedyTerrainDecimation.h:188
vtkGreedyTerrainDecimation::Normals
vtkFloatArray * Normals
Definition: vtkGreedyTerrainDecimation.h:176
VTK_ERROR_NUMBER_OF_TRIANGLES
#define VTK_ERROR_NUMBER_OF_TRIANGLES
Definition: vtkGreedyTerrainDecimation.h:86
vtkGreedyTerrainDecimation::Tolerance
double Tolerance
Definition: vtkGreedyTerrainDecimation.h:194
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:142
vtkGreedyTerrainDecimation::FindTriangle
vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri, double tol, vtkIdType nei[3], vtkIdList *neighbors, int &status)
VTK_ERROR_RELATIVE
#define VTK_ERROR_RELATIVE
Definition: vtkGreedyTerrainDecimation.h:89
vtkGreedyTerrainDecimation::~vtkGreedyTerrainDecimation
~vtkGreedyTerrainDecimation()
vtkGreedyTerrainDecimation::SatisfiesErrorMeasure
virtual int SatisfiesErrorMeasure(double error)
vtkGreedyTerrainDecimation::RequestData
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:44
vtkGreedyTerrainDecimation::New
static vtkGreedyTerrainDecimation * New()
VTK_ERROR_SPECIFIED_REDUCTION
#define VTK_ERROR_SPECIFIED_REDUCTION
Definition: vtkGreedyTerrainDecimation.h:87