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
51class vtkCellArray;
52class vtkGenericCell;
53class vtkIdList;
54class vtkPoints;
55
56class VTKCOMMONDATAMODEL_EXPORT vtkAbstractCellLocator : public vtkLocator
57{
58public:
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
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
298 const double o[3], const double n[3], double tolerance, vtkIdList* cells);
299
306 virtual vtkIdType FindCell(double x[3]);
307
309
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
334protected:
337
339
346 virtual bool StoreCellBounds();
347 virtual void FreeCellBounds();
349
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
384private:
386 void operator=(const vtkAbstractCellLocator&) = delete;
387};
388
389#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
Definition: vtkCellArray.h:187
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:34
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for objects that accelerate spatial searches
Definition: vtkLocator.h:70
Allocate and hold a VTK object.
Definition: vtkNew.h:62
represent and manipulate 3D points
Definition: vtkPoints.h:40
record modification and/or execution time
Definition: vtkTimeStamp.h:36
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