VTK  9.5.20250904
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#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
73
74VTK_ABI_NAMESPACE_BEGIN
75class vtkEdgeTable;
76class vtkIdList;
77class vtkPointData;
79class vtkDoubleArray;
80
81class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkQuadricDecimation : public vtkPolyDataAlgorithm
82{
83public:
85 void PrintSelf(ostream& os, vtkIndent indent) override;
87
89
95 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
96 vtkGetMacro(TargetReduction, double);
98
100
105 vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
106 vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
107 vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
109
111
118 vtkSetMacro(VolumePreservation, vtkTypeBool);
119 vtkGetMacro(VolumePreservation, vtkTypeBool);
120 vtkBooleanMacro(VolumePreservation, vtkTypeBool);
122
124
129 vtkSetMacro(MaximumError, double);
130 vtkGetMacro(MaximumError, double);
132
134
149 vtkSetMacro(Regularize, vtkTypeBool);
150 vtkGetMacro(Regularize, vtkTypeBool);
151 vtkBooleanMacro(Regularize, vtkTypeBool);
152 vtkSetMacro(Regularization, double);
153 vtkGetMacro(Regularization, double);
155
157
165 vtkSetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
166 vtkGetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
167 vtkBooleanMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
168 vtkSetMacro(BoundaryWeightFactor, double);
169 vtkGetMacro(BoundaryWeightFactor, double);
171
173
178 vtkGetMacro(MapPointData, bool);
179 vtkSetMacro(MapPointData, bool);
180 vtkBooleanMacro(MapPointData, bool);
182
184
190 vtkSetMacro(ScalarsAttribute, vtkTypeBool);
191 vtkGetMacro(ScalarsAttribute, vtkTypeBool);
192 vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
193 vtkSetMacro(VectorsAttribute, vtkTypeBool);
194 vtkGetMacro(VectorsAttribute, vtkTypeBool);
195 vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
196 vtkSetMacro(NormalsAttribute, vtkTypeBool);
197 vtkGetMacro(NormalsAttribute, vtkTypeBool);
198 vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
199 vtkSetMacro(TCoordsAttribute, vtkTypeBool);
200 vtkGetMacro(TCoordsAttribute, vtkTypeBool);
201 vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
202 vtkSetMacro(TensorsAttribute, vtkTypeBool);
203 vtkGetMacro(TensorsAttribute, vtkTypeBool);
204 vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
206
208
213 vtkSetMacro(ScalarsWeight, double);
214 vtkSetMacro(VectorsWeight, double);
215 vtkSetMacro(NormalsWeight, double);
216 vtkSetMacro(TCoordsWeight, double);
217 vtkSetMacro(TensorsWeight, double);
218 vtkGetMacro(ScalarsWeight, double);
219 vtkGetMacro(VectorsWeight, double);
220 vtkGetMacro(NormalsWeight, double);
221 vtkGetMacro(TCoordsWeight, double);
222 vtkGetMacro(TensorsWeight, double);
224
226
230 vtkGetMacro(ActualReduction, double);
232
233protected:
236
238
244
249
254
259
264 void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
265
267
271 double ComputeCost(vtkIdType edgeId, double* x);
272 double ComputeCost2(vtkIdType edgeId, double* x);
274
281
286
287 int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
289 const double t0[3], const double t1[3], const double t2[3], const double* x);
292
294
299 void SetPointCoordinates(vtkIdType ptId, const double* x);
300
309 void SetPointActiveAttributes(vtkIdType ptId, const double* x);
310
323 void SetPointAttributeArray(vtkIdType ptId[2], const double* x);
324 void GetPointAttributeArray(vtkIdType ptId, double* x);
326
332
337
338 bool MapPointData = false;
339
345
351
360
362 {
363 double* Quadric;
364 };
365
366 // One ErrorQuadric per point
368
369 // Controlling regularization behavior
370 vtkTypeBool Regularize = false;
371 double Regularization = 0.05;
372
373 // Controlling the boundary weighting behavior
374 vtkTypeBool WeighBoundaryConstraintsByLength = false;
375 double BoundaryWeightFactor = 1.0;
376
377 // Contains 4 doubles per point. Length = nPoints * 4
379 int AttributeComponents[6];
380 double AttributeScale[6];
381
382 // Temporary variables for performance
384 double* TempX;
385 double* TempQuad;
386 double* TempB;
387 double** TempA;
388 double* TempData;
389
390private:
392 void operator=(const vtkQuadricDecimation&) = delete;
393
394 // Maximum allowed absolute error for stopping criteria.
395 double MaximumError = VTK_DOUBLE_MAX;
396};
397
398VTK_ABI_NAMESPACE_END
399#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
#define VTK_MARSHALAUTO