VTK  9.2.6
vtkAbstractCellLocator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAbstractCellLocator.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
40 #ifndef vtkAbstractCellLocator_h
41 #define vtkAbstractCellLocator_h
42 
43 #include "vtkCommonDataModelModule.h" // For export macro
44 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
45 #include "vtkLocator.h"
46 #include "vtkNew.h" // For vtkNew
47 
48 #include <memory> // For shared_ptr
49 #include <vector> // For Weights
50 
51 class vtkCellArray;
52 class vtkGenericCell;
53 class vtkIdList;
54 class vtkPoints;
55 
56 class VTKCOMMONDATAMODEL_EXPORT vtkAbstractCellLocator : public vtkLocator
57 {
58 public:
60  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
63 
69  vtkSetClampMacro(NumberOfCellsPerNode, int, 1, VTK_INT_MAX);
70  vtkGetMacro(NumberOfCellsPerNode, int);
72 
74 
81  vtkSetMacro(CacheCellBounds, vtkTypeBool);
82  vtkGetMacro(CacheCellBounds, vtkTypeBool);
83  vtkBooleanMacro(CacheCellBounds, vtkTypeBool);
85 
90  void ComputeCellBounds();
91 
93 
98  vtkSetMacro(RetainCellLists, vtkTypeBool);
99  vtkGetMacro(RetainCellLists, vtkTypeBool);
100  vtkBooleanMacro(RetainCellLists, vtkTypeBool);
102 
104 
110  VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
111  virtual void SetLazyEvaluation(vtkTypeBool) {}
112  VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
113  virtual vtkTypeBool GetLazyEvaluation() { return 0; }
114  VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
115  virtual void LazyEvaluationOn() {}
116  VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
117  virtual void LazyEvaluationOff() {}
119 
126  virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
127  double x[3], double pcoords[3], int& subId);
128 
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);
137 
146  virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
147  double x[3], double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell);
148 
164  virtual int IntersectWithLine(
165  const double p1[3], const double p2[3], vtkPoints* points, vtkIdList* cellIds);
166 
176  virtual int IntersectWithLine(const double p1[3], const double p2[3], const double tol,
177  vtkPoints* points, vtkIdList* cellIds);
178 
190  virtual int IntersectWithLine(const double p1[3], const double p2[3], const double tol,
191  vtkPoints* points, vtkIdList* cellIds, vtkGenericCell* cell);
192 
203  virtual void FindClosestPoint(
204  const double x[3], double closestPoint[3], vtkIdType& cellId, int& subId, double& dist2);
205 
218  virtual void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell* cell,
219  vtkIdType& cellId, int& subId, double& dist2);
220 
231  virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
232  vtkIdType& cellId, int& subId, double& dist2);
233 
246  virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
247  vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2);
248 
263  virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
264  vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside);
265 
272  virtual void FindCellsWithinBounds(double* bbox, vtkIdList* cells);
273 
285  virtual void FindCellsAlongLine(
286  const double p1[3], const double p2[3], double tolerance, vtkIdList* cells);
287 
297  virtual void FindCellsAlongPlane(
298  const double o[3], const double n[3], double tolerance, vtkIdList* cells);
299 
306  virtual vtkIdType FindCell(double x[3]);
307 
309 
316  virtual vtkIdType FindCell(
317  double x[3], double tol2, vtkGenericCell* GenCell, double pcoords[3], double* weights);
318  virtual vtkIdType FindCell(double x[3], double tol2, vtkGenericCell* GenCell, int& subId,
319  double pcoords[3], double* weights);
321 
327  virtual bool InsideCellBounds(double x[3], vtkIdType cell_ID);
328 
333 
334 protected:
336  ~vtkAbstractCellLocator() override;
337 
339 
346  virtual bool StoreCellBounds();
347  virtual void FreeCellBounds();
349 
354  void UpdateInternalWeights();
355 
360  std::shared_ptr<std::vector<double>> CellBoundsSharedPtr;
361  double* CellBounds; // The is just used for simplicity in the internal code
362 
367 
368  static bool IsInBounds(const double bounds[6], const double x[3], const double tol = 0.0);
369 
370  /*
371  * This function should be used ONLY after the locator is built.
372  * cellBoundsPtr should be assigned to a double cellBounds[6] BEFORE calling this function.
373  */
374  void GetCellBounds(vtkIdType cellId, double*& cellBoundsPtr);
375 
382  std::vector<double> Weights;
383 
384 private:
386  void operator=(const vtkAbstractCellLocator&) = delete;
387 };
388 
389 #endif
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_INT_MAX
Definition: vtkType.h:155
record modification and/or execution time
Definition: vtkTimeStamp.h:35
an abstract base class for locators which find cells
abstract base class for objects that accelerate spatial searches
Definition: vtkLocator.h:69
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:332
std::shared_ptr< std::vector< double > > CellBoundsSharedPtr
provides thread-safe access to cells
int vtkTypeBool
Definition: vtkABI.h:69
virtual void ShallowCopy(vtkAbstractCellLocator *)
Shallow copy of a vtkAbstractCellLocator.
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkNew< vtkGenericCell > GenericCell
list of point or cell ids
Definition: vtkIdList.h:33
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:186
represent and manipulate 3D points
Definition: vtkPoints.h:39