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

vtkQuadricClustering.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkQuadricClustering.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 =========================================================================*/
00092 #ifndef __vtkQuadricClustering_h
00093 #define __vtkQuadricClustering_h
00094 
00095 #include "vtkPolyDataToPolyDataFilter.h"
00096 
00097 class vtkCellArray;
00098 class vtkFeatureEdges;
00099 class vtkPoints;
00100 
00101 class VTK_GRAPHICS_EXPORT vtkQuadricClustering : public vtkPolyDataToPolyDataFilter
00102 {
00103 public:
00104   vtkTypeRevisionMacro(vtkQuadricClustering, vtkPolyDataToPolyDataFilter);
00105   void PrintSelf(ostream& os, vtkIndent indent);
00106   static vtkQuadricClustering *New();
00107 
00109 
00114   void SetNumberOfXDivisions(int num);
00115   void SetNumberOfYDivisions(int num);
00116   void SetNumberOfZDivisions(int num);
00117   vtkGetMacro(NumberOfXDivisions, int);
00118   vtkGetMacro(NumberOfYDivisions, int);
00119   vtkGetMacro(NumberOfZDivisions, int);
00120   void SetNumberOfDivisions(int div[3])
00121     { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
00122   void SetNumberOfDivisions(int div0, int div1, int div2);
00123   int *GetNumberOfDivisions();
00124   void GetNumberOfDivisions(int div[3]);
00126 
00128 
00131   vtkSetMacro(AutoAdjustNumberOfDivisions,int);
00132   vtkGetMacro(AutoAdjustNumberOfDivisions,int);
00133   vtkBooleanMacro(AutoAdjustNumberOfDivisions,int);
00135 
00137 
00141   void SetDivisionOrigin(double x, double y, double z);
00142   void SetDivisionOrigin(double o[3]) 
00143     {this->SetDivisionOrigin(o[0],o[1],o[2]);}
00144   vtkGetVector3Macro(DivisionOrigin, double);
00145   void SetDivisionSpacing(double x, double y, double z);
00146   void SetDivisionSpacing(double s[3]) 
00147     {this->SetDivisionSpacing(s[0],s[1],s[2]);}
00148   vtkGetVector3Macro(DivisionSpacing, double);
00150 
00152 
00158   vtkSetMacro(UseInputPoints, int);
00159   vtkGetMacro(UseInputPoints, int);
00160   vtkBooleanMacro(UseInputPoints, int);
00162 
00164 
00168   vtkSetMacro(UseFeatureEdges, int);
00169   vtkGetMacro(UseFeatureEdges, int);
00170   vtkBooleanMacro(UseFeatureEdges, int);
00171   vtkFeatureEdges *GetFeatureEdges() {return this->FeatureEdges;}
00173 
00175 
00180   vtkSetMacro(UseFeaturePoints, int);
00181   vtkGetMacro(UseFeaturePoints, int);
00182   vtkBooleanMacro(UseFeaturePoints, int);
00184 
00186 
00188   vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
00189   vtkGetMacro(FeaturePointsAngle, double);
00191   
00193 
00197   vtkSetMacro(UseInternalTriangles, int);
00198   vtkGetMacro(UseInternalTriangles, int);
00199   vtkBooleanMacro(UseInternalTriangles, int);
00201 
00203 
00207   void StartAppend(double *bounds);
00208   void StartAppend(double x0,double x1,double y0,double y1,double z0,double z1)
00209     {double b[6]; b[0]=x0; b[1]=x1; b[2]=y0; b[3]=y1; b[4]=z0; b[5]=z1; 
00210     this->StartAppend(b);}  
00211   void Append(vtkPolyData *piece);
00212   void EndAppend();
00214 
00216 
00220   vtkSetMacro(CopyCellData, int); 
00221   vtkGetMacro(CopyCellData, int); 
00222   vtkBooleanMacro(CopyCellData, int); 
00224 
00225 protected:
00226   vtkQuadricClustering();
00227   ~vtkQuadricClustering();
00228 
00229   void Execute();
00230     
00232   vtkIdType HashPoint(double point[3]);
00233   
00235 
00236   void ComputeRepresentativePoint(double quadric[9], vtkIdType binId,
00237                                   double point[3]);
00239 
00241 
00243   void AddPolygons(vtkCellArray *polys, vtkPoints *points, int geometryFlag);
00244   void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag);
00245   void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2,
00246                    int geometeryFlag);
00248 
00250 
00252   void AddEdges(vtkCellArray *edges, vtkPoints *points,
00253                 int geometryFlag);
00254   void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag);
00256 
00258 
00260   void AddVertices(vtkCellArray *verts, vtkPoints *points, int geometryFlag);
00261   void AddVertex(vtkIdType binId, double *pt, int geometryFlag);
00263 
00265   void InitializeQuadric(double quadric[9]);
00266   
00268   void AddQuadric(vtkIdType binId, double quadric[9]);
00269 
00274   void FindFeaturePoints(vtkCellArray *edges, vtkPoints *edgePts, double angle);
00275   
00277 
00279   void EndAppendUsingPoints(vtkPolyData *input);
00280   int UseInputPoints;
00282 
00285   void EndAppendVertexGeometry(vtkPolyData *input);
00286 
00287   // Unfinished option to handle boundary edges differently.
00288   void AppendFeatureQuadrics(vtkPolyData *pd);
00289   int UseFeatureEdges;
00290   int UseFeaturePoints;
00291   int UseInternalTriangles;
00292 
00293   int NumberOfXDivisions;
00294   int NumberOfYDivisions;
00295   int NumberOfZDivisions;
00296 
00297   // Used internally.
00298   // can be smaller than user values when input numb er of points is small.
00299   int NumberOfDivisions[3];
00300 
00301   // Since there are two was of specifing the grid, we have this flag
00302   // to indicate which the user has set.  When this flag is on, 
00303   // the bin sizes are computed from the DivisionOrigin and DivisionSpacing. 
00304   int ComputeNumberOfDivisions;
00305 
00306   double DivisionOrigin[3];
00307   double DivisionSpacing[3];
00308   int   AutoAdjustNumberOfDivisions;
00309 
00310   double Bounds[6];
00311   double XBinSize;
00312   double YBinSize;
00313   double ZBinSize;
00314   vtkIdType SliceSize; //eliminate one multiplication
00315 
00316   //BTX
00317   struct PointQuadric 
00318   {
00319     PointQuadric():VertexId(-1),Dimension(255) {}
00320     
00321     vtkIdType VertexId;
00322     // Dimension is supposed to be a flag representing the dimension of the
00323     // cells contributing to the quadric.  Lines: 1, Triangles: 2 (and points
00324     // 0 in the future?)
00325     unsigned char Dimension;
00326     double Quadric[9];
00327   };
00328   //ETX
00329 
00330   PointQuadric* QuadricArray;
00331   vtkIdType NumberOfBinsUsed;
00332 
00333   // Have to make these instance variables if we are going to allow
00334   // the algorithm to be driven by the Append methods.
00335   vtkCellArray *OutputTriangleArray;
00336   vtkCellArray *OutputLines;
00337 
00338   vtkFeatureEdges *FeatureEdges;
00339   vtkPoints *FeaturePoints;
00340   double FeaturePointsAngle;
00341 
00342   int CopyCellData;
00343   int InCellCount;
00344   int OutCellCount;
00345 
00346 private:
00347   vtkQuadricClustering(const vtkQuadricClustering&);  // Not implemented.
00348   void operator=(const vtkQuadricClustering&);  // Not implemented.
00349 };
00350 
00351 #endif