00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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;
00223 int NumberOfOctants;
00224 double Bounds[6];
00225 int NumberOfParents;
00226 double H[3];
00227 int NumberOfDivisions;
00228 vtkIdList **Tree;
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
00242 double (*CellBounds)[6];
00243
00244
00245 void ComputeOctantBounds(int i, int j, int k);
00246 double OctantBounds[6];
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&);
00263 void operator=(const vtkCellLocator&);
00264 };
00265
00266 #endif
00267
00268