VTK  9.3.0
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
47#ifndef vtkQuadricDecimation_h
48#define vtkQuadricDecimation_h
49
50#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
51#include "vtkFiltersCoreModule.h" // For export macro
53
54VTK_ABI_NAMESPACE_BEGIN
55class vtkEdgeTable;
56class vtkIdList;
57class vtkPointData;
59class vtkDoubleArray;
60
61class VTKFILTERSCORE_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
62{
63public:
65 void PrintSelf(ostream& os, vtkIndent indent) override;
67
69
74 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
75 vtkGetMacro(TargetReduction, double);
77
79
84 vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
85 vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
86 vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
88
90
97 vtkSetMacro(VolumePreservation, vtkTypeBool);
98 vtkGetMacro(VolumePreservation, vtkTypeBool);
99 vtkBooleanMacro(VolumePreservation, vtkTypeBool);
101
103
118 vtkSetMacro(Regularize, vtkTypeBool);
119 vtkGetMacro(Regularize, vtkTypeBool);
120 vtkBooleanMacro(Regularize, vtkTypeBool);
121 vtkSetMacro(Regularization, double);
122 vtkGetMacro(Regularization, double);
124
126
134 vtkSetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
135 vtkGetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
136 vtkBooleanMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
137 vtkSetMacro(BoundaryWeightFactor, double);
138 vtkGetMacro(BoundaryWeightFactor, double);
140
142
145 vtkGetMacro(MapPointData, bool);
146 vtkSetMacro(MapPointData, bool);
147 vtkBooleanMacro(MapPointData, bool);
149
151
157 vtkSetMacro(ScalarsAttribute, vtkTypeBool);
158 vtkGetMacro(ScalarsAttribute, vtkTypeBool);
159 vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
160 vtkSetMacro(VectorsAttribute, vtkTypeBool);
161 vtkGetMacro(VectorsAttribute, vtkTypeBool);
162 vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
163 vtkSetMacro(NormalsAttribute, vtkTypeBool);
164 vtkGetMacro(NormalsAttribute, vtkTypeBool);
165 vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
166 vtkSetMacro(TCoordsAttribute, vtkTypeBool);
167 vtkGetMacro(TCoordsAttribute, vtkTypeBool);
168 vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
169 vtkSetMacro(TensorsAttribute, vtkTypeBool);
170 vtkGetMacro(TensorsAttribute, vtkTypeBool);
171 vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
173
175
180 vtkSetMacro(ScalarsWeight, double);
181 vtkSetMacro(VectorsWeight, double);
182 vtkSetMacro(NormalsWeight, double);
183 vtkSetMacro(TCoordsWeight, double);
184 vtkSetMacro(TensorsWeight, double);
185 vtkGetMacro(ScalarsWeight, double);
186 vtkGetMacro(VectorsWeight, double);
187 vtkGetMacro(NormalsWeight, double);
188 vtkGetMacro(TCoordsWeight, double);
189 vtkGetMacro(TensorsWeight, double);
191
193
197 vtkGetMacro(ActualReduction, double);
199
200protected:
203
205
211
216
221
226
231 void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
232
234
238 double ComputeCost(vtkIdType edgeId, double* x);
239 double ComputeCost2(vtkIdType edgeId, double* x);
241
248
253
254 int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
256 const double t0[3], const double t1[3], const double t2[3], const double* x);
259
261
266 VTK_DEPRECATED_IN_9_3_0("Deprecated in favor of the method taking the indexes of both points on "
267 "the edge to interpolate point data")
268 void SetPointAttributeArray(vtkIdType ptId, const double* x);
269 void SetPointAttributeArray(vtkIdType ptId[2], const double* x);
270 void GetPointAttributeArray(vtkIdType ptId, double* x);
272
277 void GetAttributeComponents();
278
279 double TargetReduction;
280 double ActualReduction;
281 vtkTypeBool AttributeErrorMetric;
282 vtkTypeBool VolumePreservation;
283
284 bool MapPointData = false;
285
286 vtkTypeBool ScalarsAttribute;
287 vtkTypeBool VectorsAttribute;
288 vtkTypeBool NormalsAttribute;
289 vtkTypeBool TCoordsAttribute;
290 vtkTypeBool TensorsAttribute;
291
292 double ScalarsWeight;
293 double VectorsWeight;
294 double NormalsWeight;
295 double TCoordsWeight;
296 double TensorsWeight;
297
298 int NumberOfEdgeCollapses;
300 vtkIdList* EndPoint1List;
301 vtkIdList* EndPoint2List;
303 vtkDoubleArray* TargetPoints;
304 int NumberOfComponents;
306
308 {
309 double* Quadric;
310 };
311
312 // One ErrorQuadric per point
314
315 // Controlling regularization behavior
316 vtkTypeBool Regularize = false;
317 double Regularization = 0.05;
318
319 // Controlling the boundary weighting behavior
320 vtkTypeBool WeighBoundaryConstraintsByLength = false;
321 double BoundaryWeightFactor = 1.0;
322
323 // Contains 4 doubles per point. Length = nPoints * 4
325 int AttributeComponents[6];
326 double AttributeScale[6];
327
328 // Temporary variables for performance
330 double* TempX;
331 double* TempQuad;
332 double* TempB;
333 double** TempA;
334 double* TempData;
335
336private:
338 void operator=(const vtkQuadricDecimation&) = delete;
339};
340
341VTK_ABI_NAMESPACE_END
342#endif
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:23
a simple class to control print indentation
Definition vtkIndent.h:29
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
Definition vtkPolyData.h:80
a list of ids arranged in priority order
reduce the number of triangles in a mesh
void AddBoundaryConstraints()
Free boundary edges are weighted.
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.
double ComputeCost2(vtkIdType edgeId, double *x)
Compute cost for contracting this edge and the point that gives us this cost.
static vtkQuadricDecimation * New()
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.
~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)
#define VTK_DEPRECATED_IN_9_3_0(reason)
int vtkIdType
Definition vtkType.h:315