VTK
dox/Common/DataModel/vtkPointLocator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkPointLocator.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00041 #ifndef __vtkPointLocator_h
00042 #define __vtkPointLocator_h
00043 
00044 #include "vtkCommonDataModelModule.h" // For export macro
00045 #include "vtkIncrementalPointLocator.h"
00046 
00047 class vtkCellArray;
00048 class vtkIdList;
00049 class vtkNeighborPoints;
00050 class vtkPoints;
00051 
00052 class VTKCOMMONDATAMODEL_EXPORT vtkPointLocator : public vtkIncrementalPointLocator
00053 {
00054 public:
00057   static vtkPointLocator *New();
00058 
00059   vtkTypeMacro(vtkPointLocator,vtkIncrementalPointLocator);
00060   void PrintSelf(ostream& os, vtkIndent indent);
00061 
00063 
00064   vtkSetVector3Macro(Divisions,int);
00065   vtkGetVectorMacro(Divisions,int,3);
00067 
00069 
00070   vtkSetClampMacro(NumberOfPointsPerBucket,int,1,VTK_INT_MAX);
00071   vtkGetMacro(NumberOfPointsPerBucket,int);
00073 
00078   virtual vtkIdType FindClosestPoint(const double x[3]);
00079 
00081 
00085   virtual vtkIdType FindClosestPointWithinRadius(
00086     double radius, const double x[3], double& dist2);
00087   virtual vtkIdType FindClosestPointWithinRadius(double radius, const double x[3],
00088                                          double inputDataLength, double& dist2);
00090 
00095   virtual int InitPointInsertion(vtkPoints *newPts, const double bounds[6]);
00096 
00098 
00102   virtual int InitPointInsertion(vtkPoints *newPts, const double bounds[6],
00103                                  vtkIdType estSize);
00105 
00113   virtual void InsertPoint(vtkIdType ptId, const double x[3]);
00114 
00122   virtual vtkIdType InsertNextPoint(const double x[3]);
00123 
00125 
00128   vtkIdType IsInsertedPoint(double x, double  y, double z)
00129     {
00130     double xyz[3];
00131     xyz[0] = x; xyz[1] = y; xyz[2] = z;
00132     return this->IsInsertedPoint (xyz);
00133     };
00134   virtual vtkIdType IsInsertedPoint(const double x[3]);
00136 
00144   virtual int InsertUniquePoint(const double x[3], vtkIdType &ptId);
00145 
00151   virtual vtkIdType FindClosestInsertedPoint(const double x[3]);
00152 
00159   virtual void FindClosestNPoints(int N, const double x[3], vtkIdList *result);
00160 
00162 
00167   virtual void FindDistributedPoints(int N, const double x[3],
00168                                      vtkIdList *result, int M);
00169   virtual void FindDistributedPoints(int N, double x, double y,
00170                                      double z, vtkIdList *result, int M);
00172 
00174 
00178   virtual void FindPointsWithinRadius(double R, const double x[3],
00179                                       vtkIdList *result);
00181 
00186   virtual vtkIdList *GetPointsInBucket(const double x[3], int ijk[3]);
00187 
00189 
00190   vtkGetObjectMacro(Points, vtkPoints);
00192 
00194 
00196   void Initialize();
00197   void FreeSearchStructure();
00198   void BuildLocator();
00199   void GenerateRepresentation(int level, vtkPolyData *pd);
00201 
00202 protected:
00203   vtkPointLocator();
00204   virtual ~vtkPointLocator();
00205 
00206   // place points in appropriate buckets
00207   void GetBucketNeighbors(vtkNeighborPoints* buckets,
00208                           const int ijk[3], const int ndivs[3], int level);
00209   void GetOverlappingBuckets(vtkNeighborPoints* buckets,
00210                              const double x[3], const int ijk[3], double dist,
00211                              int level);
00212   void GetOverlappingBuckets(vtkNeighborPoints* buckets,
00213                              const double x[3], double dist,
00214                              int prevMinLevel[3],
00215                              int prevMaxLevel[3]);
00216   void GenerateFace(int face, int i, int j, int k,
00217                     vtkPoints *pts, vtkCellArray *polys);
00218   double Distance2ToBucket(const double x[3], const int nei[3]);
00219   double Distance2ToBounds(const double x[3], const double bounds[6]);
00220 
00222 
00223   vtkIdType GetBucketIndex(const double x[3]);
00224   void GetBucketIndices(const double x[3], int ijk[3]);
00226 
00227   vtkPoints *Points; // Used for merging points
00228   int Divisions[3]; // Number of sub-divisions in x-y-z directions
00229   int NumberOfPointsPerBucket; //Used with previous boolean to control subdivide
00230   vtkIdList **HashTable; // lists of point ids in buckets
00231   vtkIdType NumberOfBuckets; // total size of hash table
00232   double H[3]; // width of each bucket in x-y-z directions
00233 
00234   double InsertionTol2;
00235   vtkIdType InsertionPointId;
00236 
00237   double InsertionLevel;
00238 private:
00239   vtkPointLocator(const vtkPointLocator&);  // Not implemented.
00240   void operator=(const vtkPointLocator&);  // Not implemented.
00241 };
00242 
00243 #endif
00244 
00245