VTK  9.3.1
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 
39 VTK_ABI_NAMESPACE_BEGIN
40 class vtkCellArray;
41 class vtkGenericCell;
42 class vtkIdList;
43 class vtkPoints;
44 
45 class VTKCOMMONDATAMODEL_EXPORT vtkAbstractCellLocator : public vtkLocator
46 {
47 public:
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 
79  void ComputeCellBounds();
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 
286  virtual void FindCellsAlongPlane(
287  const double o[3], const double n[3], double tolerance, vtkIdList* cells);
288 
295  virtual vtkIdType FindCell(double x[3]);
296 
298 
305  virtual vtkIdType FindCell(
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 
323 protected:
325  ~vtkAbstractCellLocator() override;
326 
328 
335  virtual bool StoreCellBounds();
336  virtual void FreeCellBounds();
338 
343  void UpdateInternalWeights();
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 
373 private:
375  void operator=(const vtkAbstractCellLocator&) = delete;
376 };
377 
378 VTK_ABI_NAMESPACE_END
379 #endif
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_INT_MAX
Definition: vtkType.h:144
record modification and/or execution time
Definition: vtkTimeStamp.h:24
an abstract base class for locators which find cells
abstract base class for objects that accelerate spatial searches
Definition: vtkLocator.h:58
void PrintSelf(ostream &os, vtkIndent indent) override
Standard type and print methods.
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...
int vtkIdType
Definition: vtkType.h:315
std::shared_ptr< std::vector< double > > CellBoundsSharedPtr
provides thread-safe access to cells
int vtkTypeBool
Definition: vtkABI.h:64
virtual void ShallowCopy(vtkAbstractCellLocator *)
Shallow copy of a vtkAbstractCellLocator.
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkNew< vtkGenericCell > GenericCell
list of point or cell ids
Definition: vtkIdList.h:22
vtkTimeStamp WeightsTime
This time stamp helps us decide if we want to update internal Weights array size. ...
object to represent cell connectivity
Definition: vtkCellArray.h:175
represent and manipulate 3D points
Definition: vtkPoints.h:28