VTK  9.7.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
48 #ifndef vtkQuadricDecimation_h
49 #define vtkQuadricDecimation_h
50 
51 #include "vtkFiltersCoreModule.h" // For export macro
52 #include "vtkPolyDataAlgorithm.h"
53 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
54 
55 VTK_ABI_NAMESPACE_BEGIN
56 class vtkEdgeTable;
57 class vtkIdList;
58 class vtkPointData;
59 class vtkPriorityQueue;
60 class vtkDoubleArray;
61 
62 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkQuadricDecimation : public vtkPolyDataAlgorithm
63 {
64 public:
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67  static vtkQuadricDecimation* New();
68 
70 
76  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
77  vtkGetMacro(TargetReduction, double);
79 
81 
86  vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
87  vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
88  vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
90 
92 
99  vtkSetMacro(VolumePreservation, vtkTypeBool);
100  vtkGetMacro(VolumePreservation, vtkTypeBool);
101  vtkBooleanMacro(VolumePreservation, vtkTypeBool);
103 
105 
110  vtkSetMacro(MaximumError, double);
111  vtkGetMacro(MaximumError, double);
113 
115 
130  vtkSetMacro(Regularize, vtkTypeBool);
131  vtkGetMacro(Regularize, vtkTypeBool);
132  vtkBooleanMacro(Regularize, vtkTypeBool);
133  vtkSetMacro(Regularization, double);
134  vtkGetMacro(Regularization, double);
136 
138 
146  vtkSetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
147  vtkGetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
148  vtkBooleanMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
149  vtkSetMacro(BoundaryWeightFactor, double);
150  vtkGetMacro(BoundaryWeightFactor, double);
152 
154 
159  vtkGetMacro(MapPointData, bool);
160  vtkSetMacro(MapPointData, bool);
161  vtkBooleanMacro(MapPointData, bool);
163 
165 
171  vtkSetMacro(ScalarsAttribute, vtkTypeBool);
172  vtkGetMacro(ScalarsAttribute, vtkTypeBool);
173  vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
174  vtkSetMacro(VectorsAttribute, vtkTypeBool);
175  vtkGetMacro(VectorsAttribute, vtkTypeBool);
176  vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
177  vtkSetMacro(NormalsAttribute, vtkTypeBool);
178  vtkGetMacro(NormalsAttribute, vtkTypeBool);
179  vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
180  vtkSetMacro(TCoordsAttribute, vtkTypeBool);
181  vtkGetMacro(TCoordsAttribute, vtkTypeBool);
182  vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
183  vtkSetMacro(TensorsAttribute, vtkTypeBool);
184  vtkGetMacro(TensorsAttribute, vtkTypeBool);
185  vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
187 
189 
194  vtkSetMacro(ScalarsWeight, double);
195  vtkSetMacro(VectorsWeight, double);
196  vtkSetMacro(NormalsWeight, double);
197  vtkSetMacro(TCoordsWeight, double);
198  vtkSetMacro(TensorsWeight, double);
199  vtkGetMacro(ScalarsWeight, double);
200  vtkGetMacro(VectorsWeight, double);
201  vtkGetMacro(NormalsWeight, double);
202  vtkGetMacro(TCoordsWeight, double);
203  vtkGetMacro(TensorsWeight, double);
205 
207 
211  vtkGetMacro(ActualReduction, double);
213 
214 protected:
216  ~vtkQuadricDecimation() override;
217 
219 
224  int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id);
225 
229  void InitializeQuadrics(vtkIdType numPts);
230 
234  void AddBoundaryConstraints();
235 
239  void ComputeQuadric(vtkIdType pointId);
240 
245  void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
246 
248 
252  double ComputeCost(vtkIdType edgeId, double* x);
253  double ComputeCost2(vtkIdType edgeId, double* x);
255 
261  void FindAffectedEdges(vtkIdType p1Id, vtkIdType p2Id, vtkIdList* edges);
262 
266  vtkIdType GetEdgeCellId(vtkIdType p1Id, vtkIdType p2Id);
267 
268  int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
269  int TrianglePlaneCheck(
270  const double t0[3], const double t1[3], const double t2[3], const double* x);
271  void ComputeNumberOfComponents();
272  void UpdateEdgeData(vtkIdType pt0Id, vtkIdType pt1Id);
273 
275 
280  void SetPointCoordinates(vtkIdType ptId, const double* x);
281 
290  void SetPointActiveAttributes(vtkIdType ptId, const double* x);
291 
304  void SetPointAttributeArray(vtkIdType ptId[2], const double* x);
305  void GetPointAttributeArray(vtkIdType ptId, double* x);
307 
312  void GetAttributeComponents();
313 
318 
319  bool MapPointData = false;
320 
326 
332 
341 
343  {
344  double* Quadric;
345  };
346 
347  // One ErrorQuadric per point
349 
350  // Controlling regularization behavior
351  vtkTypeBool Regularize = false;
352  double Regularization = 0.05;
353 
354  // Controlling the boundary weighting behavior
355  vtkTypeBool WeighBoundaryConstraintsByLength = false;
356  double BoundaryWeightFactor = 1.0;
357 
358  // Contains 4 doubles per point. Length = nPoints * 4
360  int AttributeComponents[6];
361  double AttributeScale[6];
362 
363  // Temporary variables for performance
365  double* TempX;
366  double* TempQuad;
367  double* TempB;
368  double** TempA;
369  double* TempData;
370 
371 private:
373  void operator=(const vtkQuadricDecimation&) = delete;
374 
375  // Maximum allowed absolute error for stopping criteria.
376  double MaximumError = VTK_DOUBLE_MAX;
377 };
378 
379 VTK_ABI_NAMESPACE_END
380 #endif
represent and manipulate point attribute data
Definition: vtkPointData.h:30
#define VTK_DOUBLE_MAX
Definition: vtkType.h:202
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
vtkDoubleArray * TargetPoints
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:30
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
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:25
Store zero or more vtkInformation instances.
#define VTK_MARSHALAUTO
RealT t2
Definition: PyrC2Basis.h:22
vtkPriorityQueue * EdgeCosts
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)