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 =========================================================================*/
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  // Re-use any superclass signatures that we don't override.
74 
76 
80  virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
81  double& t, double x[3], double pcoords[3],
82  int &subId, vtkIdType &cellId,
83  vtkGenericCell *cell);
85 
87 
96  virtual void FindClosestPoint(
97  double x[3], double closestPoint[3],
98  vtkGenericCell *cell, vtkIdType &cellId,
99  int &subId, double& dist2);
101 
103 
120  double x[3], double radius, double closestPoint[3],
121  vtkGenericCell *cell, vtkIdType &cellId,
122  int &subId, double& dist2, int &inside);
124 
126  virtual vtkIdList *GetCells(int bucket);
127 
130  virtual int GetNumberOfBuckets(void);
131 
133 
137  double x[3], double tol2, vtkGenericCell *GenCell,
138  double pcoords[3], double *weights);
140 
144  virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells);
145 
147 
152  virtual void FindCellsAlongLine(
153  double p1[3], double p2[3], double tolerance, vtkIdList *cells);
155 
157 
158  virtual void FreeSearchStructure();
159  virtual void BuildLocator();
160  virtual void BuildLocatorIfNeeded();
161  virtual void ForceBuildLocator();
162  virtual void BuildLocatorInternal();
163  virtual void GenerateRepresentation(int level, vtkPolyData *pd);
165 
166 protected:
169 
170  void GetBucketNeighbors(int ijk[3], int ndivs, int level);
171  void GetOverlappingBuckets(double x[3], int ijk[3], double dist,
172  int prevMinLevel[3], int prevMaxLevel[3]);
173 
176 
177  double Distance2ToBucket(double x[3], int nei[3]);
178  double Distance2ToBounds(double x[3], double bounds[6]);
179 
180  int NumberOfOctants; // number of octants in tree
181  double Bounds[6]; // bounding box root octant
182  int NumberOfParents; // number of parent octants
183  double H[3]; // width of leaf octant in x-y-z directions
184  int NumberOfDivisions; // number of "leaf" octant sub-divisions
185  vtkIdList **Tree; // octree
186 
187  void MarkParents(void*, int, int, int, int, int);
188  void GetChildren(int idx, int level, int children[8]);
189  int GenerateIndex(int offset, int numDivs, int i, int j, int k,
190  vtkIdType &idx);
191  void GenerateFace(int face, int numDivs, int i, int j, int k,
192  vtkPoints *pts, vtkCellArray *polys);
193 
194  vtkNeighborCells *Buckets;
195  unsigned char *CellHasBeenVisited;
196  unsigned char QueryNumber;
197 
198  void ComputeOctantBounds(int i, int j, int k);
199  double OctantBounds[6]; //the bounds of the current octant
200  int IsInOctantBounds(double x[3], double tol = 0.0)
201  {
202  if ( this->OctantBounds[0]-tol <= x[0] && x[0] <= this->OctantBounds[1]+tol &&
203  this->OctantBounds[2]-tol <= x[1] && x[1] <= this->OctantBounds[3]+tol &&
204  this->OctantBounds[4]-tol <= x[2] && x[2] <= this->OctantBounds[5]+tol )
205  {
206  return 1;
207  }
208  else
209  {
210  return 0;
211  }
212  }
213 
214 private:
215  vtkCellLocator(const vtkCellLocator&); // Not implemented.
216  void operator=(const vtkCellLocator&); // Not implemented.
217 };
218 
219 #endif
220 
221 
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkCellLocator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkCellLocator::NumberOfDivisions
int NumberOfDivisions
Definition: vtkCellLocator.h:184
vtkgl::weights
const GLbyte * weights
Definition: vtkgl.h:12766
vtkCellLocator::FindCellsWithinBounds
virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells)
vtkCellLocator::GenerateIndex
int GenerateIndex(int offset, int numDivs, int i, int j, int k, vtkIdType &idx)
vtkCellLocator::vtkCellLocator
vtkCellLocator()
vtkAbstractCellLocator::IntersectWithLine
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
vtkCellLocator
octree-based spatial search object to quickly locate cells
Definition: vtkCellLocator.h:52
vtkCellLocator::~vtkCellLocator
~vtkCellLocator()
vtkCellLocator::GetNumberOfBuckets
virtual int GetNumberOfBuckets(void)
vtkCellLocator::Distance2ToBucket
double Distance2ToBucket(double x[3], int nei[3])
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkCellLocator::NumberOfParents
int NumberOfParents
Definition: vtkCellLocator.h:182
vtkCommonDataModelModule.h
vtkCellLocator::BuildLocatorIfNeeded
virtual void BuildLocatorIfNeeded()
vtkCellLocator::BuildLocatorInternal
virtual void BuildLocatorInternal()
vtkCellLocator::Distance2ToBounds
double Distance2ToBounds(double x[3], double bounds[6])
vtkCellLocator::FreeSearchStructure
virtual void FreeSearchStructure()
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkCellLocator::FindCell
virtual vtkIdType FindCell(double x[3], double tol2, vtkGenericCell *GenCell, double pcoords[3], double *weights)
vtkAbstractCellLocator.h
vtkAbstractCellLocator::FindCell
virtual vtkIdType FindCell(double x[3])
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
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)
vtkCellLocator::ClearCellHasBeenVisited
void ClearCellHasBeenVisited(int id)
vtkAbstractCellLocator::FindClosestPoint
virtual void FindClosestPoint(double x[3], double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
vtkCellLocator::Tree
vtkIdList ** Tree
Definition: vtkCellLocator.h:185
vtkCellLocator::FindCellsAlongLine
virtual void FindCellsAlongLine(double p1[3], double p2[3], double tolerance, vtkIdList *cells)
vtkCellLocator::FindClosestPointWithinRadius
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2, int &inside)
vtkAbstractCellLocator::NumberOfCellsPerNode
int NumberOfCellsPerNode
Definition: vtkAbstractCellLocator.h:274
vtkAbstractCellLocator::SetNumberOfCellsPerNode
virtual void SetNumberOfCellsPerNode(int)
vtkCellLocator::GetCells
virtual vtkIdList * GetCells(int bucket)
vtkCellLocator::IntersectWithLine
virtual int IntersectWithLine(double a0[3], double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId, vtkGenericCell *cell)
vtkCellLocator::SetNumberOfCellsPerBucket
void SetNumberOfCellsPerBucket(int N)
Definition: vtkCellLocator.h:63
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:50
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkCellLocator::GenerateRepresentation
virtual void GenerateRepresentation(int level, vtkPolyData *pd)
vtkCellLocator::CellHasBeenVisited
unsigned char * CellHasBeenVisited
Definition: vtkCellLocator.h:195
vtkCellLocator::GetBucketNeighbors
void GetBucketNeighbors(int ijk[3], int ndivs, int level)
vtkgl::offset
GLintptr offset
Definition: vtkgl.h:11844
vtkgl::level
GLint level
Definition: vtkgl.h:11316
vtkAbstractCellLocator
an abstract base class for locators which find cells
Definition: vtkAbstractCellLocator.h:50
vtkCellLocator::GetNumberOfCellsPerBucket
int GetNumberOfCellsPerBucket()
Definition: vtkCellLocator.h:65
vtkCellLocator::ForceBuildLocator
virtual void ForceBuildLocator()
vtkCellLocator::GetChildren
void GetChildren(int idx, int level, int children[8])
vtkCellLocator::IsInOctantBounds
int IsInOctantBounds(double x[3], double tol=0.0)
Definition: vtkCellLocator.h:200
vtkgl::t
GLdouble GLdouble t
Definition: vtkgl.h:11602
vtkCellLocator::Buckets
vtkNeighborCells * Buckets
Definition: vtkCellLocator.h:194
vtkCellLocator::BuildLocator
virtual void BuildLocator()
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:196
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkCellLocator::MarkParents
void MarkParents(void *, int, int, int, int, int)
vtkCellLocator::NumberOfOctants
int NumberOfOctants
Definition: vtkCellLocator.h:180
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:42
vtkCellLocator::FindClosestPoint
virtual void FindClosestPoint(double x[3], double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2)
vtkgl::face
GLenum GLuint GLint GLenum face
Definition: vtkgl.h:13568
VTKCOMMONDATAMODEL_EXPORT
#define VTKCOMMONDATAMODEL_EXPORT
Definition: vtkCommonDataModelModule.h:15
vtkCellLocator::New
static vtkCellLocator * New()
vtkCellLocator::ClearCellHasBeenVisited
void ClearCellHasBeenVisited()
vtkX3D::radius
@ radius
Definition: vtkX3D.h:252
vtkCellLocator::GetOverlappingBuckets
void GetOverlappingBuckets(double x[3], int ijk[3], double dist, int prevMinLevel[3], int prevMaxLevel[3])