VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Filters/Core/vtkQuadricDecimation.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkQuadricDecimation.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00058 #ifndef vtkQuadricDecimation_h
00059 #define vtkQuadricDecimation_h
00060 
00061 #include "vtkFiltersCoreModule.h" // For export macro
00062 #include "vtkPolyDataAlgorithm.h"
00063 
00064 class vtkEdgeTable;
00065 class vtkIdList;
00066 class vtkPointData;
00067 class vtkPriorityQueue;
00068 class vtkDoubleArray;
00069 
00070 class VTKFILTERSCORE_EXPORT vtkQuadricDecimation : public vtkPolyDataAlgorithm
00071 {
00072 public:
00073   vtkTypeMacro(vtkQuadricDecimation, vtkPolyDataAlgorithm);
00074   void PrintSelf(ostream& os, vtkIndent indent);
00075   static vtkQuadricDecimation *New();
00076 
00078 
00081   vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
00082   vtkGetMacro(TargetReduction, double);
00084 
00086 
00089   vtkSetMacro(AttributeErrorMetric, int);
00090   vtkGetMacro(AttributeErrorMetric, int);
00091   vtkBooleanMacro(AttributeErrorMetric, int);
00093 
00095 
00099   vtkSetMacro(ScalarsAttribute, int);
00100   vtkGetMacro(ScalarsAttribute, int);
00101   vtkBooleanMacro(ScalarsAttribute, int);
00102   vtkSetMacro(VectorsAttribute, int);
00103   vtkGetMacro(VectorsAttribute, int);
00104   vtkBooleanMacro(VectorsAttribute, int);
00105   vtkSetMacro(NormalsAttribute, int);
00106   vtkGetMacro(NormalsAttribute, int);
00107   vtkBooleanMacro(NormalsAttribute, int);
00108   vtkSetMacro(TCoordsAttribute, int);
00109   vtkGetMacro(TCoordsAttribute, int);
00110   vtkBooleanMacro(TCoordsAttribute, int);
00111   vtkSetMacro(TensorsAttribute, int);
00112   vtkGetMacro(TensorsAttribute, int);
00113   vtkBooleanMacro(TensorsAttribute, int);
00115 
00117 
00120   vtkSetMacro(ScalarsWeight, double);
00121   vtkSetMacro(VectorsWeight, double);
00122   vtkSetMacro(NormalsWeight, double);
00123   vtkSetMacro(TCoordsWeight, double);
00124   vtkSetMacro(TensorsWeight, double);
00125   vtkGetMacro(ScalarsWeight, double);
00126   vtkGetMacro(VectorsWeight, double);
00127   vtkGetMacro(NormalsWeight, double);
00128   vtkGetMacro(TCoordsWeight, double);
00129   vtkGetMacro(TensorsWeight, double);
00131 
00133 
00135   vtkGetMacro(ActualReduction, double);
00137 
00138 protected:
00139   vtkQuadricDecimation();
00140   ~vtkQuadricDecimation();
00141 
00142   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00143 
00146   int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id);
00147 
00149   void InitializeQuadrics(vtkIdType numPts);
00150 
00152   void AddBoundaryConstraints(void);
00153 
00155   void ComputeQuadric(vtkIdType pointId);
00156 
00159   void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
00160 
00162 
00164   double ComputeCost(vtkIdType edgeId, double *x);
00165   double ComputeCost2(vtkIdType edgeId, double *x);
00167 
00171   void FindAffectedEdges(vtkIdType p1Id, vtkIdType p2Id, vtkIdList *edges);
00172 
00174   vtkIdType GetEdgeCellId(vtkIdType p1Id, vtkIdType p2Id);
00175 
00176   int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double *x);
00177   int TrianglePlaneCheck(const double t0[3], const double t1[3],
00178                          const double t2[3],  const double *x);
00179   void ComputeNumberOfComponents(void);
00180   void UpdateEdgeData(vtkIdType ptoId, vtkIdType pt1Id);
00181 
00183 
00185   void SetPointAttributeArray(vtkIdType ptId, const double *x);
00186   void GetPointAttributeArray(vtkIdType ptId, double *x);
00188 
00191   void GetAttributeComponents();
00192 
00193   double TargetReduction;
00194   double ActualReduction;
00195   int   AttributeErrorMetric;
00196 
00197   int ScalarsAttribute;
00198   int VectorsAttribute;
00199   int NormalsAttribute;
00200   int TCoordsAttribute;
00201   int TensorsAttribute;
00202 
00203   double ScalarsWeight;
00204   double VectorsWeight;
00205   double NormalsWeight;
00206   double TCoordsWeight;
00207   double TensorsWeight;
00208 
00209   int               NumberOfEdgeCollapses;
00210   vtkEdgeTable     *Edges;
00211   vtkIdList        *EndPoint1List;
00212   vtkIdList        *EndPoint2List;
00213   vtkPriorityQueue *EdgeCosts;
00214   vtkDoubleArray   *TargetPoints;
00215   int               NumberOfComponents;
00216   vtkPolyData      *Mesh;
00217 
00218   //BTX
00219   struct ErrorQuadric
00220   {
00221     double *Quadric;
00222   };
00223   //ETX
00224 
00225   ErrorQuadric *ErrorQuadrics;
00226   int           AttributeComponents[6];
00227   double        AttributeScale[6];
00228 
00229   // Temporary variables for performance
00230   vtkIdList *CollapseCellIds;
00231   double *TempX;
00232   double *TempQuad;
00233   double *TempB;
00234   double **TempA;
00235   double *TempData;
00236 
00237 private:
00238   vtkQuadricDecimation(const vtkQuadricDecimation&);  // Not implemented.
00239   void operator=(const vtkQuadricDecimation&);  // Not implemented.
00240 };
00241 
00242 #endif