VTK  9.3.0
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
28#ifndef vtkAbstractCellLocator_h
29#define vtkAbstractCellLocator_h
30
31#include "vtkCommonDataModelModule.h" // For export macro
32#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
33#include "vtkLocator.h"
34#include "vtkNew.h" // For vtkNew
35
36#include <memory> // For shared_ptr
37#include <vector> // For Weights
38
39VTK_ABI_NAMESPACE_BEGIN
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
70 vtkSetMacro(CacheCellBounds, vtkTypeBool);
71 vtkGetMacro(CacheCellBounds, vtkTypeBool);
72 vtkBooleanMacro(CacheCellBounds, vtkTypeBool);
74
80
82
87 vtkSetMacro(RetainCellLists, vtkTypeBool);
88 vtkGetMacro(RetainCellLists, vtkTypeBool);
89 vtkBooleanMacro(RetainCellLists, vtkTypeBool);
91
93
99 VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
100 virtual void SetLazyEvaluation(vtkTypeBool) {}
101 VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
102 virtual vtkTypeBool GetLazyEvaluation() { return 0; }
103 VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
104 virtual void LazyEvaluationOn() {}
105 VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
106 virtual void LazyEvaluationOff() {}
108
115 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
116 double x[3], double pcoords[3], int& subId);
117
124 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
125 double x[3], double pcoords[3], int& subId, vtkIdType& cellId);
126
135 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
136 double x[3], double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell);
137
153 virtual int IntersectWithLine(
154 const double p1[3], const double p2[3], vtkPoints* points, vtkIdList* cellIds);
155
165 virtual int IntersectWithLine(
166 const double p1[3], const double p2[3], double tol, vtkPoints* points, vtkIdList* cellIds);
167
179 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol,
180 vtkPoints* points, vtkIdList* cellIds, vtkGenericCell* cell);
181
192 virtual void FindClosestPoint(
193 const double x[3], double closestPoint[3], vtkIdType& cellId, int& subId, double& dist2);
194
207 virtual void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell* cell,
208 vtkIdType& cellId, int& subId, double& dist2);
209
220 virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
221 vtkIdType& cellId, int& subId, double& dist2);
222
235 virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
236 vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2);
237
252 virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
253 vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside);
254
261 virtual void FindCellsWithinBounds(double* bbox, vtkIdList* cells);
262
274 virtual void FindCellsAlongLine(
275 const double p1[3], const double p2[3], double tolerance, vtkIdList* cells);
276
287 const double o[3], const double n[3], double tolerance, vtkIdList* cells);
288
295 virtual vtkIdType FindCell(double x[3]);
296
298
306 double x[3], double tol2, vtkGenericCell* GenCell, double pcoords[3], double* weights);
307 virtual vtkIdType FindCell(double x[3], double tol2, vtkGenericCell* GenCell, int& subId,
308 double pcoords[3], double* weights);
310
316 virtual bool InsideCellBounds(double x[3], vtkIdType cell_ID);
317
322
323protected:
326
328
335 virtual bool StoreCellBounds();
336 virtual void FreeCellBounds();
338
344
349 std::shared_ptr<std::vector<double>> CellBoundsSharedPtr;
350 double* CellBounds; // The is just used for simplicity in the internal code
351
356
357 static bool IsInBounds(const double bounds[6], const double x[3], double tol = 0.0);
358
359 /*
360 * This function should be used ONLY after the locator is built.
361 * cellBoundsPtr should be assigned to a double cellBounds[6] BEFORE calling this function.
362 */
363 void GetCellBounds(vtkIdType cellId, double*& cellBoundsPtr);
364
371 std::vector<double> Weights;
372
373private:
375 void operator=(const vtkAbstractCellLocator&) = delete;
376};
377
378VTK_ABI_NAMESPACE_END
379#endif
an abstract base class for locators which find cells
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.
virtual vtkIdType FindCell(double x[3])
Returns the Id of the cell containing the point, returns -1 if no cell found.
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.
virtual void FindCellsAlongPlane(const double o[3], const double n[3], double tolerance, vtkIdList *cells)
Given an unbounded plane defined by an origin o[3] and unit normal n[3], return the list of unique ce...
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
vtkNew< vtkGenericCell > GenericCell
virtual vtkIdType FindCell(double x[3], double tol2, vtkGenericCell *GenCell, double pcoords[3], double *weights)
Find the cell containing a given point.
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 void FindCellsWithinBounds(double *bbox, vtkIdList *cells)
Return a list of unique cell ids inside of a given bounding box.
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 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 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 void FreeCellBounds()
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, 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 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 bool InsideCellBounds(double x[3], vtkIdType cell_ID)
Quickly test if a point is inside the bounds of a particular cell.
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 vtkIdType FindCell(double x[3], double tol2, vtkGenericCell *GenCell, int &subId, double pcoords[3], double *weights)
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)
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.
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
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:23
a simple class to control print indentation
Definition vtkIndent.h:29
abstract base class for objects that accelerate spatial searches
Definition vtkLocator.h:59
Allocate and hold a VTK object.
Definition vtkNew.h:51
represent and manipulate 3D points
Definition vtkPoints.h:29
record modification and/or execution time
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_2_0(reason)
int vtkIdType
Definition vtkType.h:315
#define VTK_INT_MAX
Definition vtkType.h:144