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 =========================================================================*/
44 #ifndef vtkCellLocator_h
45 #define vtkCellLocator_h
46 
47 #include "vtkCommonDataModelModule.h" // For export macro
48 #include "vtkAbstractCellLocator.h"
49 
50 class vtkNeighborCells;
51 
52 class VTKCOMMONDATAMODEL_EXPORT vtkCellLocator : public vtkAbstractCellLocator
53 {
54 public:
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
62  static vtkCellLocator *New();
63 
68  { this->SetNumberOfCellsPerNode(N); }
70  { return this->NumberOfCellsPerNode; }
71 
72  // Re-use any superclass signatures that we don't override.
77 
84  int IntersectWithLine(const double a0[3], const double a1[3], double tol,
85  double& t, double x[3], double pcoords[3],
86  int &subId, vtkIdType &cellId,
87  vtkGenericCell *cell) override;
88 
101  const double x[3], double closestPoint[3],
102  vtkGenericCell *cell, vtkIdType &cellId,
103  int &subId, double& dist2) override;
104 
123  double x[3], double radius, double closestPoint[3],
124  vtkGenericCell *cell, vtkIdType &cellId,
125  int &subId, double& dist2, int &inside) override;
126 
130  virtual vtkIdList *GetCells(int bucket);
131 
136  virtual int GetNumberOfBuckets(void);
137 
144  double x[3], double tol2, vtkGenericCell *GenCell,
145  double pcoords[3], double *weights) override;
146 
152  void FindCellsWithinBounds(double *bbox, vtkIdList *cells) override;
153 
161  void FindCellsAlongLine(const double p1[3], const double p2[3],
162  double tolerance, vtkIdList *cells) override;
163 
165 
168  void FreeSearchStructure() override;
169  void BuildLocator() override;
170  virtual void BuildLocatorIfNeeded();
171  virtual void ForceBuildLocator();
172  virtual void BuildLocatorInternal();
173  void GenerateRepresentation(int level, vtkPolyData *pd) override;
175 
176 protected:
178  ~vtkCellLocator() override;
179 
180  void GetBucketNeighbors(int ijk[3], int ndivs, int level);
181  void GetOverlappingBuckets(const double x[3], int ijk[3], double dist,
182  int prevMinLevel[3], int prevMaxLevel[3]);
183 
186 
187  double Distance2ToBucket(const double x[3], int nei[3]);
188  double Distance2ToBounds(const double x[3], double bounds[6]);
189 
190  int NumberOfOctants; // number of octants in tree
191  double Bounds[6]; // bounding box root octant
192  int NumberOfParents; // number of parent octants
193  double H[3]; // width of leaf octant in x-y-z directions
194  int NumberOfDivisions; // number of "leaf" octant sub-divisions
195  vtkIdList **Tree; // octree
196 
197  void MarkParents(void*, int, int, int, int, int);
198  void GetChildren(int idx, int level, int children[8]);
199  int GenerateIndex(int offset, int numDivs, int i, int j, int k,
200  vtkIdType &idx);
201  void GenerateFace(int face, int numDivs, int i, int j, int k,
202  vtkPoints *pts, vtkCellArray *polys);
203 
204  vtkNeighborCells *Buckets;
205  unsigned char *CellHasBeenVisited;
206  unsigned char QueryNumber;
207 
208  void ComputeOctantBounds(int i, int j, int k);
209  double OctantBounds[6]; //the bounds of the current octant
210  int IsInOctantBounds(const double x[3], double tol = 0.0)
211  {
212  if ( this->OctantBounds[0]-tol <= x[0] && x[0] <= this->OctantBounds[1]+tol &&
213  this->OctantBounds[2]-tol <= x[1] && x[1] <= this->OctantBounds[3]+tol &&
214  this->OctantBounds[4]-tol <= x[2] && x[2] <= this->OctantBounds[5]+tol )
215  {
216  return 1;
217  }
218  else
219  {
220  return 0;
221  }
222  }
223 
224 private:
225  vtkCellLocator(const vtkCellLocator&) = delete;
226  void operator=(const vtkCellLocator&) = delete;
227 };
228 
229 #endif
vtkCellLocator::IsInOctantBounds
int IsInOctantBounds(const double x[3], double tol=0.0)
Definition: vtkCellLocator.h:210
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:40
vtkCellLocator::Distance2ToBounds
double Distance2ToBounds(const double x[3], double bounds[6])
vtkCellLocator::NumberOfDivisions
int NumberOfDivisions
Definition: vtkCellLocator.h:194
vtkCellLocator::GenerateIndex
int GenerateIndex(int offset, int numDivs, int i, int j, int k, vtkIdType &idx)
vtkCellLocator::vtkCellLocator
vtkCellLocator()
vtkCellLocator
octree-based spatial search object to quickly locate cells
Definition: vtkCellLocator.h:53
vtkCellLocator::ClearCellHasBeenVisited
void ClearCellHasBeenVisited(vtkIdType id)
vtkCellLocator::GetNumberOfBuckets
virtual int GetNumberOfBuckets(void)
Return number of buckets available.
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkCellLocator::NumberOfParents
int NumberOfParents
Definition: vtkCellLocator.h:192
vtkCellLocator::BuildLocatorIfNeeded
virtual void BuildLocatorIfNeeded()
vtkCellLocator::BuildLocatorInternal
virtual void BuildLocatorInternal()
vtkCellLocator::BuildLocator
void BuildLocator() override
Build the locator from the input dataset.
vtkAbstractCellLocator.h
vtkAbstractCellLocator::FindCell
virtual vtkIdType FindCell(double x[3])
Returns the Id of the cell containing the point, returns -1 if no cell found.
vtkCellLocator::FreeSearchStructure
void FreeSearchStructure() override
Satisfy vtkLocator abstract interface.
vtkCellLocator::ComputeOctantBounds
void ComputeOctantBounds(int i, int j, int k)
vtkAbstractCellLocator::FindClosestPointWithinRadius
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.
vtkCellLocator::Tree
vtkIdList ** Tree
Definition: vtkCellLocator.h:195
vtkCellLocator::FindClosestPointWithinRadius
vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2, int &inside) override
Return the closest point within a specified radius and the cell which is closest to the point x.
vtkCellLocator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCellLocator::GetOverlappingBuckets
void GetOverlappingBuckets(const double x[3], int ijk[3], double dist, int prevMinLevel[3], int prevMaxLevel[3])
vtkX3D::level
@ level
Definition: vtkX3D.h:395
vtkCellLocator::FindClosestPoint
void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2) override
Return the closest point and the cell which is closest to the point x.
vtkAbstractCellLocator::NumberOfCellsPerNode
int NumberOfCellsPerNode
Definition: vtkAbstractCellLocator.h:286
vtkAbstractCellLocator::SetNumberOfCellsPerNode
virtual void SetNumberOfCellsPerNode(int)
Specify the preferred/maximum number of cells in each node/bucket.
vtkX3D::offset
@ offset
Definition: vtkX3D.h:438
vtkCellLocator::IntersectWithLine
int IntersectWithLine(const double a0[3], const double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId, vtkGenericCell *cell) override
Return intersection point (if any) AND the cell which was intersected by the finite line.
vtkCellLocator::FindCell
vtkIdType FindCell(double x[3], double tol2, vtkGenericCell *GenCell, double pcoords[3], double *weights) override
Find the cell containing a given point.
vtkCellLocator::GetCells
virtual vtkIdList * GetCells(int bucket)
Get the cells in a particular bucket.
vtkCellLocator::SetNumberOfCellsPerBucket
void SetNumberOfCellsPerBucket(int N)
Specify the average number of cells in each octant.
Definition: vtkCellLocator.h:67
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:51
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:37
vtkCellLocator::CellHasBeenVisited
unsigned char * CellHasBeenVisited
Definition: vtkCellLocator.h:205
vtkCellLocator::GetBucketNeighbors
void GetBucketNeighbors(int ijk[3], int ndivs, int level)
vtkAbstractCellLocator
an abstract base class for locators which find cells
Definition: vtkAbstractCellLocator.h:49
vtkCellLocator::GetNumberOfCellsPerBucket
int GetNumberOfCellsPerBucket()
Definition: vtkCellLocator.h:69
vtkAbstractCellLocator::FindClosestPoint
virtual void FindClosestPoint(const 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.
vtkCellLocator::ForceBuildLocator
virtual void ForceBuildLocator()
vtkCellLocator::GetChildren
void GetChildren(int idx, int level, int children[8])
vtkCellLocator::FindCellsWithinBounds
void FindCellsWithinBounds(double *bbox, vtkIdList *cells) override
Return a list of unique cell ids inside of a given bounding box.
vtkCellLocator::GenerateRepresentation
void GenerateRepresentation(int level, vtkPolyData *pd) override
Method to build a representation at a particular level.
vtkCellLocator::Buckets
vtkNeighborCells * Buckets
Definition: vtkCellLocator.h:204
vtkAbstractCellLocator::IntersectWithLine
virtual int IntersectWithLine(const double p1[3], const 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.
vtkCellLocator::~vtkCellLocator
~vtkCellLocator() override
vtkCellLocator::GenerateFace
void GenerateFace(int face, int numDivs, int i, int j, int k, vtkPoints *pts, vtkCellArray *polys)
vtkCellLocator::QueryNumber
unsigned char QueryNumber
Definition: vtkCellLocator.h:206
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
vtkCellLocator::MarkParents
void MarkParents(void *, int, int, int, int, int)
vtkCellLocator::NumberOfOctants
int NumberOfOctants
Definition: vtkCellLocator.h:190
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:40
vtkCellLocator::FindCellsAlongLine
void FindCellsAlongLine(const double p1[3], const double p2[3], double tolerance, vtkIdList *cells) override
Given a finite line defined by the two points (p1,p2), return the list of unique cell ids in the buck...
vtkCellLocator::New
static vtkCellLocator * New()
Construct with automatic computation of divisions, averaging 25 cells per bucket.
vtkCellLocator::ClearCellHasBeenVisited
void ClearCellHasBeenVisited()
vtkX3D::radius
@ radius
Definition: vtkX3D.h:252
vtkCellLocator::Distance2ToBucket
double Distance2ToBucket(const double x[3], int nei[3])