VTK  9.2.6
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=========================================================================*/
79#ifndef vtkGreedyTerrainDecimation_h
80#define vtkGreedyTerrainDecimation_h
81
82#include "vtkFiltersHybridModule.h" // For export macro
84
86class vtkDataArray;
87class vtkPointData;
88class vtkIdList;
89class vtkDoubleArray;
90class vtkFloatArray;
91
92// PIMPL Encapsulation for STL containers
93class vtkGreedyTerrainDecimationTerrainInfoType;
94class vtkGreedyTerrainDecimationPointInfoType;
95
96#define VTK_ERROR_NUMBER_OF_TRIANGLES 0
97#define VTK_ERROR_SPECIFIED_REDUCTION 1
98#define VTK_ERROR_ABSOLUTE 2
99#define VTK_ERROR_RELATIVE 3
100
101class VTKFILTERSHYBRID_EXPORT vtkGreedyTerrainDecimation : public vtkPolyDataAlgorithm
102{
103public:
105 void PrintSelf(ostream& os, vtkIndent indent) override;
106
111
113
119 vtkSetClampMacro(ErrorMeasure, int, VTK_ERROR_NUMBER_OF_TRIANGLES, VTK_ERROR_RELATIVE);
120 vtkGetMacro(ErrorMeasure, int);
122 {
123 this->SetErrorMeasure(VTK_ERROR_NUMBER_OF_TRIANGLES);
124 }
126 {
127 this->SetErrorMeasure(VTK_ERROR_SPECIFIED_REDUCTION);
128 }
129 void SetErrorMeasureToAbsoluteError() { this->SetErrorMeasure(VTK_ERROR_ABSOLUTE); }
130 void SetErrorMeasureToRelativeError() { this->SetErrorMeasure(VTK_ERROR_RELATIVE); }
132
134
140 vtkSetClampMacro(NumberOfTriangles, vtkIdType, 2, VTK_ID_MAX);
141 vtkGetMacro(NumberOfTriangles, vtkIdType);
143
145
150 vtkSetClampMacro(Reduction, double, 0.0, 1.0);
151 vtkGetMacro(Reduction, double);
153
155
160 vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
161 vtkGetMacro(AbsoluteError, double);
163
165
171 vtkSetClampMacro(RelativeError, double, 0.0, VTK_DOUBLE_MAX);
172 vtkGetMacro(RelativeError, double);
174
176
180 vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
181 vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
182 vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
184
186
189 vtkSetMacro(ComputeNormals, vtkTypeBool);
190 vtkGetMacro(ComputeNormals, vtkTypeBool);
191 vtkBooleanMacro(ComputeNormals, vtkTypeBool);
193
194protected:
197
199 int FillInputPortInformation(int port, vtkInformation* info) override;
200
203 void ComputePointNormal(int i, int j, float n[3]);
204
205 // ivars that the API addresses
208 double Reduction;
211 vtkTypeBool BoundaryVertexDeletion; // Can we delete boundary vertices?
212
213 // Used for convenience
220 double Tolerance;
222 int Dimensions[3];
223 double Origin[3];
224 double Spacing[3];
226 double Length;
227
228 // Bookkeeping arrays
229 vtkPriorityQueue* TerrainError; // errors for each pt in height field
230 vtkGreedyTerrainDecimationTerrainInfoType* TerrainInfo; // owning triangle for each pt
231 vtkGreedyTerrainDecimationPointInfoType* PointInfo; // map mesh pt id to input pt id
232
233 // Make a guess at initial allocation
234 void EstimateOutputSize(const vtkIdType numInputPts, vtkIdType& numPts, vtkIdType& numTris);
235
236 // Returns non-zero if the error measure is satisfied.
237 virtual int SatisfiesErrorMeasure(double error);
238
239 // Insert all the boundary vertices into the TIN
241
242 // Insert a point into the triangulation; get a point from the triangulation
244 vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3]);
245 double* GetPoint(vtkIdType id);
246 void GetPoint(vtkIdType id, double x[3]);
247
248 // Helper functions
249 void GetTerrainPoint(int i, int j, double x[3]);
250 void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2]);
251 int InCircle(double x[3], double x1[3], double x2[3], double x3[3]);
252 vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri, double tol,
253 vtkIdType nei[3], vtkIdList* neighbors, int& status);
254 void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2, vtkIdType tri, int depth);
255
256 void UpdateTriangles(vtkIdType meshPtId); // update all points connected to this point
258 void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[4]);
259
260 int CharacterizeTriangle(int ij1[2], int ij2[2], int ij[3], int*& min, int*& max, int*& midL,
261 int*& midR, int*& mid, int mid2[2], double h[3], double& hMin, double& hMax, double& hL,
262 double& hR);
263
264private:
266 void operator=(const vtkGreedyTerrainDecimation&) = delete;
267};
268
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.
~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:43
a simple class to control print indentation
Definition vtkIndent.h:49
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: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)