VTK  9.1.0
vtkQuadricDecimation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQuadricDecimation.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
75 #ifndef vtkQuadricDecimation_h
76 #define vtkQuadricDecimation_h
77 
78 #include "vtkFiltersCoreModule.h" // For export macro
79 #include "vtkPolyDataAlgorithm.h"
80 
81 class vtkEdgeTable;
82 class vtkIdList;
83 class vtkPointData;
84 class vtkPriorityQueue;
85 class vtkDoubleArray;
86 
87 class VTKFILTERSCORE_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
88 {
89 public:
91  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
95 
100  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
101  vtkGetMacro(TargetReduction, double);
103 
105 
110  vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
111  vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
112  vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
114 
116 
123  vtkSetMacro(VolumePreservation, vtkTypeBool);
124  vtkGetMacro(VolumePreservation, vtkTypeBool);
125  vtkBooleanMacro(VolumePreservation, vtkTypeBool);
127 
129 
135  vtkSetMacro(ScalarsAttribute, vtkTypeBool);
136  vtkGetMacro(ScalarsAttribute, vtkTypeBool);
137  vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
138  vtkSetMacro(VectorsAttribute, vtkTypeBool);
139  vtkGetMacro(VectorsAttribute, vtkTypeBool);
140  vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
141  vtkSetMacro(NormalsAttribute, vtkTypeBool);
142  vtkGetMacro(NormalsAttribute, vtkTypeBool);
143  vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
144  vtkSetMacro(TCoordsAttribute, vtkTypeBool);
145  vtkGetMacro(TCoordsAttribute, vtkTypeBool);
146  vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
147  vtkSetMacro(TensorsAttribute, vtkTypeBool);
148  vtkGetMacro(TensorsAttribute, vtkTypeBool);
149  vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
151 
153 
158  vtkSetMacro(ScalarsWeight, double);
159  vtkSetMacro(VectorsWeight, double);
160  vtkSetMacro(NormalsWeight, double);
161  vtkSetMacro(TCoordsWeight, double);
162  vtkSetMacro(TensorsWeight, double);
163  vtkGetMacro(ScalarsWeight, double);
164  vtkGetMacro(VectorsWeight, double);
165  vtkGetMacro(NormalsWeight, double);
166  vtkGetMacro(TCoordsWeight, double);
167  vtkGetMacro(TensorsWeight, double);
169 
171 
175  vtkGetMacro(ActualReduction, double);
177 
178 protected:
181 
183 
188  int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id);
189 
194 
199 
203  void ComputeQuadric(vtkIdType pointId);
204 
209  void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
210 
212 
216  double ComputeCost(vtkIdType edgeId, double* x);
217  double ComputeCost2(vtkIdType edgeId, double* x);
219 
226 
231 
232  int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
234  const double t0[3], const double t1[3], const double t2[3], const double* x);
236  void UpdateEdgeData(vtkIdType pt0Id, vtkIdType pt1Id);
237 
239 
242  void SetPointAttributeArray(vtkIdType ptId, const double* x);
243  void GetPointAttributeArray(vtkIdType ptId, double* x);
245 
251 
256 
262 
268 
277 
279  {
280  double* Quadric;
281  };
282 
283  // One ErrorQuadric per point
285 
286  // Contains 4 doubles per point. Length = nPoints * 4
288  int AttributeComponents[6];
289  double AttributeScale[6];
290 
291  // Temporary variables for performance
293  double* TempX;
294  double* TempQuad;
295  double* TempB;
296  double** TempA;
297  double* TempData;
298 
299 private:
301  void operator=(const vtkQuadricDecimation&) = delete;
302 };
303 
304 #endif
dynamic, self-adjusting array of double
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:41
list of point or cell ids
Definition: vtkIdList.h:140
a simple class to control print indentation
Definition: vtkIndent.h:113
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate point attribute data
Definition: vtkPointData.h:142
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
a list of ids arranged in priority order
reduce the number of triangles in a mesh
void SetPointAttributeArray(vtkIdType ptId, const double *x)
Helper function to set and get the point and it's attributes as an array.
void AddBoundaryConstraints(void)
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.
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.
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 ComputeNumberOfComponents(void)
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.
static vtkQuadricDecimation * New()
int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double *x)
void UpdateEdgeData(vtkIdType pt0Id, vtkIdType pt1Id)
int vtkTypeBool
Definition: vtkABI.h:69
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
int vtkIdType
Definition: vtkType.h:332