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 =========================================================================*/
56 #ifndef vtkQuadricDecimation_h
57 #define vtkQuadricDecimation_h
58 
59 #include "vtkFiltersCoreModule.h" // For export macro
60 #include "vtkPolyDataAlgorithm.h"
61 
62 class vtkEdgeTable;
63 class vtkIdList;
64 class vtkPointData;
65 class vtkPriorityQueue;
66 class vtkDoubleArray;
67 
68 class VTKFILTERSCORE_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
69 {
70 public:
72  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
73  static vtkQuadricDecimation *New();
74 
76 
81  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
82  vtkGetMacro(TargetReduction, double);
84 
86 
91  vtkSetMacro(AttributeErrorMetric, int);
92  vtkGetMacro(AttributeErrorMetric, int);
93  vtkBooleanMacro(AttributeErrorMetric, int);
95 
97 
104  vtkSetMacro(VolumePreservation, int);
105  vtkGetMacro(VolumePreservation, int);
106  vtkBooleanMacro(VolumePreservation, int);
108 
110 
116  vtkSetMacro(ScalarsAttribute, int);
117  vtkGetMacro(ScalarsAttribute, int);
118  vtkBooleanMacro(ScalarsAttribute, int);
119  vtkSetMacro(VectorsAttribute, int);
120  vtkGetMacro(VectorsAttribute, int);
121  vtkBooleanMacro(VectorsAttribute, int);
122  vtkSetMacro(NormalsAttribute, int);
123  vtkGetMacro(NormalsAttribute, int);
124  vtkBooleanMacro(NormalsAttribute, int);
125  vtkSetMacro(TCoordsAttribute, int);
126  vtkGetMacro(TCoordsAttribute, int);
127  vtkBooleanMacro(TCoordsAttribute, int);
128  vtkSetMacro(TensorsAttribute, int);
129  vtkGetMacro(TensorsAttribute, int);
130  vtkBooleanMacro(TensorsAttribute, int);
132 
134 
139  vtkSetMacro(ScalarsWeight, double);
140  vtkSetMacro(VectorsWeight, double);
141  vtkSetMacro(NormalsWeight, double);
142  vtkSetMacro(TCoordsWeight, double);
143  vtkSetMacro(TensorsWeight, double);
144  vtkGetMacro(ScalarsWeight, double);
145  vtkGetMacro(VectorsWeight, double);
146  vtkGetMacro(NormalsWeight, double);
147  vtkGetMacro(TCoordsWeight, double);
148  vtkGetMacro(TensorsWeight, double);
150 
152 
156  vtkGetMacro(ActualReduction, double);
158 
159 protected:
161  ~vtkQuadricDecimation() VTK_OVERRIDE;
162 
163  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
164 
169  int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id);
170 
174  void InitializeQuadrics(vtkIdType numPts);
175 
179  void AddBoundaryConstraints(void);
180 
184  void ComputeQuadric(vtkIdType pointId);
185 
190  void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
191 
193 
197  double ComputeCost(vtkIdType edgeId, double *x);
198  double ComputeCost2(vtkIdType edgeId, double *x);
200 
206  void FindAffectedEdges(vtkIdType p1Id, vtkIdType p2Id, vtkIdList *edges);
207 
211  vtkIdType GetEdgeCellId(vtkIdType p1Id, vtkIdType p2Id);
212 
213  int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double *x);
214  int TrianglePlaneCheck(const double t0[3], const double t1[3],
215  const double t2[3], const double *x);
216  void ComputeNumberOfComponents(void);
217  void UpdateEdgeData(vtkIdType ptoId, vtkIdType pt1Id);
218 
220 
223  void SetPointAttributeArray(vtkIdType ptId, const double *x);
224  void GetPointAttributeArray(vtkIdType ptId, double *x);
226 
231  void GetAttributeComponents();
232 
233  double TargetReduction;
234  double ActualReduction;
235  int AttributeErrorMetric;
236  int VolumePreservation;
237 
238  int ScalarsAttribute;
239  int VectorsAttribute;
240  int NormalsAttribute;
241  int TCoordsAttribute;
242  int TensorsAttribute;
243 
244  double ScalarsWeight;
245  double VectorsWeight;
246  double NormalsWeight;
247  double TCoordsWeight;
248  double TensorsWeight;
249 
250  int NumberOfEdgeCollapses;
251  vtkEdgeTable *Edges;
252  vtkIdList *EndPoint1List;
253  vtkIdList *EndPoint2List;
254  vtkPriorityQueue *EdgeCosts;
255  vtkDoubleArray *TargetPoints;
256  int NumberOfComponents;
257  vtkPolyData *Mesh;
258 
260  {
261  double *Quadric;
262  };
263 
264 
265  // One ErrorQuadric per point
267 
268  // Contains 4 doubles per point. Length = nPoints * 4
270  int AttributeComponents[6];
271  double AttributeScale[6];
272 
273  // Temporary variables for performance
275  double *TempX;
276  double *TempQuad;
277  double *TempB;
278  double **TempA;
279  double *TempData;
280 
281 private:
282  vtkQuadricDecimation(const vtkQuadricDecimation&) VTK_DELETE_FUNCTION;
283  void operator=(const vtkQuadricDecimation&) VTK_DELETE_FUNCTION;
284 };
285 
286 #endif
represent and manipulate point attribute data
Definition: vtkPointData.h:31
Store vtkAlgorithm input/output information.
int vtkIdType
Definition: vtkType.h:345
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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:33
list of point or cell ids
Definition: vtkIdList.h:30
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)