VTK  9.6.20260522
vtkAbstractCellLocator.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
27
28#ifndef vtkAbstractCellLocator_h
29#define vtkAbstractCellLocator_h
30
31#include "vtkCommonDataModelModule.h" // For export macro
32#include "vtkLocator.h"
33#include "vtkNew.h" // For vtkNew
34
35#include <memory> // For shared_ptr
36#include <vector> // For Weights
37
38VTK_ABI_NAMESPACE_BEGIN
39class vtkCell;
40class vtkCellArray;
41class vtkGenericCell;
42class vtkIdList;
43class vtkPoints;
44
45class VTKCOMMONDATAMODEL_EXPORT vtkAbstractCellLocator : public vtkLocator
46{
47public:
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
52
58 vtkSetClampMacro(NumberOfCellsPerNode, int, 1, VTK_INT_MAX);
59 vtkGetMacro(NumberOfCellsPerNode, int);
61
63
72 vtkBooleanMacro(CacheCellBounds, vtkTypeBool);
74
80
82
89 vtkBooleanMacro(RetainCellLists, vtkTypeBool);
91
98 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
99 double x[3], double pcoords[3], int& subId);
100
107 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
108 double x[3], double pcoords[3], int& subId, vtkIdType& cellId);
109
118 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
119 double x[3], double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell);
120
132 virtual int IntersectWithLine(
133 const double p1[3], const double p2[3], vtkPoints* points, vtkIdList* cellIds);
134
144 virtual int IntersectWithLine(
145 const double p1[3], const double p2[3], double tol, vtkPoints* points, vtkIdList* cellIds);
146
158 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol,
159 vtkPoints* points, vtkIdList* cellIds, vtkGenericCell* cell);
160
171 virtual void FindClosestPoint(
172 const double x[3], double closestPoint[3], vtkIdType& cellId, int& subId, double& dist2);
173
191 virtual void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell* cell,
192 vtkIdType& cellId, int& subId, double& dist2);
193
204 virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
205 vtkIdType& cellId, int& subId, double& dist2);
206
223 virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
224 vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2);
225
244 virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
245 vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside);
246
253 virtual void FindCellsWithinBounds(double* bbox, vtkIdList* cells);
254
266 void FindCellsAlongLine(const double p1[3], const double p2[3], double tol, vtkIdList* cells);
267
278 const double o[3], const double n[3], double tol, vtkIdList* cells);
279
286 vtkIdType FindCell(double x[3]);
287
294 vtkIdType FindCell(double x[3], double tol2);
295
297
305 double x[3], double tol2, vtkGenericCell* genCell, double pcoords[3], double* weights);
306 virtual vtkIdType FindCell(double x[3], double tol2, vtkGenericCell* genCell, int& subId,
307 double pcoords[3], double* weights);
309
311
321 virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* genCell, vtkIdType cellId,
322 double tol2, int& subId, double pcoords[3], double* weights);
323
329 virtual bool InsideCellBounds(double x[3], vtkIdType cell_ID, double tol = 0.0);
330
337
338protected:
341
343
350 virtual bool StoreCellBounds();
351 virtual void FreeCellBounds();
353
359
364 std::shared_ptr<std::vector<double>> CellBoundsSharedPtr;
365 double* CellBounds; // The is just used for simplicity in the internal code
366
371
372 static bool IsInBounds(const double bounds[6], const double x[3], double tol = 0.0);
373
374 /*
375 * This function should be used ONLY after the locator is built.
376 * cellBoundsPtr should be assigned to a double cellBounds[6] BEFORE calling this function.
377 */
378 void GetCellBounds(vtkIdType cellId, double*& cellBoundsPtr);
379
386 std::vector<double> Weights;
387
388private:
390 void operator=(const vtkAbstractCellLocator&) = delete;
391};
392
393VTK_ABI_NAMESPACE_END
394#endif
virtual int IntersectWithLine(const double p1[3], const double p2[3], vtkPoints *points, vtkIdList *cellIds)
Take the passed line segment and intersect it with the data set.
void UpdateInternalWeights()
To be called in FindCell(double[3]).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTimeStamp WeightsTime
This time stamp helps us decide if we want to update internal Weights array size.
virtual void ShallowCopy(vtkAbstractCellLocator *)
Shallow copy of a vtkAbstractCellLocator.
~vtkAbstractCellLocator() override
Find the cell containing a given point.
virtual void FindCellsAlongPlane(const double o[3], const double n[3], double tol, vtkIdList *cells)
Given an unbounded plane defined by an origin o[3] and unit normal n[3], return the list of unique ce...
vtkNew< vtkGenericCell > GenericCell
virtual bool StoreCellBounds()
This command is used internally by the locator to copy all cell Bounds into the internal CellBounds a...
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2)
Return the closest point within a specified radius and the cell which is closest to the point x.
void GetCellBounds(vtkIdType cellId, double *&cellBoundsPtr)
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *genCell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)
Find the cell containing a given point.
virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells)
Return a list of unique cell ids inside of a given bounding box.
vtkIdType FindCell(double x[3])
Returns the Id of the cell containing the point, returns -1 if no cell found.
virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkPoints *points, vtkIdList *cellIds)
Take the passed line segment and intersect it with the data set.
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 bool InsideCellBounds(double x[3], vtkIdType cell_ID, double tol=0.0)
Quickly test if a point is inside the bounds of a particular cell.
virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkPoints *points, vtkIdList *cellIds, vtkGenericCell *cell)
Take the passed line segment and intersect it with the data set.
virtual void FreeCellBounds()
Find the cell containing a given point.
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2, int &inside)
Return the closest point within a specified radius and the cell which is closest to the point x.
std::vector< double > Weights
This array is resized so that it can fit points from the cell hosting the most in the input data set.
static bool IsInBounds(const double bounds[6], const double x[3], double tol=0.0)
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.
void FindCellsAlongLine(const double p1[3], const double p2[3], double tol, vtkIdList *cells)
Take the passed line segment and intersect it with the data set.
void ComputeCellBounds()
This function can be used either internally or externally to compute only the cached cell bounds if C...
std::shared_ptr< std::vector< double > > CellBoundsSharedPtr
virtual vtkIdType FindCell(double x[3], double tol2, vtkGenericCell *genCell, int &subId, double pcoords[3], double *weights)
Find the cell containing a given point.
vtkIdType FindCell(double x[3], double tol2)
Returns the Id of the cell containing the point within provided squared tolerance,...
vtkIdType FindCell(double x[3], double tol2, vtkGenericCell *genCell, double pcoords[3], double *weights)
Find the cell containing a given point.
virtual void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2)
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, vtkIdType &cellId)
Return intersection point (if any) AND the cell which was intersected by the finite line.
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.
vtkAbstractCellLocator()
Find the cell containing a given point.
virtual 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)
Return intersection point (if any) AND the cell which was intersected by the finite line.
object to represent cell connectivity
abstract class to specify cell behavior
Definition vtkCell.h:130
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:135
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:168
represent and manipulate 3D points
Definition vtkPoints.h:140
record modification and/or execution time
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:363
#define VTK_INT_MAX
Definition vtkType.h:192