VTK  9.5.2
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
35
36#ifndef vtkCellLocator_h
37#define vtkCellLocator_h
38
40#include "vtkCommonDataModelModule.h" // For export macro
41#include "vtkNew.h" // For vtkNew
42
43VTK_ABI_NAMESPACE_BEGIN
44class vtkIntArray;
45
46class VTKCOMMONDATAMODEL_EXPORT vtkCellLocator : public vtkAbstractCellLocator
47{
48public:
50
54 void PrintSelf(ostream& os, vtkIndent indent) override;
56
62
68
69 // Reuse any superclass signatures that we don't override.
74
81 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
82 double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) override;
83
93 int IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkPoints* points,
94 vtkIdList* cellIds, vtkGenericCell* cell) override;
95
105 void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell* cell,
106 vtkIdType& cellId, int& subId, double& dist2) override
107 {
108 this->Superclass::FindClosestPoint(x, closestPoint, cell, cellId, subId, dist2);
109 }
110
123 vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
124 vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside) override;
125
133 vtkIdType FindCell(double x[3], double vtkNotUsed(tol2), vtkGenericCell* GenCell, int& subId,
134 double pcoords[3], double* weights) override;
135
140 void FindCellsWithinBounds(double* bbox, vtkIdList* cells) override;
141
151 const double p1[3], const double p2[3], double tolerance, vtkIdList* cellsIds) override
152 {
153 this->Superclass::FindCellsAlongLine(p1, p2, tolerance, cellsIds);
154 }
155
157
160 void FreeSearchStructure() override;
161 void BuildLocator() override;
162 void ForceBuildLocator() override;
163 void GenerateRepresentation(int level, vtkPolyData* pd) override;
165
169 virtual vtkIdList* GetCells(int bucket);
170
175 virtual int GetNumberOfBuckets();
176
182 void ShallowCopy(vtkAbstractCellLocator* locator) override;
183
184protected:
186 ~vtkCellLocator() override;
187
188 void BuildLocatorInternal() override;
189
190 //------------------------------------------------------------------------------
192 {
193 public:
195
197
198 inline void Reset();
199
200 inline int* GetPoint(int i);
201
202 inline int InsertNextPoint(int* x);
203
204 protected:
206 };
207
208 void GetOverlappingBuckets(vtkNeighborCells& buckets, const double x[3], double dist,
209 int prevMinLevel[3], int prevMaxLevel[3]);
210
211 inline void GetBucketIndices(const double x[3], int ijk[3]);
212
213 double Distance2ToBucket(const double x[3], int nei[3]);
214 double Distance2ToBounds(const double x[3], double bounds[6]);
215
216 int NumberOfOctants; // number of octants in tree
217 double Bounds[6]; // bounding box root octant
218 double H[3]; // width of leaf octant in x-y-z directions
219 int NumberOfDivisions; // number of "leaf" octant sub-divisions
220 std::shared_ptr<std::vector<vtkSmartPointer<vtkIdList>>> TreeSharedPtr;
222
223 void MarkParents(const vtkSmartPointer<vtkIdList>&, int, int, int, int, int);
224 int GenerateIndex(int offset, int numDivs, int i, int j, int k, vtkIdType& idx);
226 int face, int numDivs, int i, int j, int k, vtkPoints* pts, vtkCellArray* polys);
227 void ComputeOctantBounds(double octantBounds[6], int i, int j, int k);
228
229private:
230 vtkCellLocator(const vtkCellLocator&) = delete;
231 void operator=(const vtkCellLocator&) = delete;
232};
233
234VTK_ABI_NAMESPACE_END
235#endif
virtual vtkIdType FindCell(double x[3])
Returns the Id of the cell containing the point, returns -1 if no cell found.
virtual void SetNumberOfCellsPerNode(int)
Specify the preferred/maximum number of cells in each node/bucket.
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.
virtual void FindCellsAlongLine(const double p1[3], const double p2[3], double tolerance, vtkIdList *cells)
Take the passed line segment and intersect it with the data set.
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 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.
object to represent cell connectivity
virtual vtkIdList * GetCells(int bucket)
Get the cells in a particular bucket.
void MarkParents(const vtkSmartPointer< vtkIdList > &, int, int, int, int, int)
void FreeSearchStructure() override
Satisfy vtkLocator abstract interface.
static vtkCellLocator * New()
Construct with automatic computation of divisions, averaging 25 cells per bucket.
~vtkCellLocator() override
double Distance2ToBounds(const double x[3], double bounds[6])
int GenerateIndex(int offset, int numDivs, int i, int j, int k, vtkIdType &idx)
int GetNumberOfCellsPerBucket()
void GetBucketIndices(const double x[3], int ijk[3])
void GenerateRepresentation(int level, vtkPolyData *pd) override
Satisfy vtkLocator abstract interface.
void GetOverlappingBuckets(vtkNeighborCells &buckets, const double x[3], double dist, int prevMinLevel[3], int prevMaxLevel[3])
virtual int GetNumberOfBuckets()
Return number of buckets available.
void SetNumberOfCellsPerBucket(int N)
Specify the average number of cells in each octant.
void FindCellsWithinBounds(double *bbox, vtkIdList *cells) override
Return a list of unique cell ids inside of a given bounding box.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods to print and obtain type-related information.
void ComputeOctantBounds(double octantBounds[6], int i, int j, int k)
double Distance2ToBucket(const double x[3], int nei[3])
int IntersectWithLine(const double p1[3], const double p2[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.
std::shared_ptr< std::vector< vtkSmartPointer< vtkIdList > > > TreeSharedPtr
void GenerateFace(int face, int numDivs, int i, int j, int k, vtkPoints *pts, vtkCellArray *polys)
int IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkPoints *points, vtkIdList *cellIds, vtkGenericCell *cell) override
Take the passed line segment and intersect it with the data set.
void BuildLocatorInternal() override
This function is not pure virtual to maintain backwards compatibility.
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.
void ForceBuildLocator() override
Satisfy vtkLocator abstract interface.
void ShallowCopy(vtkAbstractCellLocator *locator) override
Shallow copy of a vtkCellLocator.
vtkSmartPointer< vtkIdList > * Tree
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.
void BuildLocator() override
Satisfy vtkLocator abstract interface.
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.
vtkIdType FindCell(double x[3], double vtkNotUsed(tol2), vtkGenericCell *GenCell, int &subId, double pcoords[3], double *weights) override
Find the cell containing a given point.
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:24
a simple class to control print indentation
Definition vtkIndent.h:29
dynamic, self-adjusting array of int
Definition vtkIntArray.h:35
Allocate and hold a VTK object.
Definition vtkNew.h:58
represent and manipulate 3D points
Definition vtkPoints.h:30
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition vtkType.h:332