Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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 =========================================================================*/
00079 #ifndef __vtkQuadricClustering_h
00080 #define __vtkQuadricClustering_h
00081 
00082 #include "vtkPolyDataAlgorithm.h"
00083 
00084 class vtkCellArray;
00085 class vtkFeatureEdges;
00086 class vtkPoints;
00087 
00088 class VTK_GRAPHICS_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
00089 {
00090 public:
00091   vtkTypeRevisionMacro(vtkQuadricClustering, vtkPolyDataAlgorithm);
00092   void PrintSelf(ostream& os, vtkIndent indent);
00093   static vtkQuadricClustering *New();
00094 
00096 
00101   void SetNumberOfXDivisions(int num);
00102   void SetNumberOfYDivisions(int num);
00103   void SetNumberOfZDivisions(int num);
00104   vtkGetMacro(NumberOfXDivisions, int);
00105   vtkGetMacro(NumberOfYDivisions, int);
00106   vtkGetMacro(NumberOfZDivisions, int);
00107   void SetNumberOfDivisions(int div[3])
00108     { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
00109   void SetNumberOfDivisions(int div0, int div1, int div2);
00110   int *GetNumberOfDivisions();
00111   void GetNumberOfDivisions(int div[3]);
00113 
00115 
00118   vtkSetMacro(AutoAdjustNumberOfDivisions,int);
00119   vtkGetMacro(AutoAdjustNumberOfDivisions,int);
00120   vtkBooleanMacro(AutoAdjustNumberOfDivisions,int);
00122 
00124 
00128   void SetDivisionOrigin(double x, double y, double z);
00129   void SetDivisionOrigin(double o[3]) 
00130     {this->SetDivisionOrigin(o[0],o[1],o[2]);}
00131   vtkGetVector3Macro(DivisionOrigin, double);
00132   void SetDivisionSpacing(double x, double y, double z);
00133   void SetDivisionSpacing(double s[3]) 
00134     {this->SetDivisionSpacing(s[0],s[1],s[2]);}
00135   vtkGetVector3Macro(DivisionSpacing, double);
00137 
00139 
00145   vtkSetMacro(UseInputPoints, int);
00146   vtkGetMacro(UseInputPoints, int);
00147   vtkBooleanMacro(UseInputPoints, int);
00149 
00151 
00155   vtkSetMacro(UseFeatureEdges, int);
00156   vtkGetMacro(UseFeatureEdges, int);
00157   vtkBooleanMacro(UseFeatureEdges, int);
00158   vtkFeatureEdges *GetFeatureEdges() {return this->FeatureEdges;}
00160 
00162 
00167   vtkSetMacro(UseFeaturePoints, int);
00168   vtkGetMacro(UseFeaturePoints, int);
00169   vtkBooleanMacro(UseFeaturePoints, int);
00171 
00173 
00175   vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
00176   vtkGetMacro(FeaturePointsAngle, double);
00178   
00180 
00184   vtkSetMacro(UseInternalTriangles, int);
00185   vtkGetMacro(UseInternalTriangles, int);
00186   vtkBooleanMacro(UseInternalTriangles, int);
00188 
00190 
00194   void StartAppend(double *bounds);
00195   void StartAppend(double x0,double x1,double y0,double y1,double z0,double z1)
00196     {double b[6]; b[0]=x0; b[1]=x1; b[2]=y0; b[3]=y1; b[4]=z0; b[5]=z1; 
00197     this->StartAppend(b);}  
00198   void Append(vtkPolyData *piece);
00199   void EndAppend();
00201 
00203 
00207   vtkSetMacro(CopyCellData, int); 
00208   vtkGetMacro(CopyCellData, int); 
00209   vtkBooleanMacro(CopyCellData, int); 
00211 
00212 protected:
00213   vtkQuadricClustering();
00214   ~vtkQuadricClustering();
00215 
00216   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00217   int FillInputPortInformation(int, vtkInformation *);
00218 
00220   vtkIdType HashPoint(double point[3]);
00221   
00223 
00224   void ComputeRepresentativePoint(double quadric[9], vtkIdType binId,
00225                                   double point[3]);
00227 
00229 
00231   void AddPolygons(vtkCellArray *polys, vtkPoints *points, int geometryFlag,
00232                    vtkPolyData *input, vtkPolyData *output);
00233   void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag,
00234                  vtkPolyData *input, vtkPolyData *output);
00235   void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2,
00236                    int geometeryFlag, vtkPolyData *input, vtkPolyData *output);
00238 
00240 
00242   void AddEdges(vtkCellArray *edges, vtkPoints *points,
00243                 int geometryFlag,
00244                 vtkPolyData *input, vtkPolyData *output);
00245   void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag,
00246                vtkPolyData *input, vtkPolyData *output);
00248 
00250 
00252   void AddVertices(vtkCellArray *verts, vtkPoints *points, int geometryFlag,
00253                    vtkPolyData *input, vtkPolyData *output);
00254   void AddVertex(vtkIdType binId, double *pt, int geometryFlag,
00255                  vtkPolyData *input, vtkPolyData *output);
00257 
00259   void InitializeQuadric(double quadric[9]);
00260   
00262   void AddQuadric(vtkIdType binId, double quadric[9]);
00263 
00268   void FindFeaturePoints(vtkCellArray *edges, vtkPoints *edgePts, double angle);
00269   
00271 
00273   void EndAppendUsingPoints(vtkPolyData *input, vtkPolyData *output);
00274   int UseInputPoints;
00276 
00279   void EndAppendVertexGeometry(vtkPolyData *input, vtkPolyData *output);
00280 
00281   // Unfinished option to handle boundary edges differently.
00282   void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output);
00283   int UseFeatureEdges;
00284   int UseFeaturePoints;
00285   int UseInternalTriangles;
00286 
00287   int NumberOfXDivisions;
00288   int NumberOfYDivisions;
00289   int NumberOfZDivisions;
00290 
00291   // Used internally.
00292   // can be smaller than user values when input numb er of points is small.
00293   int NumberOfDivisions[3];
00294 
00295   // Since there are two was of specifing the grid, we have this flag
00296   // to indicate which the user has set.  When this flag is on, 
00297   // the bin sizes are computed from the DivisionOrigin and DivisionSpacing. 
00298   int ComputeNumberOfDivisions;
00299 
00300   double DivisionOrigin[3];
00301   double DivisionSpacing[3];
00302   int   AutoAdjustNumberOfDivisions;
00303 
00304   double Bounds[6];
00305   double XBinSize;
00306   double YBinSize;
00307   double ZBinSize;
00308   vtkIdType SliceSize; //eliminate one multiplication
00309 
00310   //BTX
00311   struct PointQuadric 
00312   {
00313     PointQuadric():VertexId(-1),Dimension(255) {}
00314     
00315     vtkIdType VertexId;
00316     // Dimension is supposed to be a flag representing the dimension of the
00317     // cells contributing to the quadric.  Lines: 1, Triangles: 2 (and points
00318     // 0 in the future?)
00319     unsigned char Dimension;
00320     double Quadric[9];
00321   };
00322   //ETX
00323 
00324   PointQuadric* QuadricArray;
00325   vtkIdType NumberOfBinsUsed;
00326 
00327   // Have to make these instance variables if we are going to allow
00328   // the algorithm to be driven by the Append methods.
00329   vtkCellArray *OutputTriangleArray;
00330   vtkCellArray *OutputLines;
00331 
00332   vtkFeatureEdges *FeatureEdges;
00333   vtkPoints *FeaturePoints;
00334   double FeaturePointsAngle;
00335 
00336   int CopyCellData;
00337   int InCellCount;
00338   int OutCellCount;
00339 
00340 private:
00341   vtkQuadricClustering(const vtkQuadricClustering&);  // Not implemented.
00342   void operator=(const vtkQuadricClustering&);  // Not implemented.
00343 };
00344 
00345 #endif

Generated on Mon Jan 21 23:07:26 2008 for VTK by  doxygen 1.4.3-20050530