Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkQuadricDecimation.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkQuadricDecimation.h,v $
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 =========================================================================*/
00069 #ifndef __vtkQuadricDecimation_h
00070 #define __vtkQuadricDecimation_h
00071 
00072 #include "vtkPolyDataToPolyDataFilter.h"
00073 
00074 class vtkEdgeTable;
00075 class vtkIdList;
00076 class vtkPointData;
00077 class vtkPriorityQueue;
00078 class vtkDoubleArray;
00079 
00080 class VTK_GRAPHICS_EXPORT vtkQuadricDecimation : public vtkPolyDataToPolyDataFilter
00081 {
00082 public:
00083   vtkTypeRevisionMacro(vtkQuadricDecimation, vtkPolyDataToPolyDataFilter);
00084   void PrintSelf(ostream& os, vtkIndent indent);
00085   static vtkQuadricDecimation *New();
00086 
00088 
00091   vtkSetClampMacro(TargetReduction, double, 0.0, 1.0);
00092   vtkGetMacro(TargetReduction, double);
00094 
00096 
00099   vtkSetMacro(AttributeErrorMetric, int);
00100   vtkGetMacro(AttributeErrorMetric, int);
00101   vtkBooleanMacro(AttributeErrorMetric, int);
00103   
00105 
00109   vtkSetMacro(ScalarsAttribute, int);
00110   vtkGetMacro(ScalarsAttribute, int);
00111   vtkBooleanMacro(ScalarsAttribute, int);
00112   vtkSetMacro(VectorsAttribute, int);
00113   vtkGetMacro(VectorsAttribute, int);
00114   vtkBooleanMacro(VectorsAttribute, int);
00115   vtkSetMacro(NormalsAttribute, int);
00116   vtkGetMacro(NormalsAttribute, int);
00117   vtkBooleanMacro(NormalsAttribute, int);
00118   vtkSetMacro(TCoordsAttribute, int);
00119   vtkGetMacro(TCoordsAttribute, int);
00120   vtkBooleanMacro(TCoordsAttribute, int);
00121   vtkSetMacro(TensorsAttribute, int);
00122   vtkGetMacro(TensorsAttribute, int);
00123   vtkBooleanMacro(TensorsAttribute, int);
00125 
00127 
00130   vtkSetMacro(ScalarsWeight, double);
00131   vtkSetMacro(VectorsWeight, double);
00132   vtkSetMacro(NormalsWeight, double);
00133   vtkSetMacro(TCoordsWeight, double);
00134   vtkSetMacro(TensorsWeight, double);
00135   vtkGetMacro(ScalarsWeight, double);
00136   vtkGetMacro(VectorsWeight, double);
00137   vtkGetMacro(NormalsWeight, double);
00138   vtkGetMacro(TCoordsWeight, double);
00139   vtkGetMacro(TensorsWeight, double);
00141   
00143 
00145   vtkGetMacro(ActualReduction, double);
00147 
00148 protected:
00149   vtkQuadricDecimation();
00150   ~vtkQuadricDecimation();
00151 
00152   void Execute();
00153 
00156   int CollapseEdge(vtkIdType pt0Id, vtkIdType pt1Id);
00157 
00159   void InitializeQuadrics(vtkIdType numPts);
00160   
00162   void AddBoundaryConstraints(void);
00163 
00165   void ComputeQuadric(vtkIdType pointId);
00166 
00169   void AddQuadric(vtkIdType oldPtId, vtkIdType newPtId);
00170   
00172 
00174   double ComputeCost(vtkIdType edgeId, double *x);
00175   double ComputeCost2(vtkIdType edgeId, double *x);
00177 
00181   void FindAffectedEdges(vtkIdType p1Id, vtkIdType p2Id, vtkIdList *edges);
00182   
00184   vtkIdType GetEdgeCellId(vtkIdType p1Id, vtkIdType p2Id);
00185 
00186   int IsGoodPlacement(vtkIdType pt0Id, vtkIdType pt1Id, const double *x);
00187   int TrianglePlaneCheck(const double t0[3], const double t1[3], 
00188                          const double t2[3],  const double *x);
00189   void ComputeNumberOfComponents(void);
00190   void UpdateEdgeData(vtkIdType ptoId, vtkIdType pt1Id);
00191   
00193 
00195   void SetPointAttributeArray(vtkIdType ptId, const double *x);
00196   void GetPointAttributeArray(vtkIdType ptId, double *x);
00198 
00201   void GetAttributeComponents();
00202   
00203   double TargetReduction;
00204   double ActualReduction;
00205   int   AttributeErrorMetric;
00206   
00207   int ScalarsAttribute;
00208   int VectorsAttribute;
00209   int NormalsAttribute;
00210   int TCoordsAttribute;
00211   int TensorsAttribute;
00212 
00213   double ScalarsWeight;
00214   double VectorsWeight;
00215   double NormalsWeight;
00216   double TCoordsWeight;
00217   double TensorsWeight;
00218 
00219   int               NumberOfEdgeCollapses;
00220   vtkEdgeTable     *Edges;
00221   vtkIdList        *EndPoint1List;
00222   vtkIdList        *EndPoint2List;
00223   vtkPriorityQueue *EdgeCosts;
00224   vtkDoubleArray   *TargetPoints;
00225   int               NumberOfComponents;
00226   vtkPolyData      *Mesh;
00227 
00228   //BTX
00229   struct ErrorQuadric
00230   {
00231     double *Quadric;
00232   };
00233   //ETX
00234 
00235   ErrorQuadric *ErrorQuadrics;
00236   int           AttributeComponents[6];
00237   double        AttributeScale[6];
00238   
00239   // Temporary variables for performance
00240   vtkIdList *CollapseCellIds;
00241   double *TempX;
00242   double *TempQuad;
00243   double *TempB;
00244   double **TempA;
00245   double *TempData;
00246 
00247 private:
00248   vtkQuadricDecimation(const vtkQuadricDecimation&);  // Not implemented.
00249   void operator=(const vtkQuadricDecimation&);  // Not implemented.
00250 };
00251 
00252 #endif