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