VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vtkCellLocator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCellLocator.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
43 #ifndef __vtkCellLocator_h
44 #define __vtkCellLocator_h
45 
46 #include "vtkCommonDataModelModule.h" // For export macro
47 #include "vtkAbstractCellLocator.h"
48 
49 class vtkNeighborCells;
50 
52 {
53 public:
55  void PrintSelf(ostream& os, vtkIndent indent);
56 
59  static vtkCellLocator *New();
60 
62 
64  { this->SetNumberOfCellsPerNode(N); }
66  { return this->NumberOfCellsPerNode; }
68 
69 //BTX
70 /*
71  if the borland compiler is ever removed, we can use these declarations
72  instead of reimplementaing the calls in this subclass
73  using vtkAbstractCellLocator::IntersectWithLine;
74  using vtkAbstractCellLocator::FindClosestPoint;
75  using vtkAbstractCellLocator::FindClosestPointWithinRadius;
76 */
77 //ETX
78 
80 
81  virtual int IntersectWithLine(
82  double a0[3], double a1[3], double tol,
83  double& t, double x[3], double pcoords[3],
84  int &subId)
85  {
86  return Superclass::
87  IntersectWithLine(a0, a1, tol,t, x, pcoords, subId);
88  }
90 
92 
93  virtual int IntersectWithLine(
94  double a0[3], double a1[3], double tol,
95  double& t, double x[3], double pcoords[3],
96  int &subId, vtkIdType &cellId)
97  {
98  return Superclass::
99  IntersectWithLine(a0, a1, tol,t, x, pcoords, subId, cellId);
100  }
102 
104 
105  virtual int IntersectWithLine(
106  const double a0[3], const double a1[3],
107  vtkPoints *points, vtkIdList *cellIds)
108  {
109  return Superclass::
110  IntersectWithLine(a0, a1, points, cellIds);
111  }
113 
115 
119  virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
120  double& t, double x[3], double pcoords[3],
121  int &subId, vtkIdType &cellId,
122  vtkGenericCell *cell);
124 
126 
127  virtual void FindClosestPoint(
128  double x[3], double closestPoint[3],
129  vtkIdType &cellId, int &subId, double& dist2)
130  {
131  Superclass::
132  FindClosestPoint(x, closestPoint, cellId, subId, dist2);
133  }
135 
137 
146  virtual void FindClosestPoint(
147  double x[3], double closestPoint[3],
148  vtkGenericCell *cell, vtkIdType &cellId,
149  int &subId, double& dist2);
151 
153 
155  double x[3], double radius,
156  double closestPoint[3], vtkIdType &cellId,
157  int &subId, double& dist2)
158  {
159  return Superclass::FindClosestPointWithinRadius
160  (x, radius, closestPoint, cellId, subId, dist2);
161  }
163 
165 
167  double x[3], double radius,
168  double closestPoint[3],
169  vtkGenericCell *cell, vtkIdType &cellId,
170  int &subId, double& dist2)
171  {
172  return Superclass::FindClosestPointWithinRadius
173  (x, radius, closestPoint, cell, cellId, subId, dist2);
174  }
176 
178 
195  double x[3], double radius, double closestPoint[3],
196  vtkGenericCell *cell, vtkIdType &cellId,
197  int &subId, double& dist2, int &inside);
199 
201  virtual vtkIdList *GetCells(int bucket);
202 
205  virtual int GetNumberOfBuckets(void);
206 
208 
210  virtual vtkIdType FindCell(double x[3])
211  { return this->Superclass::FindCell(x); }
213 
215 
218  virtual vtkIdType FindCell(
219  double x[3], double tol2, vtkGenericCell *GenCell,
220  double pcoords[3], double *weights);
222 
226  virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells);
227 
229 
234  virtual void FindCellsAlongLine(
235  double p1[3], double p2[3], double tolerance, vtkIdList *cells);
237 
239 
240  virtual void FreeSearchStructure();
241  virtual void BuildLocator();
242  virtual void BuildLocatorIfNeeded();
243  virtual void ForceBuildLocator();
244  virtual void BuildLocatorInternal();
245  virtual void GenerateRepresentation(int level, vtkPolyData *pd);
247 
248 protected:
249  vtkCellLocator();
250  ~vtkCellLocator();
251 
252  void GetBucketNeighbors(int ijk[3], int ndivs, int level);
253  void GetOverlappingBuckets(double x[3], int ijk[3], double dist,
254  int prevMinLevel[3], int prevMaxLevel[3]);
255 
256  void ClearCellHasBeenVisited();
257  void ClearCellHasBeenVisited(int id);
258 
259  double Distance2ToBucket(double x[3], int nei[3]);
260  double Distance2ToBounds(double x[3], double bounds[6]);
261 
262  int NumberOfOctants; // number of octants in tree
263  double Bounds[6]; // bounding box root octant
264  int NumberOfParents; // number of parent octants
265  double H[3]; // width of leaf octant in x-y-z directions
266  int NumberOfDivisions; // number of "leaf" octant sub-divisions
267  vtkIdList **Tree; // octree
268 
269  void MarkParents(void*, int, int, int, int, int);
270  void GetChildren(int idx, int level, int children[8]);
271  int GenerateIndex(int offset, int numDivs, int i, int j, int k,
272  vtkIdType &idx);
273  void GenerateFace(int face, int numDivs, int i, int j, int k,
274  vtkPoints *pts, vtkCellArray *polys);
275 
276  vtkNeighborCells *Buckets;
277  unsigned char *CellHasBeenVisited;
278  unsigned char QueryNumber;
279 
280  void ComputeOctantBounds(int i, int j, int k);
281  double OctantBounds[6]; //the bounds of the current octant
282  int IsInOctantBounds(double x[3])
283  {
284  if ( this->OctantBounds[0] <= x[0] && x[0] <= this->OctantBounds[1] &&
285  this->OctantBounds[2] <= x[1] && x[1] <= this->OctantBounds[3] &&
286  this->OctantBounds[4] <= x[2] && x[2] <= this->OctantBounds[5] )
287  {
288  return 1;
289  }
290  else
291  {
292  return 0;
293  }
294  }
295 
296 private:
297  vtkCellLocator(const vtkCellLocator&); // Not implemented.
298  void operator=(const vtkCellLocator&); // Not implemented.
299 };
300 
301 #endif
302 
303 
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2)
int IsInOctantBounds(double x[3])
virtual void BuildLocator()=0
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
virtual void FindClosestPoint(double x[3], double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
virtual void FindCellsAlongLine(double p1[3], double p2[3], double tolerance, vtkIdList *cells)
virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells)
vtkNeighborCells * Buckets
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
virtual int IntersectWithLine(double a0[3], double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
GLintptr offset
Definition: vtkgl.h:11844
virtual void SetNumberOfCellsPerNode(int)
GLint level
Definition: vtkgl.h:11316
an abstract base class for locators which find cells
int GetNumberOfCellsPerBucket()
void SetNumberOfCellsPerBucket(int N)
int vtkIdType
Definition: vtkType.h:268
GLdouble GLdouble t
Definition: vtkgl.h:11602
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
virtual void FreeSearchStructure()=0
provides thread-safe access to cells
void PrintSelf(ostream &os, vtkIndent indent)
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
unsigned char * CellHasBeenVisited
octree-based spatial search object to quickly locate cells
const GLbyte * weights
Definition: vtkgl.h:12766
virtual vtkIdType FindCell(double x[3])
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual vtkIdType FindCell(double x[3])
list of point or cell ids
Definition: vtkIdList.h:35
unsigned char QueryNumber
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
object to represent cell connectivity
Definition: vtkCellArray.h:49
GLsizei const GLfloat * points
Definition: vtkgl.h:14786
vtkIdList ** Tree
virtual int IntersectWithLine(const double a0[3], const double a1[3], vtkPoints *points, vtkIdList *cellIds)
static vtkObject * New()
GLenum GLuint GLint GLenum face
Definition: vtkgl.h:13568
virtual int IntersectWithLine(double a0[3], double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId)
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
#define VTKCOMMONDATAMODEL_EXPORT
represent and manipulate 3D points
Definition: vtkPoints.h:39
virtual void FindClosestPoint(double x[3], double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)