VTK  9.3.1
vtkCellLocator.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
36 #ifndef vtkCellLocator_h
37 #define vtkCellLocator_h
38 
39 #include "vtkAbstractCellLocator.h"
40 #include "vtkCommonDataModelModule.h" // For export macro
41 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
42 #include "vtkNew.h" // For vtkNew
43 
44 VTK_ABI_NAMESPACE_BEGIN
45 class vtkIntArray;
46 
47 class VTKCOMMONDATAMODEL_EXPORT vtkCellLocator : public vtkAbstractCellLocator
48 {
49 public:
51 
55  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
62  static vtkCellLocator* New();
63 
69 
70  // Re-use any superclass signatures that we don't override.
75 
82  int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
83  double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) override;
84 
94  int IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkPoints* points,
95  vtkIdList* cellIds, vtkGenericCell* cell) override;
96 
106  void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell* cell,
107  vtkIdType& cellId, int& subId, double& dist2) override
108  {
109  this->Superclass::FindClosestPoint(x, closestPoint, cell, cellId, subId, dist2);
110  }
111 
124  vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
125  vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside) override;
126 
134  vtkIdType FindCell(double x[3], double vtkNotUsed(tol2), vtkGenericCell* GenCell, int& subId,
135  double pcoords[3], double* weights) override;
136 
141  void FindCellsWithinBounds(double* bbox, vtkIdList* cells) override;
142 
152  const double p1[3], const double p2[3], double tolerance, vtkIdList* cellsIds) override
153  {
154  this->Superclass::FindCellsAlongLine(p1, p2, tolerance, cellsIds);
155  }
156 
158 
161  void FreeSearchStructure() override;
162  void BuildLocator() override;
163  void ForceBuildLocator() override;
164  void GenerateRepresentation(int level, vtkPolyData* pd) override;
166 
167  VTK_DEPRECATED_IN_9_2_0("This method is deprecated because LazyEvaluation has been deprecated")
168  virtual void BuildLocatorIfNeeded() {}
169 
173  virtual vtkIdList* GetCells(int bucket);
174 
179  virtual int GetNumberOfBuckets();
180 
184  void ShallowCopy(vtkAbstractCellLocator* locator) override;
185 
186 protected:
187  vtkCellLocator();
188  ~vtkCellLocator() override;
189 
190  void BuildLocatorInternal() override;
191 
192  //------------------------------------------------------------------------------
194  {
195  public:
196  vtkNeighborCells(int size);
197 
198  inline int GetNumberOfNeighbors();
199 
200  inline void Reset();
201 
202  inline int* GetPoint(int i);
203 
204  inline int InsertNextPoint(int* x);
205 
206  protected:
208  };
209 
210  void GetOverlappingBuckets(vtkNeighborCells& buckets, const double x[3], double dist,
211  int prevMinLevel[3], int prevMaxLevel[3]);
212 
213  inline void GetBucketIndices(const double x[3], int ijk[3]);
214 
215  double Distance2ToBucket(const double x[3], int nei[3]);
216  double Distance2ToBounds(const double x[3], double bounds[6]);
217 
218  int NumberOfOctants; // number of octants in tree
219  double Bounds[6]; // bounding box root octant
220  double H[3]; // width of leaf octant in x-y-z directions
221  int NumberOfDivisions; // number of "leaf" octant sub-divisions
222  std::shared_ptr<std::vector<vtkSmartPointer<vtkIdList>>> TreeSharedPtr;
224 
225  void MarkParents(const vtkSmartPointer<vtkIdList>&, int, int, int, int, int);
226  int GenerateIndex(int offset, int numDivs, int i, int j, int k, vtkIdType& idx);
227  void GenerateFace(
228  int face, int numDivs, int i, int j, int k, vtkPoints* pts, vtkCellArray* polys);
229  void ComputeOctantBounds(double octantBounds[6], int i, int j, int k);
230 
231 private:
232  vtkCellLocator(const vtkCellLocator&) = delete;
233  void operator=(const vtkCellLocator&) = delete;
234 };
235 
236 VTK_ABI_NAMESPACE_END
237 #endif
virtual void BuildLocator()=0
Build the locator from the input dataset.
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 FindCellsWithinBounds(double *bbox, vtkIdList *cells)
Return a list of unique cell ids inside of a given bounding box.
void FindCellsAlongLine(const double p1[3], const double p2[3], double tolerance, vtkIdList *cellsIds) override
Take the passed line segment and intersect it with the data set.
#define VTK_DEPRECATED_IN_9_2_0(reason)
virtual void SetNumberOfCellsPerNode(int)
Specify the preferred/maximum number of cells in each node/bucket.
an abstract base class for locators which find cells
vtkSmartPointer< vtkIdList > * Tree
std::shared_ptr< std::vector< vtkSmartPointer< vtkIdList > > > TreeSharedPtr
int GetNumberOfCellsPerBucket()
void SetNumberOfCellsPerBucket(int N)
Specify the average number of cells in each octant.
int vtkIdType
Definition: vtkType.h:315
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
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.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:34
virtual void ShallowCopy(vtkAbstractCellLocator *)
Shallow copy of a vtkAbstractCellLocator.
octree-based spatial search object to quickly locate cells
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.
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.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void BuildLocatorInternal()
This function is not pure virtual to maintain backwards compatibility.
Definition: vtkLocator.h:192
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:22
object to represent cell connectivity
Definition: vtkCellArray.h:175
void GetPoint(int i, int j, int k, double pnt[3])
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...
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
Method to build a representation at a particular level.
represent and manipulate 3D points
Definition: vtkPoints.h:28
virtual void ForceBuildLocator()
Build the locator from the input dataset (even if UseExistingSearchStructure is on).
Definition: vtkLocator.h:156
vtkNew< vtkIntArray > Points