VTK  9.4.20250322
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
93 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
94 vtkGetMacro(TargetReduction, double);
96
98
103 vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
104 vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
105 vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
107
109
116 vtkSetMacro(VolumePreservation, vtkTypeBool);
117 vtkGetMacro(VolumePreservation, vtkTypeBool);
118 vtkBooleanMacro(VolumePreservation, vtkTypeBool);
120
122
137 vtkSetMacro(Regularize, vtkTypeBool);
138 vtkGetMacro(Regularize, vtkTypeBool);
139 vtkBooleanMacro(Regularize, vtkTypeBool);
140 vtkSetMacro(Regularization, double);
141 vtkGetMacro(Regularization, double);
143
145
153 vtkSetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
154 vtkGetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
155 vtkBooleanMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
156 vtkSetMacro(BoundaryWeightFactor, double);
157 vtkGetMacro(BoundaryWeightFactor, double);
159
161
166 vtkGetMacro(MapPointData, bool);
167 vtkSetMacro(MapPointData, bool);
168 vtkBooleanMacro(MapPointData, bool);
170
172
178 vtkSetMacro(ScalarsAttribute, vtkTypeBool);
179 vtkGetMacro(ScalarsAttribute, vtkTypeBool);
180 vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
181 vtkSetMacro(VectorsAttribute, vtkTypeBool);
182 vtkGetMacro(VectorsAttribute, vtkTypeBool);
183 vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
184 vtkSetMacro(NormalsAttribute, vtkTypeBool);
185 vtkGetMacro(NormalsAttribute, vtkTypeBool);
186 vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
187 vtkSetMacro(TCoordsAttribute, vtkTypeBool);
188 vtkGetMacro(TCoordsAttribute, vtkTypeBool);
189 vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
190 vtkSetMacro(TensorsAttribute, vtkTypeBool);
191 vtkGetMacro(TensorsAttribute, vtkTypeBool);
192 vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
194
196
201 vtkSetMacro(ScalarsWeight, double);
202 vtkSetMacro(VectorsWeight, double);
203 vtkSetMacro(NormalsWeight, double);
204 vtkSetMacro(TCoordsWeight, double);
205 vtkSetMacro(TensorsWeight, double);
206 vtkGetMacro(ScalarsWeight, double);
207 vtkGetMacro(VectorsWeight, double);
208 vtkGetMacro(NormalsWeight, double);
209 vtkGetMacro(TCoordsWeight, double);
210 vtkGetMacro(TensorsWeight, double);
212
214
218 vtkGetMacro(ActualReduction, double);
220
221protected:
224
226
232
237
242
247
252 void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
253
255
259 double ComputeCost(vtkIdType edgeId, double* x);
260 double ComputeCost2(vtkIdType edgeId, double* x);
262
269
274
275 int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
277 const double t0[3], const double t1[3], const double t2[3], const double* x);
280
282
287 void SetPointAttributeArray(vtkIdType ptId[2], const double* x);
288 void GetPointAttributeArray(vtkIdType ptId, double* x);
290
296
301
302 bool MapPointData = false;
303
309
315
324
326 {
327 double* Quadric;
328 };
329
330 // One ErrorQuadric per point
332
333 // Controlling regularization behavior
334 vtkTypeBool Regularize = false;
335 double Regularization = 0.05;
336
337 // Controlling the boundary weighting behavior
338 vtkTypeBool WeighBoundaryConstraintsByLength = false;
339 double BoundaryWeightFactor = 1.0;
340
341 // Contains 4 doubles per point. Length = nPoints * 4
343 int AttributeComponents[6];
344 double AttributeScale[6];
345
346 // Temporary variables for performance
348 double* TempX;
349 double* TempQuad;
350 double* TempB;
351 double** TempA;
352 double* TempData;
353
354private:
356 void operator=(const vtkQuadricDecimation&) = delete;
357};
358
359VTK_ABI_NAMESPACE_END
360#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.
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 and get the point and it's attributes as an array.
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 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