VTK  9.0.3
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) override;
74 
76 
81  vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
82  vtkGetMacro(TargetReduction, double);
84 
86 
91  vtkSetMacro(AttributeErrorMetric, vtkTypeBool);
92  vtkGetMacro(AttributeErrorMetric, vtkTypeBool);
93  vtkBooleanMacro(AttributeErrorMetric, vtkTypeBool);
95 
97 
104  vtkSetMacro(VolumePreservation, vtkTypeBool);
105  vtkGetMacro(VolumePreservation, vtkTypeBool);
106  vtkBooleanMacro(VolumePreservation, vtkTypeBool);
108 
110 
116  vtkSetMacro(ScalarsAttribute, vtkTypeBool);
117  vtkGetMacro(ScalarsAttribute, vtkTypeBool);
118  vtkBooleanMacro(ScalarsAttribute, vtkTypeBool);
119  vtkSetMacro(VectorsAttribute, vtkTypeBool);
120  vtkGetMacro(VectorsAttribute, vtkTypeBool);
121  vtkBooleanMacro(VectorsAttribute, vtkTypeBool);
122  vtkSetMacro(NormalsAttribute, vtkTypeBool);
123  vtkGetMacro(NormalsAttribute, vtkTypeBool);
124  vtkBooleanMacro(NormalsAttribute, vtkTypeBool);
125  vtkSetMacro(TCoordsAttribute, vtkTypeBool);
126  vtkGetMacro(TCoordsAttribute, vtkTypeBool);
127  vtkBooleanMacro(TCoordsAttribute, vtkTypeBool);
128  vtkSetMacro(TensorsAttribute, vtkTypeBool);
129  vtkGetMacro(TensorsAttribute, vtkTypeBool);
130  vtkBooleanMacro(TensorsAttribute, vtkTypeBool);
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:
162 
164 
169  int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id);
170 
175 
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 
207 
212 
213  int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double* x);
215  const double t0[3], const double t1[3], const double t2[3], const double* x);
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 
232 
237 
243 
249 
258 
260  {
261  double* Quadric;
262  };
263 
264  // One ErrorQuadric per point
266 
267  // Contains 4 doubles per point. Length = nPoints * 4
269  int AttributeComponents[6];
270  double AttributeScale[6];
271 
272  // Temporary variables for performance
274  double* TempX;
275  double* TempQuad;
276  double* TempB;
277  double** TempA;
278  double* TempData;
279 
280 private:
282  void operator=(const vtkQuadricDecimation&) = delete;
283 };
284 
285 #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:31
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate point attribute data
Definition: vtkPointData.h:32
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
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)
void GetPointAttributeArray(vtkIdType ptId, double *x)
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 UpdateEdgeData(vtkIdType ptoId, vtkIdType pt1Id)
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)
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:338