Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Common/vtkPointLocator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkPointLocator.h,v $
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 "vtkLocator.h"
00045 
00046 class vtkCellArray;
00047 class vtkIdList;
00048 class vtkNeighborPoints;
00049 class vtkPoints;
00050 
00051 class VTK_COMMON_EXPORT vtkPointLocator : public vtkLocator
00052 {
00053 public:
00056   static vtkPointLocator *New();
00057 
00058   vtkTypeRevisionMacro(vtkPointLocator,vtkLocator);
00059   void PrintSelf(ostream& os, vtkIndent indent);
00060 
00062 
00063   vtkSetVector3Macro(Divisions,int);
00064   vtkGetVectorMacro(Divisions,int,3);
00066 
00068 
00069   vtkSetClampMacro(NumberOfPointsPerBucket,int,1,VTK_LARGE_INTEGER);
00070   vtkGetMacro(NumberOfPointsPerBucket,int);
00072 
00074 
00078   virtual vtkIdType FindClosestPoint(const double x[3]);
00079   vtkIdType FindClosestPoint(double x, double y, double z);
00081 
00083 
00087   vtkIdType FindClosestPointWithinRadius(double radius, const double x[3],
00088                                          double& dist2);
00089   vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], 
00090                                          double inputDataLength, double& dist2);
00092 
00097   virtual int InitPointInsertion(vtkPoints *newPts, const double bounds[6]);
00098 
00100 
00104   virtual int InitPointInsertion(vtkPoints *newPts, const double bounds[6], 
00105                                  vtkIdType estSize);
00107 
00115   virtual void InsertPoint(vtkIdType ptId, const double x[3]);
00116 
00124   virtual vtkIdType InsertNextPoint(const double x[3]);
00125 
00127 
00130   vtkIdType IsInsertedPoint(double x, double  y, double z)
00131     {
00132     double xyz[3];
00133     xyz[0] = x; xyz[1] = y; xyz[2] = z;
00134     return this->IsInsertedPoint (xyz);
00135     };
00136   virtual vtkIdType IsInsertedPoint(const double x[3]);
00138 
00146   virtual int InsertUniquePoint(const double x[3], vtkIdType &ptId);
00147 
00153   virtual vtkIdType FindClosestInsertedPoint(const double x[3]);
00154 
00156 
00162   virtual void FindClosestNPoints(int N, const double x[3], vtkIdList *result);
00163   virtual void FindClosestNPoints(int N, double x, double y, double z,
00164                                   vtkIdList *result);
00166 
00168 
00173   virtual void FindDistributedPoints(int N, const double x[3], 
00174                                      vtkIdList *result, int M);
00175   virtual void FindDistributedPoints(int N, double x, double y, 
00176                                      double z, vtkIdList *result, int M);
00178 
00180 
00184   virtual void FindPointsWithinRadius(double R, const double x[3],
00185                                       vtkIdList *result);
00186   virtual void FindPointsWithinRadius(double R, double x, double y, double z, 
00187                                       vtkIdList *result);
00189   
00194   virtual vtkIdList *GetPointsInBucket(const double x[3], int ijk[3]);
00195 
00197 
00199   void Initialize();
00200   void FreeSearchStructure();
00201   void BuildLocator();
00202   void GenerateRepresentation(int level, vtkPolyData *pd);
00204 
00205 protected:
00206   vtkPointLocator();
00207   ~vtkPointLocator();
00208 
00209   // place points in appropriate buckets
00210   void GetBucketNeighbors(vtkNeighborPoints* buckets,
00211                           const int ijk[3], const int ndivs[3], int level);
00212   void GetOverlappingBuckets(vtkNeighborPoints* buckets, 
00213                              const double x[3], const int ijk[3], double dist,
00214                              int level);
00215   void GetOverlappingBuckets(vtkNeighborPoints* buckets,
00216                              const double x[3], double dist,
00217                              int prevMinLevel[3],
00218                              int prevMaxLevel[3]);
00219   void GenerateFace(int face, int i, int j, int k, 
00220                     vtkPoints *pts, vtkCellArray *polys);
00221   double Distance2ToBucket(const double x[3], const int nei[3]);
00222   double Distance2ToBounds(const double x[3], const double bounds[6]);
00223 
00224   vtkPoints *Points; // Used for merging points
00225   int Divisions[3]; // Number of sub-divisions in x-y-z directions
00226   int NumberOfPointsPerBucket; //Used with previous boolean to control subdivide
00227   double Bounds[6]; // bounds of points
00228   vtkIdList **HashTable; // lists of point ids in buckets
00229   vtkIdType NumberOfBuckets; // total size of hash table
00230   double H[3]; // width of each bucket in x-y-z directions
00231 
00232   double InsertionTol2;
00233   vtkIdType InsertionPointId;
00234 
00235   double InsertionLevel; 
00236 private:
00237   vtkPointLocator(const vtkPointLocator&);  // Not implemented.
00238   void operator=(const vtkPointLocator&);  // Not implemented.
00239 };
00240 
00241 #endif
00242 
00243