VTK  9.5.20250711
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
67#ifndef vtkQuadricDecimation_h
68#define vtkQuadricDecimation_h
69
70#include "vtkFiltersCoreModule.h" // For export macro
72
73VTK_ABI_NAMESPACE_BEGIN
74class vtkEdgeTable;
75class vtkIdList;
76class vtkPointData;
78class vtkDoubleArray;
79
80class VTKFILTERSCORE_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
81{
82public:
84 void PrintSelf(ostream& os, vtkIndent indent) override;
86
88
94 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
95 vtkGetMacro(TargetReduction, double);
97
99
104 vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
105 vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
106 vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
108
110
117 vtkSetMacro(VolumePreservation, vtkTypeBool);
118 vtkGetMacro(VolumePreservation, vtkTypeBool);
119 vtkBooleanMacro(VolumePreservation, vtkTypeBool);
121
123
128 vtkSetMacro(MaximumError, double);
129 vtkGetMacro(MaximumError, double);
131
133
148 vtkSetMacro(Regularize, vtkTypeBool);
149 vtkGetMacro(Regularize, vtkTypeBool);
150 vtkBooleanMacro(Regularize, vtkTypeBool);
151 vtkSetMacro(Regularization, double);
152 vtkGetMacro(Regularization, double);
154
156
164 vtkSetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
165 vtkGetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
166 vtkBooleanMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
167 vtkSetMacro(BoundaryWeightFactor, double);
168 vtkGetMacro(BoundaryWeightFactor, double);
170
172
177 vtkGetMacro(MapPointData, bool);
178 vtkSetMacro(MapPointData, bool);
179 vtkBooleanMacro(MapPointData, bool);
181
183
189 vtkSetMacro(ScalarsAttribute, vtkTypeBool);
190 vtkGetMacro(ScalarsAttribute, vtkTypeBool);
191 vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
192 vtkSetMacro(VectorsAttribute, vtkTypeBool);
193 vtkGetMacro(VectorsAttribute, vtkTypeBool);
194 vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
195 vtkSetMacro(NormalsAttribute, vtkTypeBool);
196 vtkGetMacro(NormalsAttribute, vtkTypeBool);
197 vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
198 vtkSetMacro(TCoordsAttribute, vtkTypeBool);
199 vtkGetMacro(TCoordsAttribute, vtkTypeBool);
200 vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
201 vtkSetMacro(TensorsAttribute, vtkTypeBool);
202 vtkGetMacro(TensorsAttribute, vtkTypeBool);
203 vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
205
207
212 vtkSetMacro(ScalarsWeight, double);
213 vtkSetMacro(VectorsWeight, double);
214 vtkSetMacro(NormalsWeight, double);
215 vtkSetMacro(TCoordsWeight, double);
216 vtkSetMacro(TensorsWeight, double);
217 vtkGetMacro(ScalarsWeight, double);
218 vtkGetMacro(VectorsWeight, double);
219 vtkGetMacro(NormalsWeight, double);
220 vtkGetMacro(TCoordsWeight, double);
221 vtkGetMacro(TensorsWeight, double);
223
225
229 vtkGetMacro(ActualReduction, double);
231
232protected:
235
237
243
248
253
258
263 void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
264
266
270 double ComputeCost(vtkIdType edgeId, double* x);
271 double ComputeCost2(vtkIdType edgeId, double* x);
273
280
285
286 int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
288 const double t0[3], const double t1[3], const double t2[3], const double* x);
291
293
298 void SetPointCoordinates(vtkIdType ptId, const double* x);
299
308 void SetPointActiveAttributes(vtkIdType ptId, const double* x);
309
322 void SetPointAttributeArray(vtkIdType ptId[2], const double* x);
323 void GetPointAttributeArray(vtkIdType ptId, double* x);
325
331
336
337 bool MapPointData = false;
338
344
350
359
361 {
362 double* Quadric;
363 };
364
365 // One ErrorQuadric per point
367
368 // Controlling regularization behavior
369 vtkTypeBool Regularize = false;
370 double Regularization = 0.05;
371
372 // Controlling the boundary weighting behavior
373 vtkTypeBool WeighBoundaryConstraintsByLength = false;
374 double BoundaryWeightFactor = 1.0;
375
376 // Contains 4 doubles per point. Length = nPoints * 4
378 int AttributeComponents[6];
379 double AttributeScale[6];
380
381 // Temporary variables for performance
383 double* TempX;
384 double* TempQuad;
385 double* TempB;
386 double** TempA;
387 double* TempData;
388
389private:
391 void operator=(const vtkQuadricDecimation&) = delete;
392
393 // Maximum allowed absolute error for stopping criteria.
394 double MaximumError = VTK_DOUBLE_MAX;
395};
396
397VTK_ABI_NAMESPACE_END
398#endif
RealT t2
Definition PyrC2Basis.h:22
dynamic, self-adjusting array of double
keep track of edges (edge is pair of integer id's)
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
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
reduce the number of triangles in a mesh
void SetPointAttributeArray(vtkIdType ptId[2], const double *x)
Helper function to set and get the point and it's attributes as an array.
void AddBoundaryConstraints()
Free boundary edges are weighted.
vtkDoubleArray * TargetPoints
void FindAffectedEdges(vtkIdType p1Id, vtkIdType p2Id, vtkIdList *edges)
Find all edges that will have an endpoint change ids because of an edge collapse.
void ComputeNumberOfComponents()
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void ComputeQuadric(vtkIdType pointId)
Compute quadric for this vertex.
void GetAttributeComponents()
Find out how many components there are for each attribute for this poly data.
void SetPointCoordinates(vtkIdType ptId, const double *x)
Helper function to set the new point coordinates.
double ComputeCost2(vtkIdType edgeId, double *x)
Compute cost for contracting this edge and the point that gives us this cost.
static vtkQuadricDecimation * New()
void GetPointAttributeArray(vtkIdType ptId, double *x)
Helper function to set the new point coordinates.
vtkIdType GetEdgeCellId(vtkIdType p1Id, vtkIdType p2Id)
Find a cell that uses this edge.
double ComputeCost(vtkIdType edgeId, double *x)
Compute cost for contracting this edge and the point that gives us this cost.
int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id)
Do the dirty work of eliminating the edge; return the number of triangles deleted.
vtkPriorityQueue * EdgeCosts
~vtkQuadricDecimation() override
int TrianglePlaneCheck(const double t0[3], const double t1[3], const double t2[3], const double *x)
void SetPointActiveAttributes(vtkIdType ptId, const double *x)
Helper function to set the point coordinates and it's attributes.
void InitializeQuadrics(vtkIdType numPts)
Compute quadric for all vertices.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId)
Add the quadrics for these 2 points since the edge between them has been collapsed.
int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double *x)
void UpdateEdgeData(vtkIdType pt0Id, vtkIdType pt1Id)
int vtkTypeBool
Definition vtkABI.h:64
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
int vtkIdType
Definition vtkType.h:332
#define VTK_DOUBLE_MAX
Definition vtkType.h:171