VTK  9.3.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 "vtkFindCellStrategy.h"
26 #include "vtkGenericCell.h" //inline SelectCell
27 #include "vtkPointSet.h" //inline SelectCell
28 
29 #include <vector> // For tracking visited cells
30 
31 VTK_ABI_NAMESPACE_BEGIN
32 class vtkIdList;
34 
35 class VTKCOMMONDATAMODEL_EXPORT vtkClosestPointStrategy : public vtkFindCellStrategy
36 {
37 public:
41  static vtkClosestPointStrategy* New();
42 
44 
48  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
57  int Initialize(vtkPointSet* ps) override;
58 
63  vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
64  double tol2, int& subId, double pcoords[3], double* weights) override;
65 
70  vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
71  vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside) override;
72 
76  bool InsideCellBounds(double x[3], vtkIdType cellId) override;
77 
79 
85  virtual void SetPointLocator(vtkAbstractPointLocator*);
86  vtkGetObjectMacro(PointLocator, vtkAbstractPointLocator);
88 
92  vtkCell* SelectCell(vtkPointSet* self, vtkIdType cellId, vtkCell* cell, vtkGenericCell* gencell);
93 
100  void CopyParameters(vtkFindCellStrategy* from) override;
101 
102 protected:
104  ~vtkClosestPointStrategy() override;
105 
106  std::vector<unsigned char> VisitedCells; // boolean array to track visited cells
107  vtkNew<vtkIdList> VisitedCellIds; // list of visited cell ids to reset boolean array
112  std::vector<double> Weights;
113 
115 
116 private:
118  void operator=(const vtkClosestPointStrategy&) = delete;
119 };
120 
121 // Handle cases where starting cell is provided or not
123  vtkPointSet* self, vtkIdType cellId, vtkCell* cell, vtkGenericCell* gencell)
124 {
125  if (!cell)
126  {
127  if (gencell)
128  {
129  self->GetCell(cellId, gencell);
130  cell = gencell;
131  }
132  else
133  {
134  cell = self->GetCell(cellId);
135  }
136  }
137  return cell;
138 }
139 
140 VTK_ABI_NAMESPACE_END
141 #endif
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 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:315
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:49
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:22
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...