VTK  9.1.0
vtkPointLocator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPointLocator.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 =========================================================================*/
88 #ifndef vtkPointLocator_h
89 #define vtkPointLocator_h
90 
91 #include "vtkCommonDataModelModule.h" // For export macro
93 
94 class vtkCellArray;
95 class vtkIdList;
96 class vtkNeighborPoints;
97 class vtkPoints;
98 
99 class VTKCOMMONDATAMODEL_EXPORT vtkPointLocator : public vtkIncrementalPointLocator
100 {
101 public:
106  static vtkPointLocator* New();
107 
109 
113  void PrintSelf(ostream& os, vtkIndent indent) override;
115 
117 
120  vtkSetVector3Macro(Divisions, int);
121  vtkGetVectorMacro(Divisions, int, 3);
123 
125 
128  vtkSetClampMacro(NumberOfPointsPerBucket, int, 1, VTK_INT_MAX);
129  vtkGetMacro(NumberOfPointsPerBucket, int);
131 
132  // Re-use any superclass signatures that we don't override.
134 
141  vtkIdType FindClosestPoint(const double x[3]) override;
142 
144 
151  vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2) override;
153  double radius, const double x[3], double inputDataLength, double& dist2);
155 
162  int InitPointInsertion(vtkPoints* newPts, const double bounds[6]) override;
163 
170  int InitPointInsertion(vtkPoints* newPts, const double bounds[6], vtkIdType estNumPts) override;
171 
181  void InsertPoint(vtkIdType ptId, const double x[3]) override;
182 
193  vtkIdType InsertNextPoint(const double x[3]) override;
194 
196 
201  vtkIdType IsInsertedPoint(double x, double y, double z) override
202  {
203  double xyz[3];
204  xyz[0] = x;
205  xyz[1] = y;
206  xyz[2] = z;
207  return this->IsInsertedPoint(xyz);
208  };
209  vtkIdType IsInsertedPoint(const double x[3]) override;
211 
221  int InsertUniquePoint(const double x[3], vtkIdType& ptId) override;
222 
230  vtkIdType FindClosestInsertedPoint(const double x[3]) override;
231 
240  void FindClosestNPoints(int N, const double x[3], vtkIdList* result) override;
241 
243 
250  virtual void FindDistributedPoints(int N, const double x[3], vtkIdList* result, int M);
251  virtual void FindDistributedPoints(int N, double x, double y, double z, vtkIdList* result, int M);
253 
260  void FindPointsWithinRadius(double R, const double x[3], vtkIdList* result) override;
261 
268  virtual vtkIdList* GetPointsInBucket(const double x[3], int ijk[3]);
269 
271 
274  vtkGetObjectMacro(Points, vtkPoints);
276 
278 
282  void Initialize() override;
283  void FreeSearchStructure() override;
284  void BuildLocator() override;
285  void GenerateRepresentation(int level, vtkPolyData* pd) override;
287 
288 protected:
290  ~vtkPointLocator() override;
291 
292  // place points in appropriate buckets
294  vtkNeighborPoints* buckets, const int ijk[3], const int ndivs[3], int level);
296  vtkNeighborPoints* buckets, const double x[3], const int ijk[3], double dist, int level);
297  void GetOverlappingBuckets(vtkNeighborPoints* buckets, const double x[3], double dist,
298  int prevMinLevel[3], int prevMaxLevel[3]);
299  void GenerateFace(int face, int i, int j, int k, vtkPoints* pts, vtkCellArray* polys);
300  double Distance2ToBucket(const double x[3], const int nei[3]);
301  double Distance2ToBounds(const double x[3], const double bounds[6]);
302 
303  vtkPoints* Points; // Used for merging points
304  int Divisions[3]; // Number of sub-divisions in x-y-z directions
305  int NumberOfPointsPerBucket; // Used with previous boolean to control subdivide
306  vtkIdList** HashTable; // lists of point ids in buckets
307  double H[3]; // width of each bucket in x-y-z directions
308 
312 
313  // These are inlined methods and data members for performance reasons
314  double HX, HY, HZ;
315  double FX, FY, FZ, BX, BY, BZ;
316  vtkIdType XD, YD, ZD, SliceSize;
317 
318  void GetBucketIndices(const double* x, int ijk[3]) const
319  {
320  // Compute point index. Make sure it lies within range of locator.
321  vtkIdType tmp0 = static_cast<vtkIdType>(((x[0] - this->BX) * this->FX));
322  vtkIdType tmp1 = static_cast<vtkIdType>(((x[1] - this->BY) * this->FY));
323  vtkIdType tmp2 = static_cast<vtkIdType>(((x[2] - this->BZ) * this->FZ));
324 
325  ijk[0] = tmp0 < 0 ? 0 : (tmp0 >= this->XD ? this->XD - 1 : tmp0);
326  ijk[1] = tmp1 < 0 ? 0 : (tmp1 >= this->YD ? this->YD - 1 : tmp1);
327  ijk[2] = tmp2 < 0 ? 0 : (tmp2 >= this->ZD ? this->ZD - 1 : tmp2);
328  }
329 
330  vtkIdType GetBucketIndex(const double* x) const
331  {
332  int ijk[3];
333  this->GetBucketIndices(x, ijk);
334  return ijk[0] + ijk[1] * this->XD + ijk[2] * this->SliceSize;
335  }
336 
338 
339 private:
340  vtkPointLocator(const vtkPointLocator&) = delete;
341  void operator=(const vtkPointLocator&) = delete;
342 };
343 
344 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkPointLocator::InsertionPointId
vtkIdType InsertionPointId
Definition: vtkPointLocator.h:310
vtkPointLocator::InsertPoint
void InsertPoint(vtkIdType ptId, const double x[3]) override
Incrementally insert a point into search structure with a particular index value.
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkIncrementalPointLocator::IsInsertedPoint
virtual vtkIdType IsInsertedPoint(double x, double y, double z)=0
Determine whether or not a given point has been inserted.
vtkPointLocator::GenerateFace
void GenerateFace(int face, int i, int j, int k, vtkPoints *pts, vtkCellArray *polys)
vtkPointLocator::GetBucketIndex
vtkIdType GetBucketIndex(const double *x) const
Definition: vtkPointLocator.h:330
vtkPointLocator::InitPointInsertion
int InitPointInsertion(vtkPoints *newPts, const double bounds[6]) override
Initialize the point insertion process.
vtkPointLocator::HashTable
vtkIdList ** HashTable
Definition: vtkPointLocator.h:306
vtkPointLocator::InsertionLevel
double InsertionLevel
Definition: vtkPointLocator.h:311
vtkPointLocator::FZ
double FZ
Definition: vtkPointLocator.h:315
vtkPointLocator::FindClosestPointWithinRadius
vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double &dist2) override
Given a position x and a radius r, return the id of the point closest to the point in that radius.
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkPointLocator::BuildLocator
void BuildLocator() override
See vtkLocator interface documentation.
vtkPointLocator
quickly locate points in 3-space
Definition: vtkPointLocator.h:100
vtkPointLocator::FindDistributedPoints
virtual void FindDistributedPoints(int N, double x, double y, double z, vtkIdList *result, int M)
Find the closest points to a position such that each octant of space around the position contains at ...
vtkPointLocator::GetOverlappingBuckets
void GetOverlappingBuckets(vtkNeighborPoints *buckets, const double x[3], const int ijk[3], double dist, int level)
vtkPointLocator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type management and printing.
vtkPointLocator::FindClosestInsertedPoint
vtkIdType FindClosestInsertedPoint(const double x[3]) override
Given a position x, return the id of the point closest to it.
vtkPointLocator::Points
vtkPoints * Points
Definition: vtkPointLocator.h:303
vtkPointLocator::GetPointsInBucket
virtual vtkIdList * GetPointsInBucket(const double x[3], int ijk[3])
Given a position x, return the list of points in the bucket that contains the point.
vtkPointLocator::FreeSearchStructure
void FreeSearchStructure() override
See vtkLocator interface documentation.
vtkPointLocator::GetBucketNeighbors
void GetBucketNeighbors(vtkNeighborPoints *buckets, const int ijk[3], const int ndivs[3], int level)
vtkPointLocator::NumberOfPointsPerBucket
int NumberOfPointsPerBucket
Definition: vtkPointLocator.h:305
vtkPointLocator::ComputePerformanceFactors
void ComputePerformanceFactors()
vtkPointLocator::FindPointsWithinRadius
void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result) override
Find all points within a specified radius R of position x.
vtkPointLocator::FindDistributedPoints
virtual void FindDistributedPoints(int N, const double x[3], vtkIdList *result, int M)
Find the closest points to a position such that each octant of space around the position contains at ...
vtkX3D::level
@ level
Definition: vtkX3D.h:401
vtkPointLocator::HZ
double HZ
Definition: vtkPointLocator.h:314
vtkPointLocator::ZD
vtkIdType ZD
Definition: vtkPointLocator.h:316
vtkIncrementalPointLocator.h
vtkPointLocator::InsertUniquePoint
int InsertUniquePoint(const double x[3], vtkIdType &ptId) override
Determine whether point given by x[3] has been inserted into points list.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:290
vtkIncrementalPointLocator
Abstract class in support of both point location and point insertion.
Definition: vtkIncrementalPointLocator.h:52
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
vtkPointLocator::GetBucketIndices
void GetBucketIndices(const double *x, int ijk[3]) const
Definition: vtkPointLocator.h:318
vtkPointLocator::GenerateRepresentation
void GenerateRepresentation(int level, vtkPolyData *pd) override
See vtkLocator interface documentation.
vtkPointLocator::~vtkPointLocator
~vtkPointLocator() override
vtkPointLocator::New
static vtkPointLocator * New()
Construct with automatic computation of divisions, averaging 25 points per bucket.
vtkPointLocator::IsInsertedPoint
vtkIdType IsInsertedPoint(double x, double y, double z) override
Determine whether point given by x[3] has been inserted into points list.
Definition: vtkPointLocator.h:201
vtkPointLocator::vtkPointLocator
vtkPointLocator()
vtkPointLocator::Initialize
void Initialize() override
See vtkLocator interface documentation.
vtkPointLocator::IsInsertedPoint
vtkIdType IsInsertedPoint(const double x[3]) override
Determine whether point given by x[3] has been inserted into points list.
vtkPointLocator::InsertNextPoint
vtkIdType InsertNextPoint(const double x[3]) override
Incrementally insert a point into search structure.
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkPointLocator::FindClosestPoint
vtkIdType FindClosestPoint(const double x[3]) override
Given a position x, return the id of the point closest to it.
vtkPointLocator::FindClosestNPoints
void FindClosestNPoints(int N, const double x[3], vtkIdList *result) override
Find the closest N points to a position.
vtkPointLocator::InitPointInsertion
int InitPointInsertion(vtkPoints *newPts, const double bounds[6], vtkIdType estNumPts) override
Initialize the point insertion process.
vtkAbstractPointLocator::FindClosestPoint
virtual vtkIdType FindClosestPoint(const double x[3])=0
Given a position x, return the id of the point closest to it.
vtkPointLocator::InsertionTol2
double InsertionTol2
Definition: vtkPointLocator.h:309
vtkX3D::radius
@ radius
Definition: vtkX3D.h:258
vtkPointLocator::Distance2ToBucket
double Distance2ToBucket(const double x[3], const int nei[3])
vtkPointLocator::GetOverlappingBuckets
void GetOverlappingBuckets(vtkNeighborPoints *buckets, const double x[3], double dist, int prevMinLevel[3], int prevMaxLevel[3])
vtkPointLocator::Distance2ToBounds
double Distance2ToBounds(const double x[3], const double bounds[6])
vtkPointLocator::FindClosestPointWithinRadius
virtual vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double inputDataLength, double &dist2)
Given a position x and a radius r, return the id of the point closest to the point in that radius.