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

vtkCellLocator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkCellLocator.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 =========================================================================*/
00053 #ifndef __vtkCellLocator_h
00054 #define __vtkCellLocator_h
00055 
00056 #include "vtkLocator.h"
00057 
00058 class vtkCellArray;
00059 class vtkGenericCell;
00060 class vtkIdList;
00061 class vtkNeighborCells;
00062 class vtkPoints;
00063 
00064 class VTK_FILTERING_EXPORT vtkCellLocator : public vtkLocator
00065 {
00066 public:
00067   vtkTypeRevisionMacro(vtkCellLocator,vtkLocator);
00068   void PrintSelf(ostream& os, vtkIndent indent);
00069 
00072   static vtkCellLocator *New();
00073 
00075 
00076   vtkSetClampMacro(NumberOfCellsPerBucket,int,1,VTK_LARGE_INTEGER);
00077   vtkGetMacro(NumberOfCellsPerBucket,int);
00079 
00081 
00086   vtkSetMacro(CacheCellBounds,int);
00087   vtkGetMacro(CacheCellBounds,int);
00088   vtkBooleanMacro(CacheCellBounds,int);
00090 
00092 
00094   virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
00095                                 double& t, double x[3], double pcoords[3],
00096                                 int &subId);
00098 
00100 
00102   virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
00103                                 double& t, double x[3], double pcoords[3],
00104                                 int &subId, vtkIdType &cellId);
00106 
00108 
00111   virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
00112                                 double& t, double x[3], double pcoords[3],
00113                                 int &subId, vtkIdType &cellId,
00114                                 vtkGenericCell *cell);
00116 
00118 
00121   void FindClosestPoint(double x[3], double closestPoint[3], vtkIdType &cellId,
00122                         int &subId, double& dist2);
00124   
00126 
00135   void FindClosestPoint(double x[3], double closestPoint[3],
00136                         vtkGenericCell *cell, vtkIdType &cellId, int &subId,
00137                         double& dist2);
00139   
00141 
00147   int FindClosestPointWithinRadius(double x[3], double radius,
00148                                    double closestPoint[3], vtkIdType &cellId,
00149                                    int &subId, double& dist2);
00151  
00153 
00166   int FindClosestPointWithinRadius(double x[3], double radius,
00167                                    double closestPoint[3],
00168                                    vtkGenericCell *cell, vtkIdType &cellId,
00169                                    int &subId, double& dist2);
00171 
00173 
00188   int FindClosestPointWithinRadius(double x[3], double radius,
00189                                    double closestPoint[3],
00190                                    vtkGenericCell *cell, vtkIdType &cellId,
00191                                    int &subId, double& dist2, int &inside);
00193   
00195   virtual vtkIdList *GetCells(int bucket);
00196 
00199   virtual int GetNumberOfBuckets(void);
00200 
00202 
00203   void FreeSearchStructure();
00204   void BuildLocator();
00205   void GenerateRepresentation(int level, vtkPolyData *pd);
00207   
00208 protected:
00209   vtkCellLocator();
00210   ~vtkCellLocator();
00211 
00212   void GetBucketNeighbors(int ijk[3], int ndivs, int level);
00213   void GetOverlappingBuckets(double x[3], int ijk[3], double dist, 
00214                              int prevMinLevel[3], int prevMaxLevel[3]);
00215 
00216   void ClearCellHasBeenVisited();
00217   void ClearCellHasBeenVisited(int id);
00218 
00219   double Distance2ToBucket(double x[3], int nei[3]);
00220   double Distance2ToBounds(double x[3], double bounds[6]);
00221   
00222   int NumberOfCellsPerBucket; // cells per octant
00223   int NumberOfOctants; // number of octants in tree
00224   double Bounds[6]; // bounding box root octant
00225   int NumberOfParents; // number of parent octants
00226   double H[3]; // width of leaf octant in x-y-z directions
00227   int NumberOfDivisions; // number of "leaf" octant sub-divisions
00228   vtkIdList **Tree; // octree
00229 
00230   void MarkParents(void*, int, int, int, int, int);
00231   void GetChildren(int idx, int level, int children[8]);
00232   int GenerateIndex(int offset, int numDivs, int i, int j, int k,
00233                     vtkIdType &idx);
00234   void GenerateFace(int face, int numDivs, int i, int j, int k,
00235                     vtkPoints *pts, vtkCellArray *polys);
00236 
00237   vtkNeighborCells *Buckets;
00238   unsigned char *CellHasBeenVisited;
00239   unsigned char QueryNumber;
00240   int CacheCellBounds;
00241 //BTX - begin tcl exclude
00242   double (*CellBounds)[6];
00243 //ETX - end tcl exclude
00244 
00245   void ComputeOctantBounds(int i, int j, int k);
00246   double OctantBounds[6]; //the bounds of the current octant
00247   int IsInOctantBounds(double x[3])
00248     {
00249     if ( this->OctantBounds[0] <= x[0] && x[0] <= this->OctantBounds[1] &&
00250          this->OctantBounds[2] <= x[1] && x[1] <= this->OctantBounds[3] &&
00251          this->OctantBounds[4] <= x[2] && x[2] <= this->OctantBounds[5] )
00252       {
00253       return 1;
00254       }
00255     else
00256       {
00257       return 0;
00258       }
00259     }
00260 
00261 private:
00262   vtkCellLocator(const vtkCellLocator&);  // Not implemented.
00263   void operator=(const vtkCellLocator&);  // Not implemented.
00264 };
00265 
00266 #endif
00267 
00268