VTK  9.6.20260527
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
19
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
32VTK_ABI_NAMESPACE_BEGIN
33class vtkIdList;
35
37 "Use vtkJumpAndWalkCellLocator instead") VTKCOMMONDATAMODEL_EXPORT vtkClosestPointStrategy
38 : public vtkFindCellStrategy
39{
40public:
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
98
102 vtkCell* SelectCell(vtkPointSet* self, vtkIdType cellId, vtkCell* cell, vtkGenericCell* gencell);
103
111
112protected:
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
126private:
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
150VTK_ABI_NAMESPACE_END
151#endif
abstract class to quickly locate points in 3-space
abstract class to specify cell behavior
Definition vtkCell.h:130
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.
vtkSmartPointer< vtkAbstractCellLocator > ConvertToCellLocator() override
Convert FindCellStrategy to cellLocator.
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.
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:135
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:168
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.
Hold a reference to a vtkObjectBase instance.
#define VTK_DEPRECATED_IN_9_7_0(reason)
int vtkIdType
Definition vtkType.h:363