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 =========================================================================*/
00069 #ifndef __vtkPointLocator_h
00070 #define __vtkPointLocator_h
00071 
00072 #include "vtkLocator.h"
00073 #include "vtkPoints.h"
00074 
00075 class vtkIdList;
00076 class vtkNeighborPoints;
00077 
00078 class VTK_COMMON_EXPORT vtkPointLocator : public vtkLocator
00079 {
00080 public:
00083   static vtkPointLocator *New();
00084 
00085   vtkTypeMacro(vtkPointLocator,vtkLocator);
00086   void PrintSelf(ostream& os, vtkIndent indent);
00087 
00089 
00090   vtkSetVector3Macro(Divisions,int);
00091   vtkGetVectorMacro(Divisions,int,3);
00093 
00095 
00096   vtkSetClampMacro(NumberOfPointsPerBucket,int,1,VTK_LARGE_INTEGER);
00097   vtkGetMacro(NumberOfPointsPerBucket,int);
00099 
00101 
00105   virtual vtkIdType FindClosestPoint(const float x[3]);
00106   vtkIdType FindClosestPoint(float x, float y, float z);
00108 
00110 
00114   vtkIdType FindClosestPointWithinRadius(float radius, const float x[3],
00115                                          float& dist2);
00116   vtkIdType FindClosestPointWithinRadius(float radius, const float x[3], 
00117                                          float inputDataLength, float& dist2);
00119 
00124   virtual int InitPointInsertion(vtkPoints *newPts, const float bounds[6]);
00125 
00127 
00131   virtual int InitPointInsertion(vtkPoints *newPts, const float bounds[6], 
00132                                  vtkIdType estSize);
00134 
00142   virtual void InsertPoint(vtkIdType ptId, const float x[3]);
00143 
00151   virtual vtkIdType InsertNextPoint(const float x[3]);
00152 
00154 
00157   vtkIdType IsInsertedPoint(float x, float  y, float z)
00158     {
00159     float xyz[3];
00160     xyz[0] = x; xyz[1] = y; xyz[2] = z;
00161     return this->IsInsertedPoint (xyz);
00162     };
00163   virtual vtkIdType IsInsertedPoint(const float x[3]);
00165 
00173   virtual int InsertUniquePoint(const float x[3], vtkIdType &ptId);
00174 
00180   virtual vtkIdType FindClosestInsertedPoint(const float x[3]);
00181 
00183 
00189   virtual void FindClosestNPoints(int N, const float x[3], vtkIdList *result);
00190   virtual void FindClosestNPoints(int N, float x, float y, float z,
00191                                   vtkIdList *result);
00193 
00195 
00200   virtual void FindDistributedPoints(int N, const float x[3], 
00201                                      vtkIdList *result, int M);
00202   virtual void FindDistributedPoints(int N, float x, float y, 
00203                                      float z, vtkIdList *result, int M);
00205 
00207 
00211   virtual void FindPointsWithinRadius(float R, const float x[3],
00212                                       vtkIdList *result);
00213   virtual void FindPointsWithinRadius(float R, float x, float y, float z, 
00214                                       vtkIdList *result);
00216   
00221   virtual vtkIdList *GetPointsInBucket(const float x[3], int ijk[3]);
00222 
00224 
00226   void Initialize();
00227   void FreeSearchStructure();
00228   void BuildLocator();
00229   void GenerateRepresentation(int level, vtkPolyData *pd);
00231 
00232 protected:
00233   vtkPointLocator();
00234   ~vtkPointLocator();
00235 
00236   // place points in appropriate buckets
00237   void GetBucketNeighbors(vtkNeighborPoints* buckets,
00238                           const int ijk[3], const int ndivs[3], int level);
00239   void GetOverlappingBuckets(vtkNeighborPoints* buckets, 
00240                              const float x[3], const int ijk[3], float dist,
00241                              int level);
00242   void GetOverlappingBuckets(vtkNeighborPoints* buckets,
00243                              const float x[3], float dist,
00244                              int prevMinLevel[3],
00245                              int prevMaxLevel[3]);
00246   void GenerateFace(int face, int i, int j, int k, 
00247                     vtkPoints *pts, vtkCellArray *polys);
00248   float Distance2ToBucket(const float x[3], const int nei[3]);
00249   float Distance2ToBounds(const float x[3], const float bounds[6]);
00250 
00251   vtkPoints *Points; // Used for merging points
00252   int Divisions[3]; // Number of sub-divisions in x-y-z directions
00253   int NumberOfPointsPerBucket; //Used with previous boolean to control subdivide
00254   float Bounds[6]; // bounds of points
00255   vtkIdList **HashTable; // lists of point ids in buckets
00256   vtkIdType NumberOfBuckets; // total size of hash table
00257   float H[3]; // width of each bucket in x-y-z directions
00258 
00259   float InsertionTol2;
00260   vtkIdType InsertionPointId;
00261 
00262   float InsertionLevel; 
00263 private:
00264   vtkPointLocator(const vtkPointLocator&);  // Not implemented.
00265   void operator=(const vtkPointLocator&);  // Not implemented.
00266 };
00267 
00268 #endif
00269 
00270 

Generated on Thu Mar 28 14:19:16 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001