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   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00045 #ifndef __vtkPointLocator_h
00046 #define __vtkPointLocator_h
00047 
00048 #include "vtkLocator.h"
00049 
00050 class vtkCellArray;
00051 class vtkIdList;
00052 class vtkNeighborPoints;
00053 class vtkPoints;
00054 
00055 class VTK_COMMON_EXPORT vtkPointLocator : public vtkLocator
00056 {
00057 public:
00060   static vtkPointLocator *New();
00061 
00062   vtkTypeRevisionMacro(vtkPointLocator,vtkLocator);
00063   void PrintSelf(ostream& os, vtkIndent indent);
00064 
00066 
00067   vtkSetVector3Macro(Divisions,int);
00068   vtkGetVectorMacro(Divisions,int,3);
00070 
00072 
00073   vtkSetClampMacro(NumberOfPointsPerBucket,int,1,VTK_LARGE_INTEGER);
00074   vtkGetMacro(NumberOfPointsPerBucket,int);
00076 
00078 
00082   virtual vtkIdType FindClosestPoint(const float x[3]);
00083   vtkIdType FindClosestPoint(float x, float y, float z);
00085 
00087 
00091   vtkIdType FindClosestPointWithinRadius(float radius, const float x[3],
00092                                          float& dist2);
00093   vtkIdType FindClosestPointWithinRadius(float radius, const float x[3], 
00094                                          float inputDataLength, float& dist2);
00096 
00101   virtual int InitPointInsertion(vtkPoints *newPts, const float bounds[6]);
00102 
00104 
00108   virtual int InitPointInsertion(vtkPoints *newPts, const float bounds[6], 
00109                                  vtkIdType estSize);
00111 
00119   virtual void InsertPoint(vtkIdType ptId, const float x[3]);
00120 
00128   virtual vtkIdType InsertNextPoint(const float x[3]);
00129 
00131 
00134   vtkIdType IsInsertedPoint(float x, float  y, float z)
00135     {
00136     float xyz[3];
00137     xyz[0] = x; xyz[1] = y; xyz[2] = z;
00138     return this->IsInsertedPoint (xyz);
00139     };
00140   virtual vtkIdType IsInsertedPoint(const float x[3]);
00142 
00150   virtual int InsertUniquePoint(const float x[3], vtkIdType &ptId);
00151 
00157   virtual vtkIdType FindClosestInsertedPoint(const float x[3]);
00158 
00160 
00166   virtual void FindClosestNPoints(int N, const float x[3], vtkIdList *result);
00167   virtual void FindClosestNPoints(int N, float x, float y, float z,
00168                                   vtkIdList *result);
00170 
00172 
00177   virtual void FindDistributedPoints(int N, const float x[3], 
00178                                      vtkIdList *result, int M);
00179   virtual void FindDistributedPoints(int N, float x, float y, 
00180                                      float z, vtkIdList *result, int M);
00182 
00184 
00188   virtual void FindPointsWithinRadius(float R, const float x[3],
00189                                       vtkIdList *result);
00190   virtual void FindPointsWithinRadius(float R, float x, float y, float z, 
00191                                       vtkIdList *result);
00193   
00198   virtual vtkIdList *GetPointsInBucket(const float x[3], int ijk[3]);
00199 
00201 
00203   void Initialize();
00204   void FreeSearchStructure();
00205   void BuildLocator();
00206   void GenerateRepresentation(int level, vtkPolyData *pd);
00208 
00209 protected:
00210   vtkPointLocator();
00211   ~vtkPointLocator();
00212 
00213   // place points in appropriate buckets
00214   void GetBucketNeighbors(vtkNeighborPoints* buckets,
00215                           const int ijk[3], const int ndivs[3], int level);
00216   void GetOverlappingBuckets(vtkNeighborPoints* buckets, 
00217                              const float x[3], const int ijk[3], float dist,
00218                              int level);
00219   void GetOverlappingBuckets(vtkNeighborPoints* buckets,
00220                              const float x[3], float dist,
00221                              int prevMinLevel[3],
00222                              int prevMaxLevel[3]);
00223   void GenerateFace(int face, int i, int j, int k, 
00224                     vtkPoints *pts, vtkCellArray *polys);
00225   float Distance2ToBucket(const float x[3], const int nei[3]);
00226   float Distance2ToBounds(const float x[3], const float bounds[6]);
00227 
00228   vtkPoints *Points; // Used for merging points
00229   int Divisions[3]; // Number of sub-divisions in x-y-z directions
00230   int NumberOfPointsPerBucket; //Used with previous boolean to control subdivide
00231   float Bounds[6]; // bounds of points
00232   vtkIdList **HashTable; // lists of point ids in buckets
00233   vtkIdType NumberOfBuckets; // total size of hash table
00234   float H[3]; // width of each bucket in x-y-z directions
00235 
00236   float InsertionTol2;
00237   vtkIdType InsertionPointId;
00238 
00239   float InsertionLevel; 
00240 private:
00241   vtkPointLocator(const vtkPointLocator&);  // Not implemented.
00242   void operator=(const vtkPointLocator&);  // Not implemented.
00243 };
00244 
00245 #endif
00246 
00247