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) VTK_OVERRIDE;
76  static vtkQuadricDecimation *New();
77 
79 
84  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
85  vtkGetMacro(TargetReduction, double);
87 
89 
94  vtkSetMacro(AttributeErrorMetric, int);
95  vtkGetMacro(AttributeErrorMetric, int);
96  vtkBooleanMacro(AttributeErrorMetric, int);
98 
100 
107  vtkSetMacro(VolumePreservation, int);
108  vtkGetMacro(VolumePreservation, int);
109  vtkBooleanMacro(VolumePreservation, int);
111 
113 
119  vtkSetMacro(ScalarsAttribute, int);
120  vtkGetMacro(ScalarsAttribute, int);
121  vtkBooleanMacro(ScalarsAttribute, int);
122  vtkSetMacro(VectorsAttribute, int);
123  vtkGetMacro(VectorsAttribute, int);
124  vtkBooleanMacro(VectorsAttribute, int);
125  vtkSetMacro(NormalsAttribute, int);
126  vtkGetMacro(NormalsAttribute, int);
127  vtkBooleanMacro(NormalsAttribute, int);
128  vtkSetMacro(TCoordsAttribute, int);
129  vtkGetMacro(TCoordsAttribute, int);
130  vtkBooleanMacro(TCoordsAttribute, int);
131  vtkSetMacro(TensorsAttribute, int);
132  vtkGetMacro(TensorsAttribute, int);
133  vtkBooleanMacro(TensorsAttribute, int);
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() VTK_OVERRIDE;
165 
166  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
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 
236  double TargetReduction;
237  double ActualReduction;
238  int AttributeErrorMetric;
239  int VolumePreservation;
240 
241  int ScalarsAttribute;
242  int VectorsAttribute;
243  int NormalsAttribute;
244  int TCoordsAttribute;
245  int TensorsAttribute;
246 
247  double ScalarsWeight;
248  double VectorsWeight;
249  double NormalsWeight;
250  double TCoordsWeight;
251  double TensorsWeight;
252 
253  int NumberOfEdgeCollapses;
254  vtkEdgeTable *Edges;
255  vtkIdList *EndPoint1List;
256  vtkIdList *EndPoint2List;
257  vtkPriorityQueue *EdgeCosts;
258  vtkDoubleArray *TargetPoints;
259  int NumberOfComponents;
260  vtkPolyData *Mesh;
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:
285  vtkQuadricDecimation(const vtkQuadricDecimation&) VTK_DELETE_FUNCTION;
286  void operator=(const vtkQuadricDecimation&) VTK_DELETE_FUNCTION;
287 };
288 
289 #endif
represent and manipulate point attribute data
Definition: vtkPointData.h:37
Store vtkAlgorithm input/output information.
int vtkIdType
Definition: vtkType.h:345
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()
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
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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)