VTK
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 =========================================================================*/
38 #ifndef vtkCellLocator_h
39 #define vtkCellLocator_h
40 
41 #include "vtkCommonDataModelModule.h" // For export macro
42 #include "vtkAbstractCellLocator.h"
43 
44 class vtkNeighborCells;
45 
46 class VTKCOMMONDATAMODEL_EXPORT vtkCellLocator : public vtkAbstractCellLocator
47 {
48 public:
50  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
51 
56  static vtkCellLocator *New();
57 
62  { this->SetNumberOfCellsPerNode(N); }
64  { return this->NumberOfCellsPerNode; }
65 
66  // Re-use any superclass signatures that we don't override.
71 
77  int IntersectWithLine(double a0[3], double a1[3], double tol,
78  double& t, double x[3], double pcoords[3],
79  int &subId, vtkIdType &cellId,
80  vtkGenericCell *cell) VTK_OVERRIDE;
81 
93  void FindClosestPoint(
94  double x[3], double closestPoint[3],
95  vtkGenericCell *cell, vtkIdType &cellId,
96  int &subId, double& dist2) VTK_OVERRIDE;
97 
116  double x[3], double radius, double closestPoint[3],
117  vtkGenericCell *cell, vtkIdType &cellId,
118  int &subId, double& dist2, int &inside) VTK_OVERRIDE;
119 
123  virtual vtkIdList *GetCells(int bucket);
124 
129  virtual int GetNumberOfBuckets(void);
130 
137  double x[3], double tol2, vtkGenericCell *GenCell,
138  double pcoords[3], double *weights) VTK_OVERRIDE;
139 
145  void FindCellsWithinBounds(double *bbox, vtkIdList *cells) VTK_OVERRIDE;
146 
154  void FindCellsAlongLine(double p1[3], double p2[3],
155  double tolerance, vtkIdList *cells) VTK_OVERRIDE;
156 
158 
161  void FreeSearchStructure() VTK_OVERRIDE;
162  void BuildLocator() VTK_OVERRIDE;
163  virtual void BuildLocatorIfNeeded();
164  virtual void ForceBuildLocator();
165  virtual void BuildLocatorInternal();
166  void GenerateRepresentation(int level, vtkPolyData *pd) VTK_OVERRIDE;
168 
169 protected:
170  vtkCellLocator();
171  ~vtkCellLocator() VTK_OVERRIDE;
172 
173  void GetBucketNeighbors(int ijk[3], int ndivs, int level);
174  void GetOverlappingBuckets(double x[3], int ijk[3], double dist,
175  int prevMinLevel[3], int prevMaxLevel[3]);
176 
177  void ClearCellHasBeenVisited();
178  void ClearCellHasBeenVisited(int id);
179 
180  double Distance2ToBucket(double x[3], int nei[3]);
181  double Distance2ToBounds(double x[3], double bounds[6]);
182 
183  int NumberOfOctants; // number of octants in tree
184  double Bounds[6]; // bounding box root octant
185  int NumberOfParents; // number of parent octants
186  double H[3]; // width of leaf octant in x-y-z directions
187  int NumberOfDivisions; // number of "leaf" octant sub-divisions
188  vtkIdList **Tree; // octree
189 
190  void MarkParents(void*, int, int, int, int, int);
191  void GetChildren(int idx, int level, int children[8]);
192  int GenerateIndex(int offset, int numDivs, int i, int j, int k,
193  vtkIdType &idx);
194  void GenerateFace(int face, int numDivs, int i, int j, int k,
195  vtkPoints *pts, vtkCellArray *polys);
196 
197  vtkNeighborCells *Buckets;
198  unsigned char *CellHasBeenVisited;
199  unsigned char QueryNumber;
200 
201  void ComputeOctantBounds(int i, int j, int k);
202  double OctantBounds[6]; //the bounds of the current octant
203  int IsInOctantBounds(double x[3], double tol = 0.0)
204  {
205  if ( this->OctantBounds[0]-tol <= x[0] && x[0] <= this->OctantBounds[1]+tol &&
206  this->OctantBounds[2]-tol <= x[1] && x[1] <= this->OctantBounds[3]+tol &&
207  this->OctantBounds[4]-tol <= x[2] && x[2] <= this->OctantBounds[5]+tol )
208  {
209  return 1;
210  }
211  else
212  {
213  return 0;
214  }
215  }
216 
217 private:
218  vtkCellLocator(const vtkCellLocator&) VTK_DELETE_FUNCTION;
219  void operator=(const vtkCellLocator&) VTK_DELETE_FUNCTION;
220 };
221 
222 #endif
223 
224 
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
Return the closest point within a specified radius and the cell which is closest to the point x...
virtual void FindClosestPoint(double x[3], double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
Return the closest point and the cell which is closest to the point x.
virtual void FindCellsAlongLine(double p1[3], double p2[3], double tolerance, vtkIdList *cells)
Given a finite line defined by the two points (p1,p2), return the list of unique cell ids in the buck...
virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells)
Return a list of unique cell ids inside of a given bounding box.
virtual void SetNumberOfCellsPerNode(int)
Specify the preferred/maximum number of cells in each node/bucket.
an abstract base class for locators which find cells
int GetNumberOfCellsPerBucket()
void SetNumberOfCellsPerBucket(int N)
Specify the average number of cells in each octant.
int vtkIdType
Definition: vtkType.h:345
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
virtual void FreeSearchStructure()=0
Free the memory required for the spatial data structure.
provides thread-safe access to cells
octree-based spatial search object to quickly locate cells
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual vtkIdType FindCell(double x[3])
Returns the Id of the cell containing the point, returns -1 if no cell found.
list of point or cell ids
Definition: vtkIdList.h:30
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
Return intersection point (if any) of finite line with cells contained in cell locator.
object to represent cell connectivity
Definition: vtkCellArray.h:44
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
represent and manipulate 3D points
Definition: vtkPoints.h:33