VTK  9.2.6
vtkCellLocator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCellLocator.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 =========================================================================*/
48 #ifndef vtkCellLocator_h
49 #define vtkCellLocator_h
50 
51 #include "vtkAbstractCellLocator.h"
52 #include "vtkCommonDataModelModule.h" // For export macro
53 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
54 #include "vtkNew.h" // For vtkNew
55 
56 class vtkIntArray;
57 
58 class VTKCOMMONDATAMODEL_EXPORT vtkCellLocator : public vtkAbstractCellLocator
59 {
60 public:
62 
66  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
73  static vtkCellLocator* New();
74 
80 
81  // Re-use any superclass signatures that we don't override.
86 
93  int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
94  double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) override;
95 
105  int IntersectWithLine(const double p1[3], const double p2[3], const double tol, vtkPoints* points,
106  vtkIdList* cellIds, vtkGenericCell* cell) override;
107 
117  void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell* cell,
118  vtkIdType& cellId, int& subId, double& dist2) override
119  {
120  this->Superclass::FindClosestPoint(x, closestPoint, cell, cellId, subId, dist2);
121  }
122 
135  vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3],
136  vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2, int& inside) override;
137 
145  vtkIdType FindCell(double x[3], double vtkNotUsed(tol2), vtkGenericCell* GenCell, int& subId,
146  double pcoords[3], double* weights) override;
147 
152  void FindCellsWithinBounds(double* bbox, vtkIdList* cells) override;
153 
163  const double p1[3], const double p2[3], double tolerance, vtkIdList* cellsIds) override
164  {
165  this->Superclass::FindCellsAlongLine(p1, p2, tolerance, cellsIds);
166  }
167 
169 
172  void FreeSearchStructure() override;
173  void BuildLocator() override;
174  void ForceBuildLocator() override;
175  void GenerateRepresentation(int level, vtkPolyData* pd) override;
177 
178  VTK_DEPRECATED_IN_9_2_0("This method is deprecated because LazyEvaluation has been deprecated")
179  virtual void BuildLocatorIfNeeded() {}
180 
184  virtual vtkIdList* GetCells(int bucket);
185 
190  virtual int GetNumberOfBuckets(void);
191 
195  void ShallowCopy(vtkAbstractCellLocator* locator) override;
196 
197 protected:
198  vtkCellLocator();
199  ~vtkCellLocator() override;
200 
201  void BuildLocatorInternal() override;
202 
203  //------------------------------------------------------------------------------
205  {
206  public:
207  vtkNeighborCells(int size);
208 
209  inline int GetNumberOfNeighbors();
210 
211  inline void Reset();
212 
213  inline int* GetPoint(int i);
214 
215  inline int InsertNextPoint(int* x);
216 
217  protected:
219  };
220 
221  void GetOverlappingBuckets(vtkNeighborCells& buckets, const double x[3], double dist,
222  int prevMinLevel[3], int prevMaxLevel[3]);
223 
224  inline void GetBucketIndices(const double x[3], int ijk[3]);
225 
226  double Distance2ToBucket(const double x[3], int nei[3]);
227  double Distance2ToBounds(const double x[3], double bounds[6]);
228 
229  int NumberOfOctants; // number of octants in tree
230  double Bounds[6]; // bounding box root octant
231  double H[3]; // width of leaf octant in x-y-z directions
232  int NumberOfDivisions; // number of "leaf" octant sub-divisions
233  std::shared_ptr<std::vector<vtkSmartPointer<vtkIdList>>> TreeSharedPtr;
235 
236  void MarkParents(const vtkSmartPointer<vtkIdList>&, int, int, int, int, int);
237  int GenerateIndex(int offset, int numDivs, int i, int j, int k, vtkIdType& idx);
238  void GenerateFace(
239  int face, int numDivs, int i, int j, int k, vtkPoints* pts, vtkCellArray* polys);
240  void ComputeOctantBounds(double octantBounds[6], int i, int j, int k);
241 
242 private:
243  vtkCellLocator(const vtkCellLocator&) = delete;
244  void operator=(const vtkCellLocator&) = delete;
245 };
246 
247 #endif
virtual void BuildLocator()=0
Build the locator from the input dataset.
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
Return the closest point within a specified radius and the cell which is closest to the point x...
virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells)
Return a list of unique cell ids inside of a given bounding box.
void FindCellsAlongLine(const double p1[3], const double p2[3], double tolerance, vtkIdList *cellsIds) override
Take the passed line segment and intersect it with the data set.
#define VTK_DEPRECATED_IN_9_2_0(reason)
virtual void SetNumberOfCellsPerNode(int)
Specify the preferred/maximum number of cells in each node/bucket.
an abstract base class for locators which find cells
vtkSmartPointer< vtkIdList > * Tree
std::shared_ptr< std::vector< vtkSmartPointer< vtkIdList > > > TreeSharedPtr
int GetNumberOfCellsPerBucket()
void SetNumberOfCellsPerBucket(int N)
Specify the average number of cells in each octant.
int vtkIdType
Definition: vtkType.h:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
virtual void FreeSearchStructure()=0
Free the memory required for the spatial data structure.
provides thread-safe access to cells
void GetPoint(const int i, const int j, const int k, double pnt[3])
virtual void FindClosestPoint(const double x[3], double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
Return the closest point and the cell which is closest to the point x.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
virtual void ShallowCopy(vtkAbstractCellLocator *)
Shallow copy of a vtkAbstractCellLocator.
octree-based spatial search object to quickly locate cells
void FindClosestPoint(const double x[3], double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2) override
Return the closest point and the cell which is closest to the point x.
virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
Return intersection point (if any) of finite line with cells contained in cell locator.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void BuildLocatorInternal()
This function is not pure virtual to maintain backwards compatibility.
Definition: vtkLocator.h:203
virtual vtkIdType FindCell(double x[3])
Returns the Id of the cell containing the point, returns -1 if no cell found.
list of point or cell ids
Definition: vtkIdList.h:33
object to represent cell connectivity
Definition: vtkCellArray.h:186
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
Method to build a representation at a particular level.
represent and manipulate 3D points
Definition: vtkPoints.h:39
virtual void ForceBuildLocator()
Build the locator from the input dataset (even if UseExistingSearchStructure is on).
Definition: vtkLocator.h:167
vtkNew< vtkIntArray > Points