VTK  9.2.6
vtkClosestPointStrategy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkClosestPointStrategy.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 =========================================================================*/
32 #ifndef vtkClosestPointStrategy_h
33 #define vtkClosestPointStrategy_h
34 
35 #include "vtkCell.h" //inline SelectCell
36 #include "vtkCommonDataModelModule.h" // For export macro
37 #include "vtkFindCellStrategy.h"
38 #include "vtkGenericCell.h" //inline SelectCell
39 #include "vtkPointSet.h" //inline SelectCell
40 
41 #include <vector> // For tracking visited cells
42 
43 class vtkIdList;
45 
46 class VTKCOMMONDATAMODEL_EXPORT vtkClosestPointStrategy : public vtkFindCellStrategy
47 {
48 public:
52  static vtkClosestPointStrategy* New();
53 
55 
59  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
68  int Initialize(vtkPointSet* ps) override;
69 
74  vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
75  double tol2, int& subId, double pcoords[3], double* weights) override;
76 
81  vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
82  vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside) override;
83 
87  bool InsideCellBounds(double x[3], vtkIdType cellId) override;
88 
90 
96  virtual void SetPointLocator(vtkAbstractPointLocator*);
97  vtkGetObjectMacro(PointLocator, vtkAbstractPointLocator);
99 
103  vtkCell* SelectCell(vtkPointSet* self, vtkIdType cellId, vtkCell* cell, vtkGenericCell* gencell);
104 
111  void CopyParameters(vtkFindCellStrategy* from) override;
112 
113 protected:
115  ~vtkClosestPointStrategy() override;
116 
117  std::vector<unsigned char> VisitedCells; // boolean array to track visited cells
118  vtkNew<vtkIdList> VisitedCellIds; // list of visited cell ids to reset boolean array
123  std::vector<double> Weights;
124 
126 
127 private:
129  void operator=(const vtkClosestPointStrategy&) = delete;
130 };
131 
132 // Handle cases where starting cell is provided or not
134  vtkPointSet* self, vtkIdType cellId, vtkCell* cell, vtkGenericCell* gencell)
135 {
136  if (!cell)
137  {
138  if (gencell)
139  {
140  self->GetCell(cellId, gencell);
141  cell = gencell;
142  }
143  else
144  {
145  cell = self->GetCell(cellId);
146  }
147  }
148  return cell;
149 }
150 
151 #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:69
virtual int Initialize(vtkPointSet *ps)
All subclasses of this class must provide an initialize method.
int vtkIdType
Definition: vtkType.h:332
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:60
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:33
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...