Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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 =========================================================================*/
00040 #ifndef __vtkCellLocator_h
00041 #define __vtkCellLocator_h
00042 
00043 #include "vtkLocator.h"
00044 
00045 class vtkCellArray;
00046 class vtkGenericCell;
00047 class vtkIdList;
00048 class vtkNeighborCells;
00049 class vtkPoints;
00050 
00051 class VTK_FILTERING_EXPORT vtkCellLocator : public vtkLocator
00052 {
00053 public:
00054   vtkTypeRevisionMacro(vtkCellLocator,vtkLocator);
00055   void PrintSelf(ostream& os, vtkIndent indent);
00056 
00059   static vtkCellLocator *New();
00060 
00062 
00063   vtkSetClampMacro(NumberOfCellsPerBucket,int,1,VTK_LARGE_INTEGER);
00064   vtkGetMacro(NumberOfCellsPerBucket,int);
00066 
00068 
00073   vtkSetMacro(CacheCellBounds,int);
00074   vtkGetMacro(CacheCellBounds,int);
00075   vtkBooleanMacro(CacheCellBounds,int);
00077 
00079 
00081   virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
00082                                 double& t, double x[3], double pcoords[3],
00083                                 int &subId);
00085 
00087 
00089   virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
00090                                 double& t, double x[3], double pcoords[3],
00091                                 int &subId, vtkIdType &cellId);
00093 
00095 
00098   virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
00099                                 double& t, double x[3], double pcoords[3],
00100                                 int &subId, vtkIdType &cellId,
00101                                 vtkGenericCell *cell);
00103 
00105 
00108   void FindClosestPoint(double x[3], double closestPoint[3], vtkIdType &cellId,
00109                         int &subId, double& dist2);
00111   
00113 
00122   void FindClosestPoint(double x[3], double closestPoint[3],
00123                         vtkGenericCell *cell, vtkIdType &cellId, int &subId,
00124                         double& dist2);
00126   
00128 
00134   int FindClosestPointWithinRadius(double x[3], double radius,
00135                                    double closestPoint[3], vtkIdType &cellId,
00136                                    int &subId, double& dist2);
00138  
00140 
00153   int FindClosestPointWithinRadius(double x[3], double radius,
00154                                    double closestPoint[3],
00155                                    vtkGenericCell *cell, vtkIdType &cellId,
00156                                    int &subId, double& dist2);
00158 
00160 
00175   int FindClosestPointWithinRadius(double x[3], double radius,
00176                                    double closestPoint[3],
00177                                    vtkGenericCell *cell, vtkIdType &cellId,
00178                                    int &subId, double& dist2, int &inside);
00180   
00182   virtual vtkIdList *GetCells(int bucket);
00183 
00186   virtual int GetNumberOfBuckets(void);
00187 
00189 
00190   void FreeSearchStructure();
00191   void BuildLocator();
00192   void GenerateRepresentation(int level, vtkPolyData *pd);
00194   
00195 protected:
00196   vtkCellLocator();
00197   ~vtkCellLocator();
00198 
00199   void GetBucketNeighbors(int ijk[3], int ndivs, int level);
00200   void GetOverlappingBuckets(double x[3], int ijk[3], double dist, 
00201                              int prevMinLevel[3], int prevMaxLevel[3]);
00202 
00203   void ClearCellHasBeenVisited();
00204   void ClearCellHasBeenVisited(int id);
00205 
00206   double Distance2ToBucket(double x[3], int nei[3]);
00207   double Distance2ToBounds(double x[3], double bounds[6]);
00208   
00209   int NumberOfCellsPerBucket; // cells per octant
00210   int NumberOfOctants; // number of octants in tree
00211   double Bounds[6]; // bounding box root octant
00212   int NumberOfParents; // number of parent octants
00213   double H[3]; // width of leaf octant in x-y-z directions
00214   int NumberOfDivisions; // number of "leaf" octant sub-divisions
00215   vtkIdList **Tree; // octree
00216 
00217   void MarkParents(void*, int, int, int, int, int);
00218   void GetChildren(int idx, int level, int children[8]);
00219   int GenerateIndex(int offset, int numDivs, int i, int j, int k,
00220                     vtkIdType &idx);
00221   void GenerateFace(int face, int numDivs, int i, int j, int k,
00222                     vtkPoints *pts, vtkCellArray *polys);
00223 
00224   vtkNeighborCells *Buckets;
00225   unsigned char *CellHasBeenVisited;
00226   unsigned char QueryNumber;
00227   int CacheCellBounds;
00228 //BTX - begin tcl exclude
00229   double (*CellBounds)[6];
00230 //ETX - end tcl exclude
00231 
00232   void ComputeOctantBounds(int i, int j, int k);
00233   double OctantBounds[6]; //the bounds of the current octant
00234   int IsInOctantBounds(double x[3])
00235     {
00236     if ( this->OctantBounds[0] <= x[0] && x[0] <= this->OctantBounds[1] &&
00237          this->OctantBounds[2] <= x[1] && x[1] <= this->OctantBounds[3] &&
00238          this->OctantBounds[4] <= x[2] && x[2] <= this->OctantBounds[5] )
00239       {
00240       return 1;
00241       }
00242     else
00243       {
00244       return 0;
00245       }
00246     }
00247 
00248 private:
00249   vtkCellLocator(const vtkCellLocator&);  // Not implemented.
00250   void operator=(const vtkCellLocator&);  // Not implemented.
00251 };
00252 
00253 #endif
00254 
00255 

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