VTK: Filters/Hybrid/vtkGreedyTerrainDecimation.h Source File

| VTK 9.3.1

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
67 #ifndef vtkGreedyTerrainDecimation_h
68 #define vtkGreedyTerrainDecimation_h
69
70 #include "vtkFiltersHybridModule.h" // For export macro
71 #include "vtkPolyDataAlgorithm.h"
72
73 VTK_ABI_NAMESPACE_BEGIN
74 class vtkPriorityQueue;
75 class vtkDataArray;
76 class vtkPointData;
77 class vtkIdList;
78 class vtkDoubleArray;
79 class vtkFloatArray;
80
81 // PIMPL Encapsulation for STL containers
82 class vtkGreedyTerrainDecimationTerrainInfoType;
83 class vtkGreedyTerrainDecimationPointInfoType;
84
85 #define VTK_ERROR_NUMBER_OF_TRIANGLES 0
86 #define VTK_ERROR_SPECIFIED_REDUCTION 1
87 #define VTK_ERROR_ABSOLUTE 2
88 #define VTK_ERROR_RELATIVE 3
89
90 class VTKFILTERSHYBRID_EXPORT vtkGreedyTerrainDecimation : public vtkPolyDataAlgorithm
91 {
92 public:
93 vtkTypeMacro(vtkGreedyTerrainDecimation, vtkPolyDataAlgorithm);
94 void PrintSelf(ostream& os, vtkIndent indent) override;
95
99 static vtkGreedyTerrainDecimation* New();
100
102
108 vtkSetClampMacro(ErrorMeasure, int, VTK_ERROR_NUMBER_OF_TRIANGLES, VTK_ERROR_RELATIVE);
109 vtkGetMacro(ErrorMeasure, int);
110 void SetErrorMeasureToNumberOfTriangles()
111 {
112 this->SetErrorMeasure(VTK_ERROR_NUMBER_OF_TRIANGLES);
113 }
114 void SetErrorMeasureToSpecifiedReduction()
115 {
116 this->SetErrorMeasure(VTK_ERROR_SPECIFIED_REDUCTION);
117 }
118 void SetErrorMeasureToAbsoluteError() { this->SetErrorMeasure(VTK_ERROR_ABSOLUTE); }
119 void SetErrorMeasureToRelativeError() { this->SetErrorMeasure(VTK_ERROR_RELATIVE); }
121
123
129 vtkSetClampMacro(NumberOfTriangles, vtkIdType, 2, VTK_ID_MAX);
130 vtkGetMacro(NumberOfTriangles, vtkIdType);
132
134
139 vtkSetClampMacro(Reduction, double, 0.0, 1.0);
140 vtkGetMacro(Reduction, double);
142
144
149 vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
150 vtkGetMacro(AbsoluteError, double);
152
154
160 vtkSetClampMacro(RelativeError, double, 0.0, VTK_DOUBLE_MAX);
161 vtkGetMacro(RelativeError, double);
163
165
169 vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
170 vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
171 vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
173
175
178 vtkSetMacro(ComputeNormals, vtkTypeBool);
179 vtkGetMacro(ComputeNormals, vtkTypeBool);
180 vtkBooleanMacro(ComputeNormals, vtkTypeBool);
182
183 protected:
184 vtkGreedyTerrainDecimation();
185 ~vtkGreedyTerrainDecimation() override;
186
187 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
188 int FillInputPortInformation(int port, vtkInformation* info) override;
189
190 vtkTypeBool ComputeNormals;
191 vtkFloatArray* Normals;
192 void ComputePointNormal(int i, int j, float n[3]);
193
194 // ivars that the API addresses
195 int ErrorMeasure;
196 vtkIdType NumberOfTriangles;
197 double Reduction;
198 double AbsoluteError;
199 double RelativeError;
200 vtkTypeBool BoundaryVertexDeletion; // Can we delete boundary vertices?
201
202 // Used for convenience
203 vtkPolyData* Mesh;
204 vtkPointData* InputPD;
205 vtkPointData* OutputPD;
206 vtkDoubleArray* Points;
207 vtkDataArray* Heights;
208 vtkIdType CurrentPointId;
209 double Tolerance;
210 vtkIdList* Neighbors;
211 int Dimensions[3];
212 double Origin[3];
213 double Spacing[3];
214 vtkIdType MaximumNumberOfTriangles;
215 double Length;
216
217 // Bookkeeping arrays
218 vtkPriorityQueue* TerrainError; // errors for each pt in height field
219 vtkGreedyTerrainDecimationTerrainInfoType* TerrainInfo; // owning triangle for each pt
220 vtkGreedyTerrainDecimationPointInfoType* PointInfo; // map mesh pt id to input pt id
221
222 // Make a guess at initial allocation
223 void EstimateOutputSize(vtkIdType numInputPts, vtkIdType& numPts, vtkIdType& numTris);
224
225 // Returns non-zero if the error measure is satisfied.
226 virtual int SatisfiesErrorMeasure(double error);
227
228 // Insert all the boundary vertices into the TIN
229 void InsertBoundaryVertices();
230
231 // Insert a point into the triangulation; get a point from the triangulation
232 vtkIdType AddPointToTriangulation(vtkIdType inputPtId);
233 vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3]);
234 double* GetPoint(vtkIdType id);
235 void GetPoint(vtkIdType id, double x[3]);
236
237 // Helper functions
238 void GetTerrainPoint(int i, int j, double x[3]);
239 void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2]);
240 int InCircle(double x[3], double x1[3], double x2[3], double x3[3]);
241 vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri, double tol,
242 vtkIdType nei[3], vtkIdList* neighbors, int& status);
243 void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2, vtkIdType tri, int depth);
244
245 void UpdateTriangles(vtkIdType meshPtId); // update all points connected to this point
246 void UpdateTriangle(vtkIdType triId, vtkIdType p1, vtkIdType p2, vtkIdType p3);
247 void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[3]);
248
249 int CharacterizeTriangle(int ij1[2], int ij2[2], int ij[3], int*& min, int*& max, int*& midL,
250 int*& midR, int*& mid, int mid2[2], double h[3], double& hMin, double& hMax, double& hL,
251 double& hR);
252
253 private:
254 vtkGreedyTerrainDecimation(const vtkGreedyTerrainDecimation&) = delete;
255 void operator=(const vtkGreedyTerrainDecimation&) = delete;
256 };
257
258 VTK_ABI_NAMESPACE_END
259 #endif
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:40
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:40
vtkGreedyTerrainDecimation
reduce height field (represented as image) to reduced TIN
Definition: vtkGreedyTerrainDecimation.h:91
vtkGreedyTerrainDecimation::Normals
vtkFloatArray * Normals
Definition: vtkGreedyTerrainDecimation.h:191
vtkGreedyTerrainDecimation::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkGreedyTerrainDecimation::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkGreedyTerrainDecimation::ComputeImageCoordinates
void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2])
vtkGreedyTerrainDecimation::UpdateTriangle
void UpdateTriangle(vtkIdType triId, vtkIdType p1, vtkIdType p2, vtkIdType p3)
vtkGreedyTerrainDecimation::Points
vtkDoubleArray * Points
Definition: vtkGreedyTerrainDecimation.h:206
vtkGreedyTerrainDecimation::Length
double Length
Definition: vtkGreedyTerrainDecimation.h:215
vtkGreedyTerrainDecimation::GetTerrainPoint
void GetTerrainPoint(int i, int j, double x[3])
vtkGreedyTerrainDecimation::OutputPD
vtkPointData * OutputPD
Definition: vtkGreedyTerrainDecimation.h:205
vtkGreedyTerrainDecimation::BoundaryVertexDeletion
vtkTypeBool BoundaryVertexDeletion
Definition: vtkGreedyTerrainDecimation.h:200
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::SetErrorMeasureToNumberOfTriangles
void SetErrorMeasureToNumberOfTriangles()
Specify how to terminate the algorithm: either as an absolute number of triangles,...
Definition: vtkGreedyTerrainDecimation.h:110
vtkGreedyTerrainDecimation::TerrainInfo
vtkGreedyTerrainDecimationTerrainInfoType * TerrainInfo
Definition: vtkGreedyTerrainDecimation.h:219
vtkGreedyTerrainDecimation::ComputePointNormal
void ComputePointNormal(int i, int j, float n[3])
vtkGreedyTerrainDecimation::SetErrorMeasureToAbsoluteError
void SetErrorMeasureToAbsoluteError()
Specify how to terminate the algorithm: either as an absolute number of triangles,...
Definition: vtkGreedyTerrainDecimation.h:118
vtkGreedyTerrainDecimation::Reduction
double Reduction
Definition: vtkGreedyTerrainDecimation.h:197
vtkGreedyTerrainDecimation::Heights
vtkDataArray * Heights
Definition: vtkGreedyTerrainDecimation.h:207
vtkGreedyTerrainDecimation::UpdateTriangle
void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[3])
vtkGreedyTerrainDecimation::~vtkGreedyTerrainDecimation
~vtkGreedyTerrainDecimation() override
vtkGreedyTerrainDecimation::InsertNextPoint
vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3])
vtkGreedyTerrainDecimation::ComputeNormals
vtkTypeBool ComputeNormals
Definition: vtkGreedyTerrainDecimation.h:190
vtkGreedyTerrainDecimation::AddPointToTriangulation
vtkIdType AddPointToTriangulation(vtkIdType inputPtId)
vtkGreedyTerrainDecimation::CurrentPointId
vtkIdType CurrentPointId
Definition: vtkGreedyTerrainDecimation.h:208
vtkGreedyTerrainDecimation::Neighbors
vtkIdList * Neighbors
Definition: vtkGreedyTerrainDecimation.h:210
vtkGreedyTerrainDecimation::NumberOfTriangles
vtkIdType NumberOfTriangles
Definition: vtkGreedyTerrainDecimation.h:196
vtkGreedyTerrainDecimation::FindTriangle
vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri, double tol, vtkIdType nei[3], vtkIdList *neighbors, int &status)
vtkGreedyTerrainDecimation::InsertBoundaryVertices
void InsertBoundaryVertices()
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:220
vtkGreedyTerrainDecimation::vtkGreedyTerrainDecimation
vtkGreedyTerrainDecimation()
vtkGreedyTerrainDecimation::SetErrorMeasureToRelativeError
void SetErrorMeasureToRelativeError()
Specify how to terminate the algorithm: either as an absolute number of triangles,...
Definition: vtkGreedyTerrainDecimation.h:119
vtkGreedyTerrainDecimation::GetPoint
void GetPoint(vtkIdType id, double x[3])
vtkGreedyTerrainDecimation::MaximumNumberOfTriangles
vtkIdType MaximumNumberOfTriangles
Definition: vtkGreedyTerrainDecimation.h:214
vtkGreedyTerrainDecimation::AbsoluteError
double AbsoluteError
Definition: vtkGreedyTerrainDecimation.h:198
vtkGreedyTerrainDecimation::RelativeError
double RelativeError
Definition: vtkGreedyTerrainDecimation.h:199
vtkGreedyTerrainDecimation::SetErrorMeasureToSpecifiedReduction
void SetErrorMeasureToSpecifiedReduction()
Specify how to terminate the algorithm: either as an absolute number of triangles,...
Definition: vtkGreedyTerrainDecimation.h:114
vtkGreedyTerrainDecimation::Tolerance
double Tolerance
Definition: vtkGreedyTerrainDecimation.h:209
vtkGreedyTerrainDecimation::New
static vtkGreedyTerrainDecimation * New()
Instantiate the class.
vtkGreedyTerrainDecimation::EstimateOutputSize
void EstimateOutputSize(vtkIdType numInputPts, vtkIdType &numPts, vtkIdType &numTris)
vtkGreedyTerrainDecimation::SatisfiesErrorMeasure
virtual int SatisfiesErrorMeasure(double error)
vtkGreedyTerrainDecimation::ErrorMeasure
int ErrorMeasure
Definition: vtkGreedyTerrainDecimation.h:195
vtkGreedyTerrainDecimation::InCircle
int InCircle(double x[3], double x1[3], double x2[3], double x3[3])
vtkGreedyTerrainDecimation::Mesh
vtkPolyData * Mesh
Definition: vtkGreedyTerrainDecimation.h:203
vtkGreedyTerrainDecimation::CheckEdge
void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2, vtkIdType tri, int depth)
vtkGreedyTerrainDecimation::UpdateTriangles
void UpdateTriangles(vtkIdType meshPtId)
vtkGreedyTerrainDecimation::InputPD
vtkPointData * InputPD
Definition: vtkGreedyTerrainDecimation.h:204
vtkGreedyTerrainDecimation::TerrainError
vtkPriorityQueue * TerrainError
Definition: vtkGreedyTerrainDecimation.h:218
vtkGreedyTerrainDecimation::GetPoint
double * GetPoint(vtkIdType id)
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:32
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:39
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:43
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
vtkPriorityQueue
a list of ids arranged in priority order
Definition: vtkPriorityQueue.h:36
h
Computes the portion of a dataset which is inside a selection.
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkX3D::port
@ port
Definition: vtkX3D.h:447
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
VTK_ERROR_SPECIFIED_REDUCTION
#define VTK_ERROR_SPECIFIED_REDUCTION
Definition: vtkGreedyTerrainDecimation.h:86
VTK_ERROR_ABSOLUTE
#define VTK_ERROR_ABSOLUTE
Definition: vtkGreedyTerrainDecimation.h:87
VTK_ERROR_RELATIVE
#define VTK_ERROR_RELATIVE
Definition: vtkGreedyTerrainDecimation.h:88
VTK_ERROR_NUMBER_OF_TRIANGLES
#define VTK_ERROR_NUMBER_OF_TRIANGLES
Definition: vtkGreedyTerrainDecimation.h:85
vtkPolyDataAlgorithm.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315
VTK_ID_MAX
#define VTK_ID_MAX
Definition: vtkType.h:319
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:19