VTK
|
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 "vtkAbstractCellLocator.h" 00044 00045 class vtkNeighborCells; 00046 00047 class VTK_FILTERING_EXPORT vtkCellLocator : public vtkAbstractCellLocator 00048 { 00049 public: 00050 vtkTypeRevisionMacro(vtkCellLocator,vtkAbstractCellLocator); 00051 void PrintSelf(ostream& os, vtkIndent indent); 00052 00055 static vtkCellLocator *New(); 00056 00058 00059 void SetNumberOfCellsPerBucket(int N) 00060 { this->SetNumberOfCellsPerNode(N); } 00061 int GetNumberOfCellsPerBucket() 00062 { return this->NumberOfCellsPerNode; } 00064 00065 //BTX 00066 /* 00067 if the borland compiler is ever removed, we can use these declarations 00068 instead of reimplementaing the calls in this subclass 00069 using vtkAbstractCellLocator::IntersectWithLine; 00070 using vtkAbstractCellLocator::FindClosestPoint; 00071 using vtkAbstractCellLocator::FindClosestPointWithinRadius; 00072 */ 00073 //ETX 00074 00076 00077 virtual int IntersectWithLine( 00078 double a0[3], double a1[3], double tol, 00079 double& t, double x[3], double pcoords[3], 00080 int &subId) 00081 { 00082 return Superclass:: 00083 IntersectWithLine(a0, a1, tol,t, x, pcoords, subId); 00084 } 00086 00088 00089 virtual int IntersectWithLine( 00090 double a0[3], double a1[3], double tol, 00091 double& t, double x[3], double pcoords[3], 00092 int &subId, vtkIdType &cellId) 00093 { 00094 return Superclass:: 00095 IntersectWithLine(a0, a1, tol,t, x, pcoords, subId, cellId); 00096 } 00098 00100 00101 virtual int IntersectWithLine( 00102 const double a0[3], const double a1[3], 00103 vtkPoints *points, vtkIdList *cellIds) 00104 { 00105 return Superclass:: 00106 IntersectWithLine(a0, a1, points, cellIds); 00107 } 00109 00111 00115 virtual int IntersectWithLine(double a0[3], double a1[3], double tol, 00116 double& t, double x[3], double pcoords[3], 00117 int &subId, vtkIdType &cellId, 00118 vtkGenericCell *cell); 00120 00122 00123 virtual void FindClosestPoint( 00124 double x[3], double closestPoint[3], 00125 vtkIdType &cellId, int &subId, double& dist2) 00126 { 00127 Superclass:: 00128 FindClosestPoint(x, closestPoint, cellId, subId, dist2); 00129 } 00131 00133 00142 virtual void FindClosestPoint( 00143 double x[3], double closestPoint[3], 00144 vtkGenericCell *cell, vtkIdType &cellId, 00145 int &subId, double& dist2); 00147 00149 00150 virtual vtkIdType FindClosestPointWithinRadius( 00151 double x[3], double radius, 00152 double closestPoint[3], vtkIdType &cellId, 00153 int &subId, double& dist2) 00154 { 00155 return Superclass::FindClosestPointWithinRadius 00156 (x, radius, closestPoint, cellId, subId, dist2); 00157 } 00159 00161 00162 virtual vtkIdType FindClosestPointWithinRadius( 00163 double x[3], double radius, 00164 double closestPoint[3], 00165 vtkGenericCell *cell, vtkIdType &cellId, 00166 int &subId, double& dist2) 00167 { 00168 return Superclass::FindClosestPointWithinRadius 00169 (x, radius, closestPoint, cell, cellId, subId, dist2); 00170 } 00172 00174 00190 virtual vtkIdType FindClosestPointWithinRadius( 00191 double x[3], double radius, double closestPoint[3], 00192 vtkGenericCell *cell, vtkIdType &cellId, 00193 int &subId, double& dist2, int &inside); 00195 00197 virtual vtkIdList *GetCells(int bucket); 00198 00201 virtual int GetNumberOfBuckets(void); 00202 00206 virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells); 00207 00209 00214 virtual void FindCellsAlongLine( 00215 double p1[3], double p2[3], double tolerance, vtkIdList *cells); 00217 00219 00220 virtual void FreeSearchStructure(); 00221 virtual void BuildLocator(); 00222 virtual void GenerateRepresentation(int level, vtkPolyData *pd); 00224 00225 protected: 00226 vtkCellLocator(); 00227 ~vtkCellLocator(); 00228 00229 void GetBucketNeighbors(int ijk[3], int ndivs, int level); 00230 void GetOverlappingBuckets(double x[3], int ijk[3], double dist, 00231 int prevMinLevel[3], int prevMaxLevel[3]); 00232 00233 void ClearCellHasBeenVisited(); 00234 void ClearCellHasBeenVisited(int id); 00235 00236 double Distance2ToBucket(double x[3], int nei[3]); 00237 double Distance2ToBounds(double x[3], double bounds[6]); 00238 00239 int NumberOfOctants; // number of octants in tree 00240 double Bounds[6]; // bounding box root octant 00241 int NumberOfParents; // number of parent octants 00242 double H[3]; // width of leaf octant in x-y-z directions 00243 int NumberOfDivisions; // number of "leaf" octant sub-divisions 00244 vtkIdList **Tree; // octree 00245 00246 void MarkParents(void*, int, int, int, int, int); 00247 void GetChildren(int idx, int level, int children[8]); 00248 int GenerateIndex(int offset, int numDivs, int i, int j, int k, 00249 vtkIdType &idx); 00250 void GenerateFace(int face, int numDivs, int i, int j, int k, 00251 vtkPoints *pts, vtkCellArray *polys); 00252 00253 vtkNeighborCells *Buckets; 00254 unsigned char *CellHasBeenVisited; 00255 unsigned char QueryNumber; 00256 00257 void ComputeOctantBounds(int i, int j, int k); 00258 double OctantBounds[6]; //the bounds of the current octant 00259 int IsInOctantBounds(double x[3]) 00260 { 00261 if ( this->OctantBounds[0] <= x[0] && x[0] <= this->OctantBounds[1] && 00262 this->OctantBounds[2] <= x[1] && x[1] <= this->OctantBounds[3] && 00263 this->OctantBounds[4] <= x[2] && x[2] <= this->OctantBounds[5] ) 00264 { 00265 return 1; 00266 } 00267 else 00268 { 00269 return 0; 00270 } 00271 } 00272 00273 private: 00274 vtkCellLocator(const vtkCellLocator&); // Not implemented. 00275 void operator=(const vtkCellLocator&); // Not implemented. 00276 }; 00277 00278 #endif 00279 00280