VTK  9.0.2
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 =========================================================================*/
67 #ifndef vtkGreedyTerrainDecimation_h
68 #define vtkGreedyTerrainDecimation_h
69 
70 #include "vtkFiltersHybridModule.h" // For export macro
71 #include "vtkPolyDataAlgorithm.h"
72 
73 class vtkPriorityQueue;
74 class vtkDataArray;
75 class vtkPointData;
76 class vtkIdList;
77 class vtkDoubleArray;
78 class vtkFloatArray;
79 
80 // PIMPL Encapsulation for STL containers
81 class vtkGreedyTerrainDecimationTerrainInfoType;
82 class vtkGreedyTerrainDecimationPointInfoType;
83 
84 #define VTK_ERROR_NUMBER_OF_TRIANGLES 0
85 #define VTK_ERROR_SPECIFIED_REDUCTION 1
86 #define VTK_ERROR_ABSOLUTE 2
87 #define VTK_ERROR_RELATIVE 3
88 
89 class VTKFILTERSHYBRID_EXPORT vtkGreedyTerrainDecimation : public vtkPolyDataAlgorithm
90 {
91 public:
93  void PrintSelf(ostream& os, vtkIndent indent) override;
94 
99 
101 
107  vtkSetClampMacro(ErrorMeasure, int, VTK_ERROR_NUMBER_OF_TRIANGLES, VTK_ERROR_RELATIVE);
108  vtkGetMacro(ErrorMeasure, int);
110  {
111  this->SetErrorMeasure(VTK_ERROR_NUMBER_OF_TRIANGLES);
112  }
114  {
115  this->SetErrorMeasure(VTK_ERROR_SPECIFIED_REDUCTION);
116  }
117  void SetErrorMeasureToAbsoluteError() { this->SetErrorMeasure(VTK_ERROR_ABSOLUTE); }
118  void SetErrorMeasureToRelativeError() { this->SetErrorMeasure(VTK_ERROR_RELATIVE); }
120 
122 
128  vtkSetClampMacro(NumberOfTriangles, vtkIdType, 2, VTK_ID_MAX);
129  vtkGetMacro(NumberOfTriangles, vtkIdType);
131 
133 
138  vtkSetClampMacro(Reduction, double, 0.0, 1.0);
139  vtkGetMacro(Reduction, double);
141 
143 
148  vtkSetClampMacro(AbsoluteError, double, 0.0, VTK_DOUBLE_MAX);
149  vtkGetMacro(AbsoluteError, double);
151 
153 
159  vtkSetClampMacro(RelativeError, double, 0.0, VTK_DOUBLE_MAX);
160  vtkGetMacro(RelativeError, double);
162 
164 
168  vtkSetMacro(BoundaryVertexDeletion, vtkTypeBool);
169  vtkGetMacro(BoundaryVertexDeletion, vtkTypeBool);
170  vtkBooleanMacro(BoundaryVertexDeletion, vtkTypeBool);
172 
174 
177  vtkSetMacro(ComputeNormals, vtkTypeBool);
178  vtkGetMacro(ComputeNormals, vtkTypeBool);
179  vtkBooleanMacro(ComputeNormals, vtkTypeBool);
181 
182 protected:
185 
188 
191  void ComputePointNormal(int i, int j, float n[3]);
192 
193  // ivars that the API addresses
196  double Reduction;
199  vtkTypeBool BoundaryVertexDeletion; // Can we delete boundary vertices?
200 
201  // Used for convenience
208  double Tolerance;
210  int Dimensions[3];
211  double Origin[3];
212  double Spacing[3];
214  double Length;
215 
216  // Bookkeeping arrays
217  vtkPriorityQueue* TerrainError; // errors for each pt in height field
218  vtkGreedyTerrainDecimationTerrainInfoType* TerrainInfo; // owning triangle for each pt
219  vtkGreedyTerrainDecimationPointInfoType* PointInfo; // map mesh pt id to input pt id
220 
221  // Make a guess at initial allocation
222  void EstimateOutputSize(const vtkIdType numInputPts, vtkIdType& numPts, vtkIdType& numTris);
223 
224  // Returns non-zero if the error measure is satisfied.
225  virtual int SatisfiesErrorMeasure(double error);
226 
227  // Insert all the boundary vertices into the TIN
229 
230  // Insert a point into the triangulation; get a point from the triangulation
232  vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3]);
233  double* GetPoint(vtkIdType id);
234  void GetPoint(vtkIdType id, double x[3]);
235 
236  // Helper functions
237  void GetTerrainPoint(int i, int j, double x[3]);
238  void ComputeImageCoordinates(vtkIdType inputPtId, int ij[2]);
239  int InCircle(double x[3], double x1[3], double x2[3], double x3[3]);
240  vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri, double tol,
241  vtkIdType nei[3], vtkIdList* neighbors, int& status);
242  void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2, vtkIdType tri, int depth);
243 
244  void UpdateTriangles(vtkIdType meshPtId); // update all points connected to this point
246  void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[4]);
247 
248  int CharacterizeTriangle(int ij1[2], int ij2[2], int ij[3], int*& min, int*& max, int*& midL,
249  int*& midR, int*& mid, int mid2[2], double h[3], double& hMin, double& hMax, double& hL,
250  double& hR);
251 
252 private:
254  void operator=(const vtkGreedyTerrainDecimation&) = delete;
255 };
256 
257 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
dynamic, self-adjusting array of double
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
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)
vtkGreedyTerrainDecimationTerrainInfoType * TerrainInfo
void ComputePointNormal(int i, int j, float n[3])
~vtkGreedyTerrainDecimation() override
vtkIdType InsertNextPoint(vtkIdType inputPtId, double x[3])
vtkIdType AddPointToTriangulation(vtkIdType inputPtId)
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 GetPoint(vtkIdType id, double x[3])
void UpdateTriangle(vtkIdType triId, int ij1[2], int ij2[2], int ij3[2], double h[4])
static vtkGreedyTerrainDecimation * New()
Instantiate the class.
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)
double * GetPoint(vtkIdType id)
list of point or cell ids
Definition: vtkIdList.h:31
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate point attribute data
Definition: vtkPointData.h:32
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
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:338
#define VTK_ID_MAX
Definition: vtkType.h:342
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
#define max(a, b)