VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkCellLocator.h 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 =========================================================================*/ 00043 #ifndef __vtkCellLocator_h 00044 #define __vtkCellLocator_h 00045 00046 #include "vtkAbstractCellLocator.h" 00047 00048 class vtkNeighborCells; 00049 00050 class VTK_FILTERING_EXPORT vtkCellLocator : public vtkAbstractCellLocator 00051 { 00052 public: 00053 vtkTypeMacro(vtkCellLocator,vtkAbstractCellLocator); 00054 void PrintSelf(ostream& os, vtkIndent indent); 00055 00058 static vtkCellLocator *New(); 00059 00061 00062 void SetNumberOfCellsPerBucket(int N) 00063 { this->SetNumberOfCellsPerNode(N); } 00064 int GetNumberOfCellsPerBucket() 00065 { return this->NumberOfCellsPerNode; } 00067 00068 //BTX 00069 /* 00070 if the borland compiler is ever removed, we can use these declarations 00071 instead of reimplementaing the calls in this subclass 00072 using vtkAbstractCellLocator::IntersectWithLine; 00073 using vtkAbstractCellLocator::FindClosestPoint; 00074 using vtkAbstractCellLocator::FindClosestPointWithinRadius; 00075 */ 00076 //ETX 00077 00079 00080 virtual int IntersectWithLine( 00081 double a0[3], double a1[3], double tol, 00082 double& t, double x[3], double pcoords[3], 00083 int &subId) 00084 { 00085 return Superclass:: 00086 IntersectWithLine(a0, a1, tol,t, x, pcoords, subId); 00087 } 00089 00091 00092 virtual int IntersectWithLine( 00093 double a0[3], double a1[3], double tol, 00094 double& t, double x[3], double pcoords[3], 00095 int &subId, vtkIdType &cellId) 00096 { 00097 return Superclass:: 00098 IntersectWithLine(a0, a1, tol,t, x, pcoords, subId, cellId); 00099 } 00101 00103 00104 virtual int IntersectWithLine( 00105 const double a0[3], const double a1[3], 00106 vtkPoints *points, vtkIdList *cellIds) 00107 { 00108 return Superclass:: 00109 IntersectWithLine(a0, a1, points, cellIds); 00110 } 00112 00114 00118 virtual int IntersectWithLine(double a0[3], double a1[3], double tol, 00119 double& t, double x[3], double pcoords[3], 00120 int &subId, vtkIdType &cellId, 00121 vtkGenericCell *cell); 00123 00125 00126 virtual void FindClosestPoint( 00127 double x[3], double closestPoint[3], 00128 vtkIdType &cellId, int &subId, double& dist2) 00129 { 00130 Superclass:: 00131 FindClosestPoint(x, closestPoint, cellId, subId, dist2); 00132 } 00134 00136 00145 virtual void FindClosestPoint( 00146 double x[3], double closestPoint[3], 00147 vtkGenericCell *cell, vtkIdType &cellId, 00148 int &subId, double& dist2); 00150 00152 00153 virtual vtkIdType FindClosestPointWithinRadius( 00154 double x[3], double radius, 00155 double closestPoint[3], vtkIdType &cellId, 00156 int &subId, double& dist2) 00157 { 00158 return Superclass::FindClosestPointWithinRadius 00159 (x, radius, closestPoint, cellId, subId, dist2); 00160 } 00162 00164 00165 virtual vtkIdType FindClosestPointWithinRadius( 00166 double x[3], double radius, 00167 double closestPoint[3], 00168 vtkGenericCell *cell, vtkIdType &cellId, 00169 int &subId, double& dist2) 00170 { 00171 return Superclass::FindClosestPointWithinRadius 00172 (x, radius, closestPoint, cell, cellId, subId, dist2); 00173 } 00175 00177 00193 virtual vtkIdType FindClosestPointWithinRadius( 00194 double x[3], double radius, double closestPoint[3], 00195 vtkGenericCell *cell, vtkIdType &cellId, 00196 int &subId, double& dist2, int &inside); 00198 00200 virtual vtkIdList *GetCells(int bucket); 00201 00204 virtual int GetNumberOfBuckets(void); 00205 00207 00209 virtual vtkIdType FindCell(double x[3]) 00210 { return this->Superclass::FindCell(x); } 00212 00214 00217 virtual vtkIdType FindCell( 00218 double x[3], double tol2, vtkGenericCell *GenCell, 00219 double pcoords[3], double *weights); 00221 00225 virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells); 00226 00228 00233 virtual void FindCellsAlongLine( 00234 double p1[3], double p2[3], double tolerance, vtkIdList *cells); 00236 00238 00239 virtual void FreeSearchStructure(); 00240 virtual void BuildLocator(); 00241 virtual void BuildLocatorIfNeeded(); 00242 virtual void ForceBuildLocator(); 00243 virtual void BuildLocatorInternal(); 00244 virtual void GenerateRepresentation(int level, vtkPolyData *pd); 00246 00247 protected: 00248 vtkCellLocator(); 00249 ~vtkCellLocator(); 00250 00251 void GetBucketNeighbors(int ijk[3], int ndivs, int level); 00252 void GetOverlappingBuckets(double x[3], int ijk[3], double dist, 00253 int prevMinLevel[3], int prevMaxLevel[3]); 00254 00255 void ClearCellHasBeenVisited(); 00256 void ClearCellHasBeenVisited(int id); 00257 00258 double Distance2ToBucket(double x[3], int nei[3]); 00259 double Distance2ToBounds(double x[3], double bounds[6]); 00260 00261 int NumberOfOctants; // number of octants in tree 00262 double Bounds[6]; // bounding box root octant 00263 int NumberOfParents; // number of parent octants 00264 double H[3]; // width of leaf octant in x-y-z directions 00265 int NumberOfDivisions; // number of "leaf" octant sub-divisions 00266 vtkIdList **Tree; // octree 00267 00268 void MarkParents(void*, int, int, int, int, int); 00269 void GetChildren(int idx, int level, int children[8]); 00270 int GenerateIndex(int offset, int numDivs, int i, int j, int k, 00271 vtkIdType &idx); 00272 void GenerateFace(int face, int numDivs, int i, int j, int k, 00273 vtkPoints *pts, vtkCellArray *polys); 00274 00275 vtkNeighborCells *Buckets; 00276 unsigned char *CellHasBeenVisited; 00277 unsigned char QueryNumber; 00278 00279 void ComputeOctantBounds(int i, int j, int k); 00280 double OctantBounds[6]; //the bounds of the current octant 00281 int IsInOctantBounds(double x[3]) 00282 { 00283 if ( this->OctantBounds[0] <= x[0] && x[0] <= this->OctantBounds[1] && 00284 this->OctantBounds[2] <= x[1] && x[1] <= this->OctantBounds[3] && 00285 this->OctantBounds[4] <= x[2] && x[2] <= this->OctantBounds[5] ) 00286 { 00287 return 1; 00288 } 00289 else 00290 { 00291 return 0; 00292 } 00293 } 00294 00295 private: 00296 vtkCellLocator(const vtkCellLocator&); // Not implemented. 00297 void operator=(const vtkCellLocator&); // Not implemented. 00298 }; 00299 00300 #endif 00301 00302