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=========================================================================*/
37#ifndef vtkAbstractCellLocator_h
38#define vtkAbstractCellLocator_h
39
40#include "vtkCommonDataModelModule.h" // For export macro
41#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
42#include "vtkLocator.h"
43#include "vtkNew.h" // For vtkNew
44
45#include <memory> // For shared_ptr
46#include <vector> // For Weights
47
48class vtkCellArray;
49class vtkGenericCell;
50class vtkIdList;
51class vtkPoints;
52
53class VTKCOMMONDATAMODEL_EXPORT vtkAbstractCellLocator : public vtkLocator
54{
55public:
57 void PrintSelf(ostream& os, vtkIndent indent) override;
58
60
66 vtkSetClampMacro(NumberOfCellsPerNode, int, 1, VTK_INT_MAX);
67 vtkGetMacro(NumberOfCellsPerNode, int);
69
71
78 vtkSetMacro(CacheCellBounds, vtkTypeBool);
79 vtkGetMacro(CacheCellBounds, vtkTypeBool);
80 vtkBooleanMacro(CacheCellBounds, vtkTypeBool);
82
88
90
95 vtkSetMacro(RetainCellLists, vtkTypeBool);
96 vtkGetMacro(RetainCellLists, vtkTypeBool);
97 vtkBooleanMacro(RetainCellLists, vtkTypeBool);
99
101
107 VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
108 virtual void SetLazyEvaluation(vtkTypeBool) {}
109 VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
110 virtual vtkTypeBool GetLazyEvaluation() { return 0; }
111 VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
112 virtual void LazyEvaluationOn() {}
113 VTK_DEPRECATED_IN_9_2_0("This method is deprecated because it can lead to thread-safety issues")
114 virtual void LazyEvaluationOff() {}
116
123 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
124 double x[3], double pcoords[3], int& subId);
125
132 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
133 double x[3], double pcoords[3], int& subId, vtkIdType& cellId);
134
143 virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
144 double x[3], double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell);
145
161 virtual int IntersectWithLine(
162 const double p1[3], const double p2[3], vtkPoints* points, vtkIdList* cellIds);
163
173 virtual int IntersectWithLine(const double p1[3], const double p2[3], const double tol,
174 vtkPoints* points, vtkIdList* cellIds);
175
187 virtual int IntersectWithLine(const double p1[3], const double p2[3], const double tol,
188 vtkPoints* points, vtkIdList* cellIds, vtkGenericCell* cell);
189
200 virtual void FindClosestPoint(
201 const double x[3], double closestPoint[3], vtkIdType& cellId, int& subId, double& dist2);
202
215 virtual void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell* cell,
216 vtkIdType& cellId, int& subId, double& dist2);
217
228 virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
229 vtkIdType& cellId, int& subId, double& dist2);
230
243 virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
244 vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2);
245
260 virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
261 vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside);
262
269 virtual void FindCellsWithinBounds(double* bbox, vtkIdList* cells);
270
282 virtual void FindCellsAlongLine(
283 const double p1[3], const double p2[3], double tolerance, vtkIdList* cells);
284
295 const double o[3], const double n[3], double tolerance, vtkIdList* cells);
296
303 virtual vtkIdType FindCell(double x[3]);
304
306
314 double x[3], double tol2, vtkGenericCell* GenCell, double pcoords[3], double* weights);
315 virtual vtkIdType FindCell(double x[3], double tol2, vtkGenericCell* GenCell, int& subId,
316 double pcoords[3], double* weights);
318
324 virtual bool InsideCellBounds(double x[3], vtkIdType cell_ID);
325
330
331protected:
334
336
343 virtual bool StoreCellBounds();
344 virtual void FreeCellBounds();
346
352
357 std::shared_ptr<std::vector<double>> CellBoundsSharedPtr;
358 double* CellBounds; // The is just used for simplicity in the internal code
359
364
365 static bool IsInBounds(const double bounds[6], const double x[3], const double tol = 0.0);
366
367 /*
368 * This function should be used ONLY after the locator is built.
369 * cellBoundsPtr should be assigned to a double cellBounds[6] BEFORE calling this function.
370 */
371 void GetCellBounds(vtkIdType cellId, double*& cellBoundsPtr);
372
379 std::vector<double> Weights;
380
381private:
383 void operator=(const vtkAbstractCellLocator&) = delete;
384};
385
386#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...
static bool IsInBounds(const double bounds[6], const double x[3], const double tol=0.0)
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 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 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.
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], const double tol, vtkPoints *points, vtkIdList *cellIds, vtkGenericCell *cell)
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 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], const double tol, vtkPoints *points, vtkIdList *cellIds)
Take the passed line segment and intersect it with the data set.
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:31
a simple class to control print indentation
Definition vtkIndent.h:34
abstract base class for objects that accelerate spatial searches
Definition vtkLocator.h:70
Allocate and hold a VTK object.
Definition vtkNew.h:56
represent and manipulate 3D points
Definition vtkPoints.h:34
record modification and/or execution time
int vtkTypeBool
Definition vtkABI.h:69
#define VTK_DEPRECATED_IN_9_2_0(reason)
int vtkIdType
Definition vtkType.h:332
#define VTK_INT_MAX
Definition vtkType.h:155