VTK
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=========================================================================*/
42#ifndef vtkPointLocator_h
43#define vtkPointLocator_h
44
45#include "vtkCommonDataModelModule.h" // For export macro
47
48class vtkCellArray;
49class vtkIdList;
50class vtkNeighborPoints;
51class vtkPoints;
52
53class VTKCOMMONDATAMODEL_EXPORT vtkPointLocator : public vtkIncrementalPointLocator
54{
55public:
61
63
67 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
69
71
74 vtkSetVector3Macro(Divisions,int);
75 vtkGetVectorMacro(Divisions,int,3);
77
79
82 vtkSetClampMacro(NumberOfPointsPerBucket,int,1,VTK_INT_MAX);
83 vtkGetMacro(NumberOfPointsPerBucket,int);
85
86 // Re-use any superclass signatures that we don't override.
88
95 vtkIdType FindClosestPoint(const double x[3]) VTK_OVERRIDE;
96
98
106 double radius, const double x[3], double& dist2) VTK_OVERRIDE;
108 double radius, const double x[3],
109 double inputDataLength, double& dist2);
111
119 const double bounds[6]) VTK_OVERRIDE;
120
127 int InitPointInsertion(vtkPoints *newPts, const double bounds[6],
128 vtkIdType estSize) VTK_OVERRIDE;
129
139 void InsertPoint(vtkIdType ptId, const double x[3]) VTK_OVERRIDE;
140
151 vtkIdType InsertNextPoint(const double x[3]) VTK_OVERRIDE;
152
154
159 vtkIdType IsInsertedPoint(double x, double y, double z) VTK_OVERRIDE
160 {
161 double xyz[3];
162 xyz[0] = x; xyz[1] = y; xyz[2] = z;
163 return this->IsInsertedPoint (xyz);
164 };
165 vtkIdType IsInsertedPoint(const double x[3]) VTK_OVERRIDE;
167
177 int InsertUniquePoint(const double x[3], vtkIdType &ptId) VTK_OVERRIDE;
178
186 vtkIdType FindClosestInsertedPoint(const double x[3]) VTK_OVERRIDE;
187
196 void FindClosestNPoints(int N, const double x[3],
197 vtkIdList *result) VTK_OVERRIDE;
198
200
207 virtual void FindDistributedPoints(int N, const double x[3],
208 vtkIdList *result, int M);
209 virtual void FindDistributedPoints(int N, double x, double y,
210 double z, vtkIdList *result, int M);
212
219 void FindPointsWithinRadius(double R, const double x[3],
220 vtkIdList *result) VTK_OVERRIDE;
221
228 virtual vtkIdList *GetPointsInBucket(const double x[3], int ijk[3]);
229
231
234 vtkGetObjectMacro(Points, vtkPoints);
236
238
242 void Initialize() VTK_OVERRIDE;
243 void FreeSearchStructure() VTK_OVERRIDE;
244 void BuildLocator() VTK_OVERRIDE;
245 void GenerateRepresentation(int level, vtkPolyData *pd) VTK_OVERRIDE;
247
248protected:
250 ~vtkPointLocator() VTK_OVERRIDE;
251
252 // place points in appropriate buckets
253 void GetBucketNeighbors(vtkNeighborPoints* buckets,
254 const int ijk[3], const int ndivs[3], int level);
255 void GetOverlappingBuckets(vtkNeighborPoints* buckets,
256 const double x[3], const int ijk[3], double dist,
257 int level);
258 void GetOverlappingBuckets(vtkNeighborPoints* buckets,
259 const double x[3], double dist,
260 int prevMinLevel[3],
261 int prevMaxLevel[3]);
262 void GenerateFace(int face, int i, int j, int k,
263 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
273 double InsertionTol2;
274 vtkIdType InsertionPointId;
275 double InsertionLevel;
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;
280 vtkIdType XD, YD, ZD, SliceSize;
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 ijk[0] = static_cast<int>(((x[0] - this->BX) * this->FX));
286 ijk[1] = static_cast<int>(((x[1] - this->BY) * this->FY));
287 ijk[2] = static_cast<int>(((x[2] - this->BZ) * this->FZ));
288
289 ijk[0] = (ijk[0] < 0 ? 0 : (ijk[0] >= XD ? XD-1 : ijk[0]));
290 ijk[1] = (ijk[1] < 0 ? 0 : (ijk[1] >= YD ? YD-1 : ijk[1]));
291 ijk[2] = (ijk[2] < 0 ? 0 : (ijk[2] >= ZD ? ZD-1 : ijk[2]));
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&) VTK_DELETE_FUNCTION;
305 void operator=(const vtkPointLocator&) VTK_DELETE_FUNCTION;
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
Definition: vtkCellArray.h:51
list of point or cell ids
Definition: vtkIdList.h:37
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:40
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 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)
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.
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 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.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double inputDataLength, double &dist2)
void ComputePerformanceFactors()
vtkIdType IsInsertedPoint(const double x[3]) override
Determine whether or not a given point has been inserted.
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.
int InitPointInsertion(vtkPoints *newPts, const double bounds[6], vtkIdType estSize) override
Initialize the point insertion process.
void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result) override
Find all points within a specified radius R of position x.
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:86
@ level
Definition: vtkX3D.h:395
@ radius
Definition: vtkX3D.h:252
int vtkIdType
Definition: vtkType.h:287
#define VTK_INT_MAX
Definition: vtkType.h:153
#define M(row, col)