VTK  9.2.6
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=========================================================================*/
48
49#ifndef vtkPointLocator_h
50#define vtkPointLocator_h
51
52#include "vtkCommonDataModelModule.h" // For export macro
54
55class vtkCellArray;
56class vtkIdList;
57class vtkNeighborPoints;
58class vtkPoints;
59
60class VTKCOMMONDATAMODEL_EXPORT vtkPointLocator : public vtkIncrementalPointLocator
61{
62public:
68
70
74 void PrintSelf(ostream& os, vtkIndent indent) override;
76
78
81 vtkSetVector3Macro(Divisions, int);
82 vtkGetVectorMacro(Divisions, int, 3);
84
86
89 vtkSetClampMacro(NumberOfPointsPerBucket, int, 1, VTK_INT_MAX);
90 vtkGetMacro(NumberOfPointsPerBucket, int);
92
93 // Re-use any superclass signatures that we don't override.
95
102 vtkIdType FindClosestPoint(const double x[3]) override;
103
105
112 vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2) override;
114 double radius, const double x[3], double inputDataLength, double& dist2);
116
123 int InitPointInsertion(vtkPoints* newPts, const double bounds[6]) override;
124
131 int InitPointInsertion(vtkPoints* newPts, const double bounds[6], vtkIdType estNumPts) override;
132
142 void InsertPoint(vtkIdType ptId, const double x[3]) override;
143
154 vtkIdType InsertNextPoint(const double x[3]) override;
155
157
162 vtkIdType IsInsertedPoint(double x, double y, double z) override
163 {
164 double xyz[3];
165 xyz[0] = x;
166 xyz[1] = y;
167 xyz[2] = z;
168 return this->IsInsertedPoint(xyz);
169 };
170 vtkIdType IsInsertedPoint(const double x[3]) override;
172
182 int InsertUniquePoint(const double x[3], vtkIdType& ptId) override;
183
191 vtkIdType FindClosestInsertedPoint(const double x[3]) override;
192
201 void FindClosestNPoints(int N, const double x[3], vtkIdList* result) override;
202
204
211 virtual void FindDistributedPoints(int N, const double x[3], vtkIdList* result, int M);
212 virtual void FindDistributedPoints(int N, double x, double y, double z, vtkIdList* result, int M);
214
221 void FindPointsWithinRadius(double R, const double x[3], vtkIdList* result) override;
222
229 virtual vtkIdList* GetPointsInBucket(const double x[3], int ijk[3]);
230
232
235 vtkGetObjectMacro(Points, vtkPoints);
237
239
243 void Initialize() override;
244 void FreeSearchStructure() override;
245 void BuildLocator() override;
246 void ForceBuildLocator() override;
247 void GenerateRepresentation(int level, vtkPolyData* pd) override;
249
250protected:
253
254 void BuildLocatorInternal() override;
255
256 // place points in appropriate buckets
258 vtkNeighborPoints* buckets, const int ijk[3], const int ndivs[3], int level);
260 vtkNeighborPoints* buckets, const double x[3], const int ijk[3], double dist, int level);
261 void GetOverlappingBuckets(vtkNeighborPoints* buckets, const double x[3], double dist,
262 int prevMinLevel[3], int prevMaxLevel[3]);
263 void GenerateFace(int face, int i, int j, int k, vtkPoints* pts, vtkCellArray* polys);
264 double Distance2ToBucket(const double x[3], const int nei[3]);
265 double Distance2ToBounds(const double x[3], const double bounds[6]);
266
267 vtkPoints* Points; // Used for merging points
268 int Divisions[3]; // Number of sub-divisions in x-y-z directions
269 int NumberOfPointsPerBucket; // Used with previous boolean to control subdivide
270 vtkIdList** HashTable; // lists of point ids in buckets
271 double H[3]; // width of each bucket in x-y-z directions
272
276
277 // These are inlined methods and data members for performance reasons
278 double HX, HY, HZ;
279 double FX, FY, FZ, BX, BY, BZ;
281
282 void GetBucketIndices(const double* x, int ijk[3]) const
283 {
284 // Compute point index. Make sure it lies within range of locator.
285 vtkIdType tmp0 = static_cast<vtkIdType>(((x[0] - this->BX) * this->FX));
286 vtkIdType tmp1 = static_cast<vtkIdType>(((x[1] - this->BY) * this->FY));
287 vtkIdType tmp2 = static_cast<vtkIdType>(((x[2] - this->BZ) * this->FZ));
288
289 ijk[0] = tmp0 < 0 ? 0 : (tmp0 >= this->XD ? this->XD - 1 : tmp0);
290 ijk[1] = tmp1 < 0 ? 0 : (tmp1 >= this->YD ? this->YD - 1 : tmp1);
291 ijk[2] = tmp2 < 0 ? 0 : (tmp2 >= this->ZD ? this->ZD - 1 : tmp2);
292 }
293
294 vtkIdType GetBucketIndex(const double* x) const
295 {
296 int ijk[3];
297 this->GetBucketIndices(x, ijk);
298 return ijk[0] + ijk[1] * this->XD + ijk[2] * this->SliceSize;
299 }
300
302
303private:
304 vtkPointLocator(const vtkPointLocator&) = delete;
305 void operator=(const vtkPointLocator&) = delete;
306};
307
308#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:34
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:40
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:40
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:91
int vtkIdType
Definition vtkType.h:332
#define VTK_INT_MAX
Definition vtkType.h:155