VTK  9.7.1
vtkClosestPointStrategy.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
20 #ifndef vtkClosestPointStrategy_h
21 #define vtkClosestPointStrategy_h
22 
23 #include "vtkCell.h" //inline SelectCell
24 #include "vtkCommonDataModelModule.h" // For export macro
25 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
26 #include "vtkFindCellStrategy.h"
27 #include "vtkGenericCell.h" //inline SelectCell
28 #include "vtkPointSet.h" //inline SelectCell
29 
30 #include <vector> // For tracking visited cells
31 
32 VTK_ABI_NAMESPACE_BEGIN
33 class vtkIdList;
35 
37  "Use vtkJumpAndWalkCellLocator instead") VTKCOMMONDATAMODEL_EXPORT vtkClosestPointStrategy
38  : public vtkFindCellStrategy
39 {
40 public:
44  static vtkClosestPointStrategy* New();
45 
47 
51  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
60 
67  int Initialize(vtkPointSet* ps) override;
68 
73  vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
74  double tol2, int& subId, double pcoords[3], double* weights) override;
75 
80  vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
81  vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside) override;
82 
86  bool InsideCellBounds(double x[3], vtkIdType cellId) override;
87 
89 
95  virtual void SetPointLocator(vtkAbstractPointLocator*);
96  vtkGetObjectMacro(PointLocator, vtkAbstractPointLocator);
98 
102  vtkCell* SelectCell(vtkPointSet* self, vtkIdType cellId, vtkCell* cell, vtkGenericCell* gencell);
103 
110  void CopyParameters(vtkFindCellStrategy* from) override;
111 
112 protected:
114  ~vtkClosestPointStrategy() override;
115 
116  std::vector<unsigned char> VisitedCells; // boolean array to track visited cells
117  vtkNew<vtkIdList> VisitedCellIds; // list of visited cell ids to reset boolean array
122  std::vector<double> Weights;
123 
125 
126 private:
128  void operator=(const vtkClosestPointStrategy&) = delete;
129 };
130 
131 // Handle cases where starting cell is provided or not
133  vtkPointSet* self, vtkIdType cellId, vtkCell* cell, vtkGenericCell* gencell)
134 {
135  if (!cell)
136  {
137  if (gencell)
138  {
139  self->GetCell(cellId, gencell);
140  cell = gencell;
141  }
142  else
143  {
144  cell = self->GetCell(cellId);
145  }
146  }
147  return cell;
148 }
149 
150 VTK_ABI_NAMESPACE_END
151 #endif
point locator adaptor to perform cell Location using the jump and walk approach
vtkNew< vtkIdList > NearPointIds
virtual bool InsideCellBounds(double x[3], vtkIdType cellId)=0
Quickly test if a point is inside the bounds of a particular cell.
virtual vtkSmartPointer< vtkAbstractCellLocator > ConvertToCellLocator()=0
Convert FindCellStrategy to cellLocator.
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2, int &inside)=0
Return the closest point within a specified radius and the cell which is closest to the point x...
vtkNew< vtkIdList > VisitedCellIds
virtual void CopyParameters(vtkFindCellStrategy *from)
Copy essential parameters between instances of this class.
implement a specific vtkPointSet::FindCell() strategy based on closest point
concrete class for storing a set of points
Definition: vtkPointSet.h:58
virtual int Initialize(vtkPointSet *ps)
All subclasses of this class must provide an initialize method.
int vtkIdType
Definition: vtkType.h:363
vtkCell * SelectCell(vtkPointSet *self, vtkIdType cellId, vtkCell *cell, vtkGenericCell *gencell)
Subclasses use this method to select the current cell.
provides thread-safe access to cells
helper class to manage the vtkPointSet::FindCell() method
abstract class to specify cell behavior
Definition: vtkCell.h:50
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:25
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
Virtual method for finding a cell.
std::vector< unsigned char > VisitedCells
vtkAbstractPointLocator * PointLocator
std::vector< double > Weights
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
#define VTK_DEPRECATED_IN_9_7_0(reason)