VTK
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 =========================================================================*/
59 #ifndef vtkQuadricDecimation_h
60 #define vtkQuadricDecimation_h
61 
62 #include "vtkFiltersCoreModule.h" // For export macro
63 #include "vtkPolyDataAlgorithm.h"
64 
65 class vtkEdgeTable;
66 class vtkIdList;
67 class vtkPointData;
68 class vtkPriorityQueue;
69 class vtkDoubleArray;
70 
71 class VTKFILTERSCORE_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
72 {
73 public:
75  void PrintSelf(ostream& os, vtkIndent indent) override;
76  static vtkQuadricDecimation *New();
77 
79 
84  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
85  vtkGetMacro(TargetReduction, double);
87 
89 
94  vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
95  vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
96  vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
98 
100 
107  vtkSetMacro(VolumePreservation, vtkTypeBool);
108  vtkGetMacro(VolumePreservation, vtkTypeBool);
109  vtkBooleanMacro(VolumePreservation, vtkTypeBool);
111 
113 
119  vtkSetMacro(ScalarsAttribute, vtkTypeBool);
120  vtkGetMacro(ScalarsAttribute, vtkTypeBool);
121  vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
122  vtkSetMacro(VectorsAttribute, vtkTypeBool);
123  vtkGetMacro(VectorsAttribute, vtkTypeBool);
124  vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
125  vtkSetMacro(NormalsAttribute, vtkTypeBool);
126  vtkGetMacro(NormalsAttribute, vtkTypeBool);
127  vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
128  vtkSetMacro(TCoordsAttribute, vtkTypeBool);
129  vtkGetMacro(TCoordsAttribute, vtkTypeBool);
130  vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
131  vtkSetMacro(TensorsAttribute, vtkTypeBool);
132  vtkGetMacro(TensorsAttribute, vtkTypeBool);
133  vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
135 
137 
142  vtkSetMacro(ScalarsWeight, double);
143  vtkSetMacro(VectorsWeight, double);
144  vtkSetMacro(NormalsWeight, double);
145  vtkSetMacro(TCoordsWeight, double);
146  vtkSetMacro(TensorsWeight, double);
147  vtkGetMacro(ScalarsWeight, double);
148  vtkGetMacro(VectorsWeight, double);
149  vtkGetMacro(NormalsWeight, double);
150  vtkGetMacro(TCoordsWeight, double);
151  vtkGetMacro(TensorsWeight, double);
153 
155 
159  vtkGetMacro(ActualReduction, double);
161 
162 protected:
164  ~vtkQuadricDecimation() override;
165 
167 
172  int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id);
173 
177  void InitializeQuadrics(vtkIdType numPts);
178 
182  void AddBoundaryConstraints(void);
183 
187  void ComputeQuadric(vtkIdType pointId);
188 
193  void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
194 
196 
200  double ComputeCost(vtkIdType edgeId, double *x);
201  double ComputeCost2(vtkIdType edgeId, double *x);
203 
209  void FindAffectedEdges(vtkIdType p1Id, vtkIdType p2Id, vtkIdList *edges);
210 
214  vtkIdType GetEdgeCellId(vtkIdType p1Id, vtkIdType p2Id);
215 
216  int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double *x);
217  int TrianglePlaneCheck(const double t0[3], const double t1[3],
218  const double t2[3], const double *x);
219  void ComputeNumberOfComponents(void);
220  void UpdateEdgeData(vtkIdType ptoId, vtkIdType pt1Id);
221 
223 
226  void SetPointAttributeArray(vtkIdType ptId, const double *x);
227  void GetPointAttributeArray(vtkIdType ptId, double *x);
229 
234  void GetAttributeComponents();
235 
240 
246 
252 
261 
263  {
264  double *Quadric;
265  };
266 
267 
268  // One ErrorQuadric per point
270 
271  // Contains 4 doubles per point. Length = nPoints * 4
273  int AttributeComponents[6];
274  double AttributeScale[6];
275 
276  // Temporary variables for performance
278  double *TempX;
279  double *TempQuad;
280  double *TempB;
281  double **TempA;
282  double *TempData;
283 
284 private:
286  void operator=(const vtkQuadricDecimation&) = delete;
287 };
288 
289 #endif
represent and manipulate point attribute data
Definition: vtkPointData.h:37
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
vtkDoubleArray * TargetPoints
int vtkIdType
Definition: vtkType.h:347
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:40
dynamic, self-adjusting array of double
a list of ids arranged in priority order
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:69
reduce the number of triangles in a mesh
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:39
list of point or cell ids
Definition: vtkIdList.h:36
Store zero or more vtkInformation instances.
vtkPriorityQueue * EdgeCosts
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)