00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00058 #ifndef __vtkQuadricDecimation_h
00059 #define __vtkQuadricDecimation_h
00060
00061 #include "vtkPolyDataAlgorithm.h"
00062
00063 class vtkEdgeTable;
00064 class vtkIdList;
00065 class vtkPointData;
00066 class vtkPriorityQueue;
00067 class vtkDoubleArray;
00068
00069 class VTK_GRAPHICS_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
00070 {
00071 public:
00072 vtkTypeMacro(vtkQuadricDecimation, vtkPolyDataAlgorithm);
00073 void PrintSelf(ostream& os, vtkIndent indent);
00074 static vtkQuadricDecimation *New();
00075
00077
00080 vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
00081 vtkGetMacro(TargetReduction, double);
00083
00085
00088 vtkSetMacro(AttributeErrorMetric, int);
00089 vtkGetMacro(AttributeErrorMetric, int);
00090 vtkBooleanMacro(AttributeErrorMetric, int);
00092
00094
00098 vtkSetMacro(ScalarsAttribute, int);
00099 vtkGetMacro(ScalarsAttribute, int);
00100 vtkBooleanMacro(ScalarsAttribute, int);
00101 vtkSetMacro(VectorsAttribute, int);
00102 vtkGetMacro(VectorsAttribute, int);
00103 vtkBooleanMacro(VectorsAttribute, int);
00104 vtkSetMacro(NormalsAttribute, int);
00105 vtkGetMacro(NormalsAttribute, int);
00106 vtkBooleanMacro(NormalsAttribute, int);
00107 vtkSetMacro(TCoordsAttribute, int);
00108 vtkGetMacro(TCoordsAttribute, int);
00109 vtkBooleanMacro(TCoordsAttribute, int);
00110 vtkSetMacro(TensorsAttribute, int);
00111 vtkGetMacro(TensorsAttribute, int);
00112 vtkBooleanMacro(TensorsAttribute, int);
00114
00116
00119 vtkSetMacro(ScalarsWeight, double);
00120 vtkSetMacro(VectorsWeight, double);
00121 vtkSetMacro(NormalsWeight, double);
00122 vtkSetMacro(TCoordsWeight, double);
00123 vtkSetMacro(TensorsWeight, double);
00124 vtkGetMacro(ScalarsWeight, double);
00125 vtkGetMacro(VectorsWeight, double);
00126 vtkGetMacro(NormalsWeight, double);
00127 vtkGetMacro(TCoordsWeight, double);
00128 vtkGetMacro(TensorsWeight, double);
00130
00132
00134 vtkGetMacro(ActualReduction, double);
00136
00137 protected:
00138 vtkQuadricDecimation();
00139 ~vtkQuadricDecimation();
00140
00141 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00142
00145 int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id);
00146
00148 void InitializeQuadrics(vtkIdType numPts);
00149
00151 void AddBoundaryConstraints(void);
00152
00154 void ComputeQuadric(vtkIdType pointId);
00155
00158 void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
00159
00161
00163 double ComputeCost(vtkIdType edgeId, double *x);
00164 double ComputeCost2(vtkIdType edgeId, double *x);
00166
00170 void FindAffectedEdges(vtkIdType p1Id, vtkIdType p2Id, vtkIdList *edges);
00171
00173 vtkIdType GetEdgeCellId(vtkIdType p1Id, vtkIdType p2Id);
00174
00175 int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double *x);
00176 int TrianglePlaneCheck(const double t0[3], const double t1[3],
00177 const double t2[3], const double *x);
00178 void ComputeNumberOfComponents(void);
00179 void UpdateEdgeData(vtkIdType ptoId, vtkIdType pt1Id);
00180
00182
00184 void SetPointAttributeArray(vtkIdType ptId, const double *x);
00185 void GetPointAttributeArray(vtkIdType ptId, double *x);
00187
00190 void GetAttributeComponents();
00191
00192 double TargetReduction;
00193 double ActualReduction;
00194 int AttributeErrorMetric;
00195
00196 int ScalarsAttribute;
00197 int VectorsAttribute;
00198 int NormalsAttribute;
00199 int TCoordsAttribute;
00200 int TensorsAttribute;
00201
00202 double ScalarsWeight;
00203 double VectorsWeight;
00204 double NormalsWeight;
00205 double TCoordsWeight;
00206 double TensorsWeight;
00207
00208 int NumberOfEdgeCollapses;
00209 vtkEdgeTable *Edges;
00210 vtkIdList *EndPoint1List;
00211 vtkIdList *EndPoint2List;
00212 vtkPriorityQueue *EdgeCosts;
00213 vtkDoubleArray *TargetPoints;
00214 int NumberOfComponents;
00215 vtkPolyData *Mesh;
00216
00217
00218 struct ErrorQuadric
00219 {
00220 double *Quadric;
00221 };
00222
00223
00224 ErrorQuadric *ErrorQuadrics;
00225 int AttributeComponents[6];
00226 double AttributeScale[6];
00227
00228
00229 vtkIdList *CollapseCellIds;
00230 double *TempX;
00231 double *TempQuad;
00232 double *TempB;
00233 double **TempA;
00234 double *TempData;
00235
00236 private:
00237 vtkQuadricDecimation(const vtkQuadricDecimation&);
00238 void operator=(const vtkQuadricDecimation&);
00239 };
00240
00241 #endif