VTK  9.1.0
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 =========================================================================*/
86 #ifndef vtkGreedyTerrainDecimation_h
87 #define vtkGreedyTerrainDecimation_h
88 
89 #include "vtkFiltersHybridModule.h" // For export macro
90 #include "vtkPolyDataAlgorithm.h"
91 
92 class vtkPriorityQueue;
93 class vtkDataArray;
94 class vtkPointData;
95 class vtkIdList;
96 class vtkDoubleArray;
97 class vtkFloatArray;
98 
99 // PIMPL Encapsulation for STL containers
100 class vtkGreedyTerrainDecimationTerrainInfoType;
101 class vtkGreedyTerrainDecimationPointInfoType;
102 
103 #define VTK_ERROR_NUMBER_OF_TRIANGLES 0
104 #define VTK_ERROR_SPECIFIED_REDUCTION 1
105 #define VTK_ERROR_ABSOLUTE 2
106 #define VTK_ERROR_RELATIVE 3
107 
108 class VTKFILTERSHYBRID_EXPORT vtkGreedyTerrainDecimation : public vtkPolyDataAlgorithm
109 {
110 public:
112  void PrintSelf(ostream& os, vtkIndent indent) override;
113 
118 
120 
126  vtkSetClampMacro(ErrorMeasure, int, VTK_ERROR_NUMBER_OF_TRIANGLES, VTK_ERROR_RELATIVE);
127  vtkGetMacro(ErrorMeasure, int);
129  {
130  this->SetErrorMeasure(VTK_ERROR_NUMBER_OF_TRIANGLES);
131  }
133  {
134  this->SetErrorMeasure(VTK_ERROR_SPECIFIED_REDUCTION);
135  }
136  void SetErrorMeasureToAbsoluteError() { this->SetErrorMeasure(VTK_ERROR_ABSOLUTE); }
137  void SetErrorMeasureToRelativeError() { this->SetErrorMeasure(VTK_ERROR_RELATIVE); }
139 
141 
147  vtkSetClampMacro(NumberOfTriangles, vtkIdType, 2, VTK_ID_MAX);
148  vtkGetMacro(NumberOfTriangles, vtkIdType);
150 
152 
157  vtkSetClampMacro(Reduction, double, 0.0, 1.0);
158  vtkGetMacro(Reduction, double);
160 
162 
167  vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
168  vtkGetMacro(AbsoluteError, double);
170 
172 
178  vtkSetClampMacro(RelativeError, double, 0.0, VTK_DOUBLE_MAX);
179  vtkGetMacro(RelativeError, double);
181 
183 
187  vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
188  vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
189  vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
191 
193 
196  vtkSetMacro(ComputeNormals, vtkTypeBool);
197  vtkGetMacro(ComputeNormals, vtkTypeBool);
198  vtkBooleanMacro(ComputeNormals, vtkTypeBool);
200 
201 protected:
204 
207 
210  void ComputePointNormal(int i, int j, float n[3]);
211 
212  // ivars that the API addresses
215  double Reduction;
218  vtkTypeBool BoundaryVertexDeletion; // Can we delete boundary vertices?
219 
220  // Used for convenience
227  double Tolerance;
229  int Dimensions[3];
230  double Origin[3];
231  double Spacing[3];
233  double Length;
234 
235  // Bookkeeping arrays
236  vtkPriorityQueue* TerrainError; // errors for each pt in height field
237  vtkGreedyTerrainDecimationTerrainInfoType* TerrainInfo; // owning triangle for each pt
238  vtkGreedyTerrainDecimationPointInfoType* PointInfo; // map mesh pt id to input pt id
239 
240  // Make a guess at initial allocation
241  void EstimateOutputSize(const vtkIdType numInputPts, vtkIdType& numPts, vtkIdType& numTris);
242 
243  // Returns non-zero if the error measure is satisfied.
244  virtual int SatisfiesErrorMeasure(double error);
245 
246  // Insert all the boundary vertices into the TIN
248 
249  // Insert a point into the triangulation; get a point from the triangulation
251  vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3]);
252  double* GetPoint(vtkIdType id);
253  void GetPoint(vtkIdType id, double x[3]);
254 
255  // Helper functions
256  void GetTerrainPoint(int i, int j, double x[3]);
257  void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2]);
258  int InCircle(double x[3], double x1[3], double x2[3], double x3[3]);
259  vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri, double tol,
260  vtkIdType nei[3], vtkIdList* neighbors, int& status);
261  void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2, vtkIdType tri, int depth);
262 
263  void UpdateTriangles(vtkIdType meshPtId); // update all points connected to this point
265  void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[4]);
266 
267  int CharacterizeTriangle(int ij1[2], int ij2[2], int ij[3], int*& min, int*& max, int*& midL,
268  int*& midR, int*& mid, int mid2[2], double h[3], double& hMin, double& hMax, double& hL,
269  double& hR);
270 
271 private:
273  void operator=(const vtkGreedyTerrainDecimation&) = delete;
274 };
275 
276 #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::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGreedyTerrainDecimation::PointInfo
vtkGreedyTerrainDecimationPointInfoType * PointInfo
Definition: vtkGreedyTerrainDecimation.h:238
vtkGreedyTerrainDecimation::GetPoint
void GetPoint(vtkIdType id, double x[3])
vtkGreedyTerrainDecimation::SetErrorMeasureToNumberOfTriangles
void SetErrorMeasureToNumberOfTriangles()
Specify how to terminate the algorithm: either as an absolute number of triangles,...
Definition: vtkGreedyTerrainDecimation.h:128
vtkGreedyTerrainDecimation::NumberOfTriangles
vtkIdType NumberOfTriangles
Definition: vtkGreedyTerrainDecimation.h:214
vtkGreedyTerrainDecimation::GetTerrainPoint
void GetTerrainPoint(int i, int j, double x[3])
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:142
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:145
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkGreedyTerrainDecimation::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
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:223
vtkGreedyTerrainDecimation::AddPointToTriangulation
vtkIdType AddPointToTriangulation(vtkIdType inputPtId)
vtkGreedyTerrainDecimation::RelativeError
double RelativeError
Definition: vtkGreedyTerrainDecimation.h:217
vtkPriorityQueue
a list of ids arranged in priority order
Definition: vtkPriorityQueue.h:47
vtkGreedyTerrainDecimation::vtkGreedyTerrainDecimation
vtkGreedyTerrainDecimation()
vtkGreedyTerrainDecimation::InsertBoundaryVertices
void InsertBoundaryVertices()
VTK_ERROR_ABSOLUTE
#define VTK_ERROR_ABSOLUTE
Definition: vtkGreedyTerrainDecimation.h:105
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkGreedyTerrainDecimation::Heights
vtkDataArray * Heights
Definition: vtkGreedyTerrainDecimation.h:225
vtkGreedyTerrainDecimation::SetErrorMeasureToAbsoluteError
void SetErrorMeasureToAbsoluteError()
Specify how to terminate the algorithm: either as an absolute number of triangles,...
Definition: vtkGreedyTerrainDecimation.h:136
vtkGreedyTerrainDecimation::MaximumNumberOfTriangles
vtkIdType MaximumNumberOfTriangles
Definition: vtkGreedyTerrainDecimation.h:232
vtkGreedyTerrainDecimation::BoundaryVertexDeletion
vtkTypeBool BoundaryVertexDeletion
Definition: vtkGreedyTerrainDecimation.h:218
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
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:216
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:222
vtkX3D::port
@ port
Definition: vtkX3D.h:453
vtkGreedyTerrainDecimation
reduce height field (represented as image) to reduced TIN
Definition: vtkGreedyTerrainDecimation.h:109
vtkGreedyTerrainDecimation::Neighbors
vtkIdList * Neighbors
Definition: vtkGreedyTerrainDecimation.h:228
vtkGreedyTerrainDecimation::GetPoint
double * GetPoint(vtkIdType id)
vtkGreedyTerrainDecimation::Points
vtkDoubleArray * Points
Definition: vtkGreedyTerrainDecimation.h:224
vtkGreedyTerrainDecimation::Length
double Length
Definition: vtkGreedyTerrainDecimation.h:233
vtkGreedyTerrainDecimation::UpdateTriangle
void UpdateTriangle(vtkIdType triId, vtkIdType p1, vtkIdType p2, vtkIdType p3)
vtkGreedyTerrainDecimation::TerrainError
vtkPriorityQueue * TerrainError
Definition: vtkGreedyTerrainDecimation.h:236
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkGreedyTerrainDecimation::CurrentPointId
vtkIdType CurrentPointId
Definition: vtkGreedyTerrainDecimation.h:226
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
vtkGreedyTerrainDecimation::InCircle
int InCircle(double x[3], double x1[3], double x2[3], double x3[3])
vtkGreedyTerrainDecimation::TerrainInfo
vtkGreedyTerrainDecimationTerrainInfoType * TerrainInfo
Definition: vtkGreedyTerrainDecimation.h:237
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkGreedyTerrainDecimation::ComputeNormals
vtkTypeBool ComputeNormals
Definition: vtkGreedyTerrainDecimation.h:208
vtkGreedyTerrainDecimation::Reduction
double Reduction
Definition: vtkGreedyTerrainDecimation.h:215
vtkGreedyTerrainDecimation::ErrorMeasure
int ErrorMeasure
Definition: vtkGreedyTerrainDecimation.h:213
vtkGreedyTerrainDecimation::CheckEdge
void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2, vtkIdType tri, int depth)
vtkGreedyTerrainDecimation::SetErrorMeasureToSpecifiedReduction
void SetErrorMeasureToSpecifiedReduction()
Specify how to terminate the algorithm: either as an absolute number of triangles,...
Definition: vtkGreedyTerrainDecimation.h:132
VTK_ID_MAX
#define VTK_ID_MAX
Definition: vtkType.h:336
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkGreedyTerrainDecimation::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkGreedyTerrainDecimation::SetErrorMeasureToRelativeError
void SetErrorMeasureToRelativeError()
Specify how to terminate the algorithm: either as an absolute number of triangles,...
Definition: vtkGreedyTerrainDecimation.h:137
vtkGreedyTerrainDecimation::~vtkGreedyTerrainDecimation
~vtkGreedyTerrainDecimation() override
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:145
vtkGreedyTerrainDecimation::Mesh
vtkPolyData * Mesh
Definition: vtkGreedyTerrainDecimation.h:221
vtkGreedyTerrainDecimation::Normals
vtkFloatArray * Normals
Definition: vtkGreedyTerrainDecimation.h:209
VTK_ERROR_NUMBER_OF_TRIANGLES
#define VTK_ERROR_NUMBER_OF_TRIANGLES
Definition: vtkGreedyTerrainDecimation.h:103
vtkGreedyTerrainDecimation::Tolerance
double Tolerance
Definition: vtkGreedyTerrainDecimation.h:227
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
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:106
h
vtkFrustumSelector is a vtkSelector that selects elements based on whether they are inside or interse...
vtkGreedyTerrainDecimation::SatisfiesErrorMeasure
virtual int SatisfiesErrorMeasure(double error)
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:151
vtkGreedyTerrainDecimation::New
static vtkGreedyTerrainDecimation * New()
Instantiate the class.
VTK_ERROR_SPECIFIED_REDUCTION
#define VTK_ERROR_SPECIFIED_REDUCTION
Definition: vtkGreedyTerrainDecimation.h:104