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 =========================================================================*/
41 #ifndef vtkPointLocator_h
42 #define vtkPointLocator_h
43 
44 #include "vtkCommonDataModelModule.h" // For export macro
46 
47 class vtkCellArray;
48 class vtkIdList;
49 class vtkNeighborPoints;
50 class vtkPoints;
51 
53 {
54 public:
57  static vtkPointLocator *New();
58 
60 
62  void PrintSelf(ostream& os, vtkIndent indent);
64 
66 
67  vtkSetVector3Macro(Divisions,int);
68  vtkGetVectorMacro(Divisions,int,3);
70 
72 
73  vtkSetClampMacro(NumberOfPointsPerBucket,int,1,VTK_INT_MAX);
74  vtkGetMacro(NumberOfPointsPerBucket,int);
76 
77  // Re-use any superclass signatures that we don't override.
79 
84  virtual vtkIdType FindClosestPoint(const double x[3]);
85 
87 
92  double radius, const double x[3], double& dist2);
94  double radius, const double x[3], double inputDataLength, double& dist2);
96 
101  virtual int InitPointInsertion(vtkPoints *newPts, const double bounds[6]);
102 
104 
108  virtual int InitPointInsertion(vtkPoints *newPts, const double bounds[6],
109  vtkIdType estSize);
111 
119  virtual void InsertPoint(vtkIdType ptId, const double x[3]);
120 
128  virtual vtkIdType InsertNextPoint(const double x[3]);
129 
131 
134  vtkIdType IsInsertedPoint(double x, double y, double z)
135  {
136  double xyz[3];
137  xyz[0] = x; xyz[1] = y; xyz[2] = z;
138  return this->IsInsertedPoint (xyz);
139  };
140  virtual vtkIdType IsInsertedPoint(const double x[3]);
142 
150  virtual int InsertUniquePoint(const double x[3], vtkIdType &ptId);
151 
157  virtual vtkIdType FindClosestInsertedPoint(const double x[3]);
158 
165  virtual void FindClosestNPoints(int N, const double x[3], vtkIdList *result);
166 
168 
173  virtual void FindDistributedPoints(int N, const double x[3],
174  vtkIdList *result, int M);
175  virtual void FindDistributedPoints(int N, double x, double y,
176  double z, vtkIdList *result, int M);
178 
180 
184  virtual void FindPointsWithinRadius(double R, const double x[3],
185  vtkIdList *result);
187 
192  virtual vtkIdList *GetPointsInBucket(const double x[3], int ijk[3]);
193 
195 
196  vtkGetObjectMacro(Points, vtkPoints);
198 
200 
202  void Initialize();
203  void FreeSearchStructure();
204  void BuildLocator();
207 
208 protected:
209  vtkPointLocator();
210  virtual ~vtkPointLocator();
211 
212  // place points in appropriate buckets
213  void GetBucketNeighbors(vtkNeighborPoints* buckets,
214  const int ijk[3], const int ndivs[3], int level);
215  void GetOverlappingBuckets(vtkNeighborPoints* buckets,
216  const double x[3], const int ijk[3], double dist,
217  int level);
218  void GetOverlappingBuckets(vtkNeighborPoints* buckets,
219  const double x[3], double dist,
220  int prevMinLevel[3],
221  int prevMaxLevel[3]);
222  void GenerateFace(int face, int i, int j, int k,
223  vtkPoints *pts, vtkCellArray *polys);
224  double Distance2ToBucket(const double x[3], const int nei[3]);
225  double Distance2ToBounds(const double x[3], const double bounds[6]);
226 
227  vtkPoints *Points; // Used for merging points
228  int Divisions[3]; // Number of sub-divisions in x-y-z directions
229  int NumberOfPointsPerBucket; //Used with previous boolean to control subdivide
230  vtkIdList **HashTable; // lists of point ids in buckets
231  double H[3]; // width of each bucket in x-y-z directions
232 
236 
237  // These are inlined methods and data members for performance reasons
238  double HX, HY, HZ;
239  double FX, FY, FZ, BX, BY, BZ;
240  vtkIdType XD, YD, ZD, SliceSize;
241 
242  void GetBucketIndices(const double *x, int ijk[3]) const
243  {
244  // Compute point index. Make sure it lies within range of locator.
245  ijk[0] = static_cast<int>(((x[0] - this->BX) * this->FX));
246  ijk[1] = static_cast<int>(((x[1] - this->BY) * this->FY));
247  ijk[2] = static_cast<int>(((x[2] - this->BZ) * this->FZ));
248 
249  ijk[0] = (ijk[0] < 0 ? 0 : (ijk[0] >= XD ? XD-1 : ijk[0]));
250  ijk[1] = (ijk[1] < 0 ? 0 : (ijk[1] >= YD ? YD-1 : ijk[1]));
251  ijk[2] = (ijk[2] < 0 ? 0 : (ijk[2] >= ZD ? ZD-1 : ijk[2]));
252  }
253 
254  vtkIdType GetBucketIndex(const double *x) const
255  {
256  int ijk[3];
257  this->GetBucketIndices(x, ijk);
258  return ijk[0] + ijk[1]*this->XD + ijk[2]*this->SliceSize;
259  }
260 
261  void ComputePerformanceFactors();
262 
263 private:
264  vtkPointLocator(const vtkPointLocator&); // Not implemented.
265  void operator=(const vtkPointLocator&); // Not implemented.
266 };
267 
268 #endif
vtkIdType GetBucketIndex(const double *x) const
void GetBucketIndices(const double *x, int ijk[3]) const
virtual void FreeSearchStructure()=0
virtual void Initialize()=0
virtual vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double &dist2)=0
quickly locate points in 3-space
virtual int InsertUniquePoint(const double x[3], vtkIdType &ptId)=0
vtkIdType InsertionPointId
virtual vtkIdType IsInsertedPoint(double x, double y, double z)=0
#define VTK_INT_MAX
Definition: vtkType.h:130
vtkIdType IsInsertedPoint(double x, double y, double z)
vtkIdList ** HashTable
Abstract class in support of both point location and point insertion.
void PrintSelf(ostream &os, vtkIndent indent)
int vtkIdType
Definition: vtkType.h:247
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
virtual int InitPointInsertion(vtkPoints *newPts, const double bounds[6])=0
a simple class to control print indentation
Definition: vtkIndent.h:38
list of point or cell ids
Definition: vtkIdList.h:35
vtkPoints * Points
virtual void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result)=0
virtual void FindClosestNPoints(int N, const double x[3], vtkIdList *result)=0
object to represent cell connectivity
Definition: vtkCellArray.h:49
virtual vtkIdType InsertNextPoint(const double x[3])=0
#define M(row, col)
virtual vtkIdType FindClosestInsertedPoint(const double x[3])=0
virtual vtkIdType FindClosestPoint(const double x[3])=0
virtual void BuildLocator()=0
static vtkObject * New()
virtual void InsertPoint(vtkIdType ptId, const double x[3])=0
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
#define VTKCOMMONDATAMODEL_EXPORT
represent and manipulate 3D points
Definition: vtkPoints.h:38