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
56#ifndef vtkQuadricDecimation_h
57#define vtkQuadricDecimation_h
58
59#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
60#include "vtkFiltersCoreModule.h" // For export macro
62
63VTK_ABI_NAMESPACE_BEGIN
64class vtkEdgeTable;
65class vtkIdList;
66class vtkPointData;
68class vtkDoubleArray;
69
70class VTKFILTERSCORE_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
71{
72public:
74 void PrintSelf(ostream& os, vtkIndent indent) override;
76
78
83 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
84 vtkGetMacro(TargetReduction, double);
86
88
93 vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
94 vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
95 vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
97
99
106 vtkSetMacro(VolumePreservation, vtkTypeBool);
107 vtkGetMacro(VolumePreservation, vtkTypeBool);
108 vtkBooleanMacro(VolumePreservation, vtkTypeBool);
110
112
127 vtkSetMacro(Regularize, vtkTypeBool);
128 vtkGetMacro(Regularize, vtkTypeBool);
129 vtkBooleanMacro(Regularize, vtkTypeBool);
130 vtkSetMacro(Regularization, double);
131 vtkGetMacro(Regularization, double);
133
135
143 vtkSetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
144 vtkGetMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
145 vtkBooleanMacro(WeighBoundaryConstraintsByLength, vtkTypeBool);
146 vtkSetMacro(BoundaryWeightFactor, double);
147 vtkGetMacro(BoundaryWeightFactor, double);
149
151
154 vtkGetMacro(MapPointData, bool);
155 vtkSetMacro(MapPointData, bool);
156 vtkBooleanMacro(MapPointData, bool);
158
160
166 vtkSetMacro(ScalarsAttribute, vtkTypeBool);
167 vtkGetMacro(ScalarsAttribute, vtkTypeBool);
168 vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
169 vtkSetMacro(VectorsAttribute, vtkTypeBool);
170 vtkGetMacro(VectorsAttribute, vtkTypeBool);
171 vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
172 vtkSetMacro(NormalsAttribute, vtkTypeBool);
173 vtkGetMacro(NormalsAttribute, vtkTypeBool);
174 vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
175 vtkSetMacro(TCoordsAttribute, vtkTypeBool);
176 vtkGetMacro(TCoordsAttribute, vtkTypeBool);
177 vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
178 vtkSetMacro(TensorsAttribute, vtkTypeBool);
179 vtkGetMacro(TensorsAttribute, vtkTypeBool);
180 vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
182
184
189 vtkSetMacro(ScalarsWeight, double);
190 vtkSetMacro(VectorsWeight, double);
191 vtkSetMacro(NormalsWeight, double);
192 vtkSetMacro(TCoordsWeight, double);
193 vtkSetMacro(TensorsWeight, double);
194 vtkGetMacro(ScalarsWeight, double);
195 vtkGetMacro(VectorsWeight, double);
196 vtkGetMacro(NormalsWeight, double);
197 vtkGetMacro(TCoordsWeight, double);
198 vtkGetMacro(TensorsWeight, double);
200
202
206 vtkGetMacro(ActualReduction, double);
208
209protected:
212
214
220
225
230
235
240 void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
241
243
247 double ComputeCost(vtkIdType edgeId, double* x);
248 double ComputeCost2(vtkIdType edgeId, double* x);
250
257
262
263 int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
265 const double t0[3], const double t1[3], const double t2[3], const double* x);
268
270
275 VTK_DEPRECATED_IN_9_3_0("Deprecated in favor of the method taking the indexes of both points on "
276 "the edge to interpolate point data")
277 void SetPointAttributeArray(vtkIdType ptId, const double* x);
278 void SetPointAttributeArray(vtkIdType ptId[2], const double* x);
279 void GetPointAttributeArray(vtkIdType ptId, double* x);
281
286 void GetAttributeComponents();
287
288 double TargetReduction;
289 double ActualReduction;
290 vtkTypeBool AttributeErrorMetric;
291 vtkTypeBool VolumePreservation;
292
293 bool MapPointData = false;
294
295 vtkTypeBool ScalarsAttribute;
296 vtkTypeBool VectorsAttribute;
297 vtkTypeBool NormalsAttribute;
298 vtkTypeBool TCoordsAttribute;
299 vtkTypeBool TensorsAttribute;
300
301 double ScalarsWeight;
302 double VectorsWeight;
303 double NormalsWeight;
304 double TCoordsWeight;
305 double TensorsWeight;
306
307 int NumberOfEdgeCollapses;
309 vtkIdList* EndPoint1List;
310 vtkIdList* EndPoint2List;
312 vtkDoubleArray* TargetPoints;
313 int NumberOfComponents;
315
317 {
318 double* Quadric;
319 };
320
321 // One ErrorQuadric per point
323
324 // Controlling regularization behavior
325 vtkTypeBool Regularize = false;
326 double Regularization = 0.05;
327
328 // Controlling the boundary weighting behavior
329 vtkTypeBool WeighBoundaryConstraintsByLength = false;
330 double BoundaryWeightFactor = 1.0;
331
332 // Contains 4 doubles per point. Length = nPoints * 4
334 int AttributeComponents[6];
335 double AttributeScale[6];
336
337 // Temporary variables for performance
339 double* TempX;
340 double* TempQuad;
341 double* TempB;
342 double** TempA;
343 double* TempData;
344
345private:
347 void operator=(const vtkQuadricDecimation&) = delete;
348};
349
350VTK_ABI_NAMESPACE_END
351#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:32
a simple class to control print indentation
Definition vtkIndent.h:38
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:89
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