VTK  9.3.1
vtkQuadricDecimation.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
47 #ifndef vtkQuadricDecimation_h
48 #define vtkQuadricDecimation_h
49 
50 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
51 #include "vtkFiltersCoreModule.h" // For export macro
52 #include "vtkPolyDataAlgorithm.h"
53 
54 VTK_ABI_NAMESPACE_BEGIN
55 class vtkEdgeTable;
56 class vtkIdList;
57 class vtkPointData;
58 class vtkPriorityQueue;
59 class vtkDoubleArray;
60 
61 class VTKFILTERSCORE_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
62 {
63 public:
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66  static vtkQuadricDecimation* New();
67 
69 
74  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
75  vtkGetMacro(TargetReduction, double);
77 
79 
84  vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
85  vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
86  vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
88 
90 
97  vtkSetMacro(VolumePreservation, vtkTypeBool);
98  vtkGetMacro(VolumePreservation, vtkTypeBool);
99  vtkBooleanMacro(VolumePreservation, vtkTypeBool);
101 
103 
118  vtkSetMacro(Regularize, vtkTypeBool);
119  vtkGetMacro(Regularize, vtkTypeBool);
120  vtkBooleanMacro(Regularize, vtkTypeBool);
121  vtkSetMacro(Regularization, double);
122  vtkGetMacro(Regularization, double);
124 
126 
134  vtkSetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
135  vtkGetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
136  vtkBooleanMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
137  vtkSetMacro(BoundaryWeightFactor, double);
138  vtkGetMacro(BoundaryWeightFactor, double);
140 
142 
145  vtkGetMacro(MapPointData, bool);
146  vtkSetMacro(MapPointData, bool);
147  vtkBooleanMacro(MapPointData, bool);
149 
151 
157  vtkSetMacro(ScalarsAttribute, vtkTypeBool);
158  vtkGetMacro(ScalarsAttribute, vtkTypeBool);
159  vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
160  vtkSetMacro(VectorsAttribute, vtkTypeBool);
161  vtkGetMacro(VectorsAttribute, vtkTypeBool);
162  vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
163  vtkSetMacro(NormalsAttribute, vtkTypeBool);
164  vtkGetMacro(NormalsAttribute, vtkTypeBool);
165  vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
166  vtkSetMacro(TCoordsAttribute, vtkTypeBool);
167  vtkGetMacro(TCoordsAttribute, vtkTypeBool);
168  vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
169  vtkSetMacro(TensorsAttribute, vtkTypeBool);
170  vtkGetMacro(TensorsAttribute, vtkTypeBool);
171  vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
173 
175 
180  vtkSetMacro(ScalarsWeight, double);
181  vtkSetMacro(VectorsWeight, double);
182  vtkSetMacro(NormalsWeight, double);
183  vtkSetMacro(TCoordsWeight, double);
184  vtkSetMacro(TensorsWeight, double);
185  vtkGetMacro(ScalarsWeight, double);
186  vtkGetMacro(VectorsWeight, double);
187  vtkGetMacro(NormalsWeight, double);
188  vtkGetMacro(TCoordsWeight, double);
189  vtkGetMacro(TensorsWeight, double);
191 
193 
197  vtkGetMacro(ActualReduction, double);
199 
200 protected:
202  ~vtkQuadricDecimation() override;
203 
205 
210  int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id);
211 
215  void InitializeQuadrics(vtkIdType numPts);
216 
220  void AddBoundaryConstraints();
221 
225  void ComputeQuadric(vtkIdType pointId);
226 
231  void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
232 
234 
238  double ComputeCost(vtkIdType edgeId, double* x);
239  double ComputeCost2(vtkIdType edgeId, double* x);
241 
247  void FindAffectedEdges(vtkIdType p1Id, vtkIdType p2Id, vtkIdList* edges);
248 
252  vtkIdType GetEdgeCellId(vtkIdType p1Id, vtkIdType p2Id);
253 
254  int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
255  int TrianglePlaneCheck(
256  const double t0[3], const double t1[3], const double t2[3], const double* x);
257  void ComputeNumberOfComponents();
258  void UpdateEdgeData(vtkIdType pt0Id, vtkIdType pt1Id);
259 
261 
266  VTK_DEPRECATED_IN_9_3_0("Deprecated in favor of the method taking the indexes of both points on "
267  "the edge to interpolate point data")
268  void SetPointAttributeArray(vtkIdType ptId, const double* x);
269  void SetPointAttributeArray(vtkIdType ptId[2], const double* x);
270  void GetPointAttributeArray(vtkIdType ptId, double* x);
272 
277  void GetAttributeComponents();
278 
279  double TargetReduction;
280  double ActualReduction;
281  vtkTypeBool AttributeErrorMetric;
282  vtkTypeBool VolumePreservation;
283 
284  bool MapPointData = false;
285 
286  vtkTypeBool ScalarsAttribute;
287  vtkTypeBool VectorsAttribute;
288  vtkTypeBool NormalsAttribute;
289  vtkTypeBool TCoordsAttribute;
290  vtkTypeBool TensorsAttribute;
291 
292  double ScalarsWeight;
293  double VectorsWeight;
294  double NormalsWeight;
295  double TCoordsWeight;
296  double TensorsWeight;
297 
298  int NumberOfEdgeCollapses;
299  vtkEdgeTable* Edges;
300  vtkIdList* EndPoint1List;
301  vtkIdList* EndPoint2List;
302  vtkPriorityQueue* EdgeCosts;
303  vtkDoubleArray* TargetPoints;
304  int NumberOfComponents;
305  vtkPolyData* Mesh;
306 
308  {
309  double* Quadric;
310  };
311 
312  // One ErrorQuadric per point
314 
315  // Controlling regularization behavior
316  vtkTypeBool Regularize = false;
317  double Regularization = 0.05;
318 
319  // Controlling the boundary weighting behavior
320  vtkTypeBool WeighBoundaryConstraintsByLength = false;
321  double BoundaryWeightFactor = 1.0;
322 
323  // Contains 4 doubles per point. Length = nPoints * 4
325  int AttributeComponents[6];
326  double AttributeScale[6];
327 
328  // Temporary variables for performance
330  double* TempX;
331  double* TempQuad;
332  double* TempB;
333  double** TempA;
334  double* TempData;
335 
336 private:
338  void operator=(const vtkQuadricDecimation&) = delete;
339 };
340 
341 VTK_ABI_NAMESPACE_END
342 #endif
represent and manipulate point attribute data
Definition: vtkPointData.h:29
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
int vtkIdType
Definition: vtkType.h:315
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:29
dynamic, self-adjusting array of double
a list of ids arranged in priority order
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:64
reduce the number of triangles in a mesh
#define VTK_DEPRECATED_IN_9_3_0(reason)
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:28
list of point or cell ids
Definition: vtkIdList.h:22
Store zero or more vtkInformation instances.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)