VTK  9.4.20250303
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
31VTK_ABI_NAMESPACE_BEGIN
32class vtkIdList;
34
35class VTKCOMMONDATAMODEL_EXPORT vtkClosestPointStrategy : public vtkFindCellStrategy
36{
37public:
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
86 vtkGetObjectMacro(PointLocator, vtkAbstractPointLocator);
88
92 vtkCell* SelectCell(vtkPointSet* self, vtkIdType cellId, vtkCell* cell, vtkGenericCell* gencell);
93
101
102protected:
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
116private:
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
140VTK_ABI_NAMESPACE_END
141#endif
abstract class to quickly locate points in 3-space
abstract class to specify cell behavior
Definition vtkCell.h:130
implement a specific vtkPointSet::FindCell() strategy based on closest point
vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Implement the specific strategy.
vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2, int &inside) override
Implement the specific strategy.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
static vtkClosestPointStrategy * New()
Construct a vtkFindCellStrategy subclass.
int Initialize(vtkPointSet *ps) override
Provide the necessary initialization method (see superclass for more information).
void CopyParameters(vtkFindCellStrategy *from) override
Copy essential parameters between instances of this class.
vtkCell * SelectCell(vtkPointSet *self, vtkIdType cellId, vtkCell *cell, vtkGenericCell *gencell)
Subclasses use this method to select the current cell.
~vtkClosestPointStrategy() override
virtual void SetPointLocator(vtkAbstractPointLocator *)
Set / get an instance of vtkAbstractPointLocator which is used to implement the strategy for FindCell...
vtkAbstractPointLocator * PointLocator
std::vector< unsigned char > VisitedCells
bool InsideCellBounds(double x[3], vtkIdType cellId) override
Implement the specific strategy.
helper class to manage the vtkPointSet::FindCell() method
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
concrete class for storing a set of points
Definition vtkPointSet.h:98
vtkCell * GetCell(vtkIdType) override
This method always return a vtkEmptyCell, as there is no cell in a vtkPointSet.
int vtkIdType
Definition vtkType.h:332