VTK  9.4.20241217
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
66#ifndef vtkQuadricDecimation_h
67#define vtkQuadricDecimation_h
68
69#include "vtkFiltersCoreModule.h" // For export macro
71
72VTK_ABI_NAMESPACE_BEGIN
73class vtkEdgeTable;
74class vtkIdList;
75class vtkPointData;
77class vtkDoubleArray;
78
79class VTKFILTERSCORE_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
80{
81public:
83 void PrintSelf(ostream& os, vtkIndent indent) override;
85
87
92 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
93 vtkGetMacro(TargetReduction, double);
95
97
102 vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
103 vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
104 vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
106
108
115 vtkSetMacro(VolumePreservation, vtkTypeBool);
116 vtkGetMacro(VolumePreservation, vtkTypeBool);
117 vtkBooleanMacro(VolumePreservation, vtkTypeBool);
119
121
136 vtkSetMacro(Regularize, vtkTypeBool);
137 vtkGetMacro(Regularize, vtkTypeBool);
138 vtkBooleanMacro(Regularize, vtkTypeBool);
139 vtkSetMacro(Regularization, double);
140 vtkGetMacro(Regularization, double);
142
144
152 vtkSetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
153 vtkGetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
154 vtkBooleanMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
155 vtkSetMacro(BoundaryWeightFactor, double);
156 vtkGetMacro(BoundaryWeightFactor, double);
158
160
163 vtkGetMacro(MapPointData, bool);
164 vtkSetMacro(MapPointData, bool);
165 vtkBooleanMacro(MapPointData, bool);
167
169
175 vtkSetMacro(ScalarsAttribute, vtkTypeBool);
176 vtkGetMacro(ScalarsAttribute, vtkTypeBool);
177 vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
178 vtkSetMacro(VectorsAttribute, vtkTypeBool);
179 vtkGetMacro(VectorsAttribute, vtkTypeBool);
180 vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
181 vtkSetMacro(NormalsAttribute, vtkTypeBool);
182 vtkGetMacro(NormalsAttribute, vtkTypeBool);
183 vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
184 vtkSetMacro(TCoordsAttribute, vtkTypeBool);
185 vtkGetMacro(TCoordsAttribute, vtkTypeBool);
186 vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
187 vtkSetMacro(TensorsAttribute, vtkTypeBool);
188 vtkGetMacro(TensorsAttribute, vtkTypeBool);
189 vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
191
193
198 vtkSetMacro(ScalarsWeight, double);
199 vtkSetMacro(VectorsWeight, double);
200 vtkSetMacro(NormalsWeight, double);
201 vtkSetMacro(TCoordsWeight, double);
202 vtkSetMacro(TensorsWeight, double);
203 vtkGetMacro(ScalarsWeight, double);
204 vtkGetMacro(VectorsWeight, double);
205 vtkGetMacro(NormalsWeight, double);
206 vtkGetMacro(TCoordsWeight, double);
207 vtkGetMacro(TensorsWeight, double);
209
211
215 vtkGetMacro(ActualReduction, double);
217
218protected:
221
223
229
234
239
244
249 void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
250
252
256 double ComputeCost(vtkIdType edgeId, double* x);
257 double ComputeCost2(vtkIdType edgeId, double* x);
259
266
271
272 int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
274 const double t0[3], const double t1[3], const double t2[3], const double* x);
277
279
284 void SetPointAttributeArray(vtkIdType ptId[2], const double* x);
285 void GetPointAttributeArray(vtkIdType ptId, double* x);
287
293
298
299 bool MapPointData = false;
300
306
312
321
323 {
324 double* Quadric;
325 };
326
327 // One ErrorQuadric per point
329
330 // Controlling regularization behavior
331 vtkTypeBool Regularize = false;
332 double Regularization = 0.05;
333
334 // Controlling the boundary weighting behavior
335 vtkTypeBool WeighBoundaryConstraintsByLength = false;
336 double BoundaryWeightFactor = 1.0;
337
338 // Contains 4 doubles per point. Length = nPoints * 4
340 int AttributeComponents[6];
341 double AttributeScale[6];
342
343 // Temporary variables for performance
345 double* TempX;
346 double* TempQuad;
347 double* TempB;
348 double** TempA;
349 double* TempData;
350
351private:
353 void operator=(const vtkQuadricDecimation&) = delete;
354};
355
356VTK_ABI_NAMESPACE_END
357#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:315