VTK
|
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 "vtkIncrementalPointLocator.h" 00045 00046 class vtkCellArray; 00047 class vtkIdList; 00048 class vtkNeighborPoints; 00049 class vtkPoints; 00050 00051 class VTK_FILTERING_EXPORT vtkPointLocator : public vtkIncrementalPointLocator 00052 { 00053 public: 00056 static vtkPointLocator *New(); 00057 00058 vtkTypeMacro(vtkPointLocator,vtkIncrementalPointLocator); 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 00077 virtual vtkIdType FindClosestPoint(const double x[3]); 00078 00080 00084 virtual vtkIdType FindClosestPointWithinRadius( 00085 double radius, const double x[3], double& dist2); 00086 virtual vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], 00087 double inputDataLength, double& dist2); 00089 00094 virtual int InitPointInsertion(vtkPoints *newPts, const double bounds[6]); 00095 00097 00101 virtual int InitPointInsertion(vtkPoints *newPts, const double bounds[6], 00102 vtkIdType estSize); 00104 00112 virtual void InsertPoint(vtkIdType ptId, const double x[3]); 00113 00121 virtual vtkIdType InsertNextPoint(const double x[3]); 00122 00124 00127 vtkIdType IsInsertedPoint(double x, double y, double z) 00128 { 00129 double xyz[3]; 00130 xyz[0] = x; xyz[1] = y; xyz[2] = z; 00131 return this->IsInsertedPoint (xyz); 00132 }; 00133 virtual vtkIdType IsInsertedPoint(const double x[3]); 00135 00143 virtual int InsertUniquePoint(const double x[3], vtkIdType &ptId); 00144 00150 virtual vtkIdType FindClosestInsertedPoint(const double x[3]); 00151 00158 virtual void FindClosestNPoints(int N, const double x[3], vtkIdList *result); 00159 00161 00166 virtual void FindDistributedPoints(int N, const double x[3], 00167 vtkIdList *result, int M); 00168 virtual void FindDistributedPoints(int N, double x, double y, 00169 double z, vtkIdList *result, int M); 00171 00173 00177 virtual void FindPointsWithinRadius(double R, const double x[3], 00178 vtkIdList *result); 00180 00185 virtual vtkIdList *GetPointsInBucket(const double x[3], int ijk[3]); 00186 00188 00189 vtkGetObjectMacro(Points, vtkPoints); 00191 00193 00195 void Initialize(); 00196 void FreeSearchStructure(); 00197 void BuildLocator(); 00198 void GenerateRepresentation(int level, vtkPolyData *pd); 00200 00201 protected: 00202 vtkPointLocator(); 00203 virtual ~vtkPointLocator(); 00204 00205 // place points in appropriate buckets 00206 void GetBucketNeighbors(vtkNeighborPoints* buckets, 00207 const int ijk[3], const int ndivs[3], int level); 00208 void GetOverlappingBuckets(vtkNeighborPoints* buckets, 00209 const double x[3], const int ijk[3], double dist, 00210 int level); 00211 void GetOverlappingBuckets(vtkNeighborPoints* buckets, 00212 const double x[3], double dist, 00213 int prevMinLevel[3], 00214 int prevMaxLevel[3]); 00215 void GenerateFace(int face, int i, int j, int k, 00216 vtkPoints *pts, vtkCellArray *polys); 00217 double Distance2ToBucket(const double x[3], const int nei[3]); 00218 double Distance2ToBounds(const double x[3], const double bounds[6]); 00219 00220 vtkPoints *Points; // Used for merging points 00221 int Divisions[3]; // Number of sub-divisions in x-y-z directions 00222 int NumberOfPointsPerBucket; //Used with previous boolean to control subdivide 00223 vtkIdList **HashTable; // lists of point ids in buckets 00224 vtkIdType NumberOfBuckets; // total size of hash table 00225 double H[3]; // width of each bucket in x-y-z directions 00226 00227 double InsertionTol2; 00228 vtkIdType InsertionPointId; 00229 00230 double InsertionLevel; 00231 private: 00232 vtkPointLocator(const vtkPointLocator&); // Not implemented. 00233 void operator=(const vtkPointLocator&); // Not implemented. 00234 }; 00235 00236 #endif 00237 00238