VTK  9.3.20240424
vtkGreedyTerrainDecimation.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
77#ifndef vtkGreedyTerrainDecimation_h
78#define vtkGreedyTerrainDecimation_h
79
80#include "vtkFiltersHybridModule.h" // For export macro
82
83VTK_ABI_NAMESPACE_BEGIN
85class vtkDataArray;
86class vtkPointData;
87class vtkIdList;
88class vtkDoubleArray;
89class vtkFloatArray;
90
91// PIMPL Encapsulation for STL containers
92class vtkGreedyTerrainDecimationTerrainInfoType;
93class vtkGreedyTerrainDecimationPointInfoType;
94
95#define VTK_ERROR_NUMBER_OF_TRIANGLES 0
96#define VTK_ERROR_SPECIFIED_REDUCTION 1
97#define VTK_ERROR_ABSOLUTE 2
98#define VTK_ERROR_RELATIVE 3
99
100class VTKFILTERSHYBRID_EXPORT vtkGreedyTerrainDecimation : public vtkPolyDataAlgorithm
101{
102public:
104 void PrintSelf(ostream& os, vtkIndent indent) override;
105
110
112
118 vtkSetClampMacro(ErrorMeasure, int, VTK_ERROR_NUMBER_OF_TRIANGLES, VTK_ERROR_RELATIVE);
119 vtkGetMacro(ErrorMeasure, int);
121 {
122 this->SetErrorMeasure(VTK_ERROR_NUMBER_OF_TRIANGLES);
123 }
125 {
126 this->SetErrorMeasure(VTK_ERROR_SPECIFIED_REDUCTION);
127 }
128 void SetErrorMeasureToAbsoluteError() { this->SetErrorMeasure(VTK_ERROR_ABSOLUTE); }
129 void SetErrorMeasureToRelativeError() { this->SetErrorMeasure(VTK_ERROR_RELATIVE); }
131
133
139 vtkSetClampMacro(NumberOfTriangles, vtkIdType, 2, VTK_ID_MAX);
140 vtkGetMacro(NumberOfTriangles, vtkIdType);
142
144
149 vtkSetClampMacro(Reduction, double, 0.0, 1.0);
150 vtkGetMacro(Reduction, double);
152
154
159 vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
160 vtkGetMacro(AbsoluteError, double);
162
164
170 vtkSetClampMacro(RelativeError, double, 0.0, VTK_DOUBLE_MAX);
171 vtkGetMacro(RelativeError, double);
173
175
179 vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
180 vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
181 vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
183
185
188 vtkSetMacro(ComputeNormals, vtkTypeBool);
189 vtkGetMacro(ComputeNormals, vtkTypeBool);
190 vtkBooleanMacro(ComputeNormals, vtkTypeBool);
192
193protected:
196
198 int FillInputPortInformation(int port, vtkInformation* info) override;
199
202 void ComputePointNormal(int i, int j, float n[3]);
203
204 // ivars that the API addresses
207 double Reduction;
210 vtkTypeBool BoundaryVertexDeletion; // Can we delete boundary vertices?
211
212 // Used for convenience
219 double Tolerance;
221 int Dimensions[3];
222 double Origin[3];
223 double Spacing[3];
225 double Length;
226
227 // Bookkeeping arrays
228 vtkPriorityQueue* TerrainError; // errors for each pt in height field
229 vtkGreedyTerrainDecimationTerrainInfoType* TerrainInfo; // owning triangle for each pt
230 vtkGreedyTerrainDecimationPointInfoType* PointInfo; // map mesh pt id to input pt id
231
232 // Make a guess at initial allocation
233 void EstimateOutputSize(vtkIdType numInputPts, vtkIdType& numPts, vtkIdType& numTris);
234
235 // Returns non-zero if the error measure is satisfied.
236 virtual int SatisfiesErrorMeasure(double error);
237
238 // Insert all the boundary vertices into the TIN
240
241 // Insert a point into the triangulation; get a point from the triangulation
243 vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3]);
244 double* GetPoint(vtkIdType id);
245 void GetPoint(vtkIdType id, double x[3]);
246
247 // Helper functions
248 void GetTerrainPoint(int i, int j, double x[3]);
249 void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2]);
250 int InCircle(double x[3], double x1[3], double x2[3], double x3[3]);
251 vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri, double tol,
252 vtkIdType nei[3], vtkIdList* neighbors, int& status);
253 void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2, vtkIdType tri, int depth);
254
255 void UpdateTriangles(vtkIdType meshPtId); // update all points connected to this point
257 void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[3]);
258
259 int CharacterizeTriangle(int ij1[2], int ij2[2], int ij[3], int*& min, int*& max, int*& midL,
260 int*& midR, int*& mid, int mid2[2], double h[3], double& hMin, double& hMax, double& hL,
261 double& hR);
262
263private:
265 void operator=(const vtkGreedyTerrainDecimation&) = delete;
266};
267
268VTK_ABI_NAMESPACE_END
269#endif
abstract superclass for arrays of numeric data
dynamic, self-adjusting array of double
dynamic, self-adjusting array of float
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.
void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[3])
~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.
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 SetErrorMeasureToSpecifiedReduction()
Specify how to terminate the algorithm: either as an absolute number of triangles,...
void EstimateOutputSize(vtkIdType numInputPts, vtkIdType &numPts, vtkIdType &numTris)
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:133
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate point attribute data
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
a list of ids arranged in priority order
Computes the portion of a dataset which is inside a selection.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_ERROR_SPECIFIED_REDUCTION
#define VTK_ERROR_ABSOLUTE
#define VTK_ERROR_RELATIVE
#define VTK_ERROR_NUMBER_OF_TRIANGLES
int vtkIdType
Definition vtkType.h:315
#define VTK_ID_MAX
Definition vtkType.h:319
#define VTK_DOUBLE_MAX
Definition vtkType.h:154
#define max(a, b)