Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00068 #ifndef __vtkPointLocator_h
00069 #define __vtkPointLocator_h
00070 
00071 #include "vtkLocator.h"
00072 #include "vtkPoints.h"
00073 
00074 class vtkIdList;
00075 class vtkNeighborPoints;
00076 
00077 class VTK_EXPORT vtkPointLocator : public vtkLocator
00078 {
00079 public:
00082   static vtkPointLocator *New();
00083 
00084   vtkTypeMacro(vtkPointLocator,vtkLocator);
00085   void PrintSelf(ostream& os, vtkIndent indent);
00086 
00088   vtkSetVector3Macro(Divisions,int);
00089   vtkGetVectorMacro(Divisions,int,3);
00090 
00092   vtkSetClampMacro(NumberOfPointsPerBucket,int,1,VTK_LARGE_INTEGER);
00093   vtkGetMacro(NumberOfPointsPerBucket,int);
00094 
00099   virtual int FindClosestPoint(const float x[3]);
00100   int FindClosestPoint(float x, float y, float z);
00101 
00106   int FindClosestPointWithinRadius(float radius, const float x[3],
00107                float& dist2);
00108   int FindClosestPointWithinRadius(float radius, const float x[3], 
00109                float inputDataLength, float& dist2);
00110 
00115   virtual int InitPointInsertion(vtkPoints *newPts, const float bounds[6]);
00116 
00121   virtual int InitPointInsertion(vtkPoints *newPts, const float bounds[6], 
00122              int estSize);
00123 
00131   virtual void InsertPoint(int ptId, const float x[3]);
00132 
00140   virtual int InsertNextPoint(const float x[3]);
00141 
00145   int IsInsertedPoint(float x, float  y, float z)
00146     {
00147     float xyz[3];
00148     xyz[0] = x; xyz[1] = y; xyz[2] = z;
00149     return this->IsInsertedPoint (xyz);
00150     };
00151   virtual int IsInsertedPoint(const float x[3]);
00152 
00160   virtual int InsertUniquePoint(const float x[3], int &ptId);
00161 
00167   virtual int FindClosestInsertedPoint(const float x[3]);
00168 
00175   virtual void FindClosestNPoints(int N, const float x[3], vtkIdList *result);
00176   virtual void FindClosestNPoints(int N, float x, float y, float z,
00177               vtkIdList *result);
00178 
00184   virtual void FindDistributedPoints(int N, const float x[3], 
00185                  vtkIdList *result, int M);
00186   virtual void FindDistributedPoints(int N, float x, float y, 
00187                  float z, vtkIdList *result, int M);
00188 
00193   virtual void FindPointsWithinRadius(float R, const float x[3],
00194                   vtkIdList *result);
00195   virtual void FindPointsWithinRadius(float R, float x, float y, float z, 
00196                   vtkIdList *result);
00197   
00202   virtual vtkIdList *GetPointsInBucket(const float x[3], int ijk[3]);
00203 
00206   void Initialize();
00207   void FreeSearchStructure();
00208   void BuildLocator();
00209   void GenerateRepresentation(int level, vtkPolyData *pd);
00210 
00211 protected:
00212   vtkPointLocator();
00213   ~vtkPointLocator();
00214   vtkPointLocator(const vtkPointLocator&) {};
00215   void operator=(const vtkPointLocator&) {};
00216 
00217   // place points in appropriate buckets
00218   void GetBucketNeighbors(vtkNeighborPoints* buckets,
00219            const int ijk[3], const int ndivs[3], int level);
00220   void GetOverlappingBuckets(vtkNeighborPoints* buckets, 
00221               const float x[3], const int ijk[3], float dist,
00222               int level);
00223   void GetOverlappingBuckets(vtkNeighborPoints* buckets,
00224               const float x[3], float dist,
00225               int prevMinLevel[3],
00226               int prevMaxLevel[3]);
00227   void GenerateFace(int face, int i, int j, int k, 
00228                     vtkPoints *pts, vtkCellArray *polys);
00229   float Distance2ToBucket(const float x[3], const int nei[3]);
00230   float Distance2ToBounds(const float x[3], const float bounds[6]);
00231 
00232   vtkPoints *Points; // Used for merging points
00233   int Divisions[3]; // Number of sub-divisions in x-y-z directions
00234   int NumberOfPointsPerBucket; //Used with previous boolean to control subdivide
00235   float Bounds[6]; // bounds of points
00236   vtkIdList **HashTable; // lists of point ids in buckets
00237   int NumberOfBuckets; // total size of hash table
00238   float H[3]; // width of each bucket in x-y-z directions
00239 
00240   float InsertionTol2;
00241   int InsertionPointId;
00242 
00243   float InsertionLevel; 
00244 };
00245 
00246 #endif
00247 
00248 

Generated on Wed Nov 21 12:26:53 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001