Thanks to visit codestin.com
Credit goes to vtk.org

VTK  9.5.20250921
vtkPointLocator.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
90#ifndef vtkPointLocator_h
91#define vtkPointLocator_h
92
93#include "vtkCommonDataModelModule.h" // For export macro
95
96#include <algorithm> // for std::min/std::max
97
98VTK_ABI_NAMESPACE_BEGIN
99class vtkCellArray;
100class vtkIdList;
101class vtkNeighborPoints;
102class vtkPoints;
103
104class VTKCOMMONDATAMODEL_EXPORT vtkPointLocator : public vtkIncrementalPointLocator
105{
106public:
112
114
118 void PrintSelf(ostream& os, vtkIndent indent) override;
120
122
125 vtkSetVector3Macro(Divisions, int);
126 vtkGetVectorMacro(Divisions, int, 3);
128
130
133 vtkSetClampMacro(NumberOfPointsPerBucket, int, 1, VTK_INT_MAX);
134 vtkGetMacro(NumberOfPointsPerBucket, int);
136
137 // Reuse any superclass signatures that we don't override.
139
146 vtkIdType FindClosestPoint(const double x[3]) override;
147
149
156 vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2) override;
158 double radius, const double x[3], double inputDataLength, double& dist2);
160
167 int InitPointInsertion(vtkPoints* newPts, const double bounds[6]) override;
168
175 int InitPointInsertion(vtkPoints* newPts, const double bounds[6], vtkIdType estNumPts) override;
176
186 void InsertPoint(vtkIdType ptId, const double x[3]) override;
187
198 vtkIdType InsertNextPoint(const double x[3]) override;
199
201
206 vtkIdType IsInsertedPoint(double x, double y, double z) override
207 {
208 double xyz[3];
209 xyz[0] = x;
210 xyz[1] = y;
211 xyz[2] = z;
212 return this->IsInsertedPoint(xyz);
213 }
214 vtkIdType IsInsertedPoint(const double x[3]) override;
216
226 int InsertUniquePoint(const double x[3], vtkIdType& ptId) override;
227
235 vtkIdType FindClosestInsertedPoint(const double x[3]) override;
236
245 void FindClosestNPoints(int N, const double x[3], vtkIdList* result) override;
246
248
255 virtual void FindDistributedPoints(int N, const double x[3], vtkIdList* result, int M);
256 virtual void FindDistributedPoints(int N, double x, double y, double z, vtkIdList* result, int M);
258
265 void FindPointsWithinRadius(double R, const double x[3], vtkIdList* result) override;
266
273 virtual vtkIdList* GetPointsInBucket(const double x[3], int ijk[3]);
274
276
279 vtkGetObjectMacro(Points, vtkPoints);
281
283
287 void Initialize() override;
288 void FreeSearchStructure() override;
289 void BuildLocator() override;
290 void ForceBuildLocator() override;
291 void GenerateRepresentation(int level, vtkPolyData* pd) override;
293
294protected:
297
298 void BuildLocatorInternal() override;
299
300 // place points in appropriate buckets
302 vtkNeighborPoints* buckets, const int ijk[3], const int ndivs[3], int level);
304 vtkNeighborPoints* buckets, const double x[3], const int ijk[3], double dist, int level);
305 void GetOverlappingBuckets(vtkNeighborPoints* buckets, const double x[3], double dist,
306 int prevMinLevel[3], int prevMaxLevel[3]);
307 void GenerateFace(int face, int i, int j, int k, vtkPoints* pts, vtkCellArray* polys);
308 double Distance2ToBucket(const double x[3], const int nei[3]);
309 double Distance2ToBounds(const double x[3], const double bounds[6]);
310
311 vtkPoints* Points; // Used for merging points
312 int Divisions[3]; // Number of sub-divisions in x-y-z directions
313 int NumberOfPointsPerBucket; // Used with previous boolean to control subdivide
314 vtkIdList** HashTable; // lists of point ids in buckets
315 double H[3]; // width of each bucket in x-y-z directions
316
320
321 // These are inlined methods and data members for performance reasons
322 double HX, HY, HZ;
323 double FX, FY, FZ, BX, BY, BZ;
324 vtkIdType XD, YD, ZD, SliceSize;
325
326 void GetBucketIndices(const double* x, int ijk[3]) const
327 {
328 // Compute point index. Make sure it lies within range of locator.
329 vtkIdType tmp0 = static_cast<vtkIdType>(((x[0] - this->BX) * this->FX));
330 vtkIdType tmp1 = static_cast<vtkIdType>(((x[1] - this->BY) * this->FY));
331 vtkIdType tmp2 = static_cast<vtkIdType>(((x[2] - this->BZ) * this->FZ));
332
333 ijk[0] = std::min(std::max<vtkIdType>(tmp0, 0), this->XD - 1);
334 ijk[1] = std::min(std::max<vtkIdType>(tmp1, 0), this->YD - 1);
335 ijk[2] = std::min(std::max<vtkIdType>(tmp2, 0), this->ZD - 1);
336 }
337
338 vtkIdType GetBucketIndex(const double* x) const
339 {
340 int ijk[3];
341 this->GetBucketIndices(x, ijk);
342 return ijk[0] + ijk[1] * this->XD + ijk[2] * this->SliceSize;
343 }
344
346
347private:
348 vtkPointLocator(const vtkPointLocator&) = delete;
349 void operator=(const vtkPointLocator&) = delete;
350};
351
352VTK_ABI_NAMESPACE_END
353#endif
virtual vtkIdType FindClosestPoint(const double x[3])=0
Given a position x, return the id of the point closest to it.
object to represent cell connectivity
list of point or cell ids
Definition vtkIdList.h:133
Abstract class in support of both point location and point insertion.
virtual vtkIdType IsInsertedPoint(double x, double y, double z)=0
Determine whether or not a given point has been inserted.
a simple class to control print indentation
Definition vtkIndent.h:108
quickly locate points in 3-space
void InsertPoint(vtkIdType ptId, const double x[3]) override
Incrementally insert a point into search structure with a particular index value.
int InitPointInsertion(vtkPoints *newPts, const double bounds[6]) override
Initialize the point insertion process.
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 IsInsertedPoint(double x, double y, double z) override
Determine whether point given by x[3] has been inserted into points list.
void BuildLocator() override
See vtkLocator interface documentation.
void FindClosestNPoints(int N, const double x[3], vtkIdList *result) override
Find the closest N points to a position.
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 ...
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.
static vtkPointLocator * New()
Construct with automatic computation of divisions, averaging 25 points per bucket.
void GetBucketIndices(const double *x, int ijk[3]) const
void GetBucketNeighbors(vtkNeighborPoints *buckets, const int ijk[3], const int ndivs[3], int level)
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 ...
void FreeSearchStructure() override
See vtkLocator interface documentation.
vtkIdList ** HashTable
void BuildLocatorInternal() override
This function is not pure virtual to maintain backwards compatibility.
void ForceBuildLocator() override
See vtkLocator interface documentation.
void Initialize() override
See vtkLocator interface documentation.
vtkIdType FindClosestPoint(const double x[3]) override
Given a position x, return the id of the point closest to it.
double Distance2ToBucket(const double x[3], const int nei[3])
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type management and printing.
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.
void ComputePerformanceFactors()
vtkIdType IsInsertedPoint(const double x[3]) override
Determine whether point given by x[3] has been inserted into points list.
~vtkPointLocator() override
void GenerateRepresentation(int level, vtkPolyData *pd) override
See vtkLocator interface documentation.
void GenerateFace(int face, int i, int j, int k, vtkPoints *pts, vtkCellArray *polys)
vtkIdType InsertionPointId
void GetOverlappingBuckets(vtkNeighborPoints *buckets, const double x[3], double dist, int prevMinLevel[3], int prevMaxLevel[3])
void GetOverlappingBuckets(vtkNeighborPoints *buckets, const double x[3], const int ijk[3], double dist, int level)
vtkIdType GetBucketIndex(const double *x) const
vtkIdType InsertNextPoint(const double x[3]) override
Incrementally insert a point into search structure.
int InsertUniquePoint(const double x[3], vtkIdType &ptId) override
Determine whether point given by x[3] has been inserted into points list.
void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result) override
Find all points within a specified radius R of position x.
double Distance2ToBounds(const double x[3], const double bounds[6])
int InitPointInsertion(vtkPoints *newPts, const double bounds[6], vtkIdType estNumPts) override
Initialize the point insertion process.
vtkIdType FindClosestInsertedPoint(const double x[3]) override
Given a position x, return the id of the point closest to it.
represent and manipulate 3D points
Definition vtkPoints.h:139
concrete dataset represents vertices, lines, polygons, and triangle strips
int vtkIdType
Definition vtkType.h:333
#define VTK_INT_MAX
Definition vtkType.h:162