00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __itkPointLocator_h
00021 #define __itkPointLocator_h
00022
00023 #include "itkObject.h"
00024 #include "itkPoint.h"
00025 #include "itkNumericTraits.h"
00026 #include "itkBoundingBox.h"
00027
00028 namespace itk
00029 {
00030
00052 template <
00053 typename TPointIdentifier = unsigned long,
00054 int VPointDimension = 3,
00055 typename TCoordRep = float,
00056 typename TPointsContainer =
00057 VectorContainer< TPointIdentifier,Point<TCoordRep,VPointDimension> >
00058 >
00059 class ITK_EXPORT PointLocator : public Object
00060 {
00061 public:
00063 typedef PointLocator Self;
00064 typedef Object Superclass;
00065 typedef SmartPointer<Self> Pointer;
00066 typedef SmartPointer<const Self> ConstPointer;
00067
00069 itkNewMacro(Self);
00070
00072 itkTypeMacro(PointLocator, Object);
00073
00075 itkStaticConstMacro(PointDimension, unsigned int, VPointDimension);
00076
00079 typedef TPointIdentifier PointIdentifier;
00080 typedef TCoordRep CoordRepType;
00081 typedef TPointsContainer PointsContainer;
00082 typedef typename PointsContainer::Pointer PointsContainerPointer;
00083 typedef Point< CoordRepType, VPointDimension > PointType;
00084
00086 typedef BoundingBox<PointIdentifier,VPointDimension,
00087 CoordRepType,PointsContainer> BoundingBoxType;
00088 typedef typename BoundingBoxType::Pointer BoundingBoxPointer;
00089
00091 itkSetVectorMacro(Divisions,unsigned long,VPointDimension);
00092 itkGetVectorMacro(Divisions,unsigned long,VPointDimension);
00093
00095 itkSetClampMacro(NumberOfPointsPerBucket,
00096 unsigned long,1,NumericTraits<unsigned long>::max());
00097 itkGetMacro(NumberOfPointsPerBucket,unsigned long);
00098
00103 void InitPointInsertion(PointsContainer *newPts, BoundingBoxPointer bbox);
00104
00109 void InitIncrementalPointInsertion(PointsContainer *newPts, BoundingBoxPointer bbox);
00110
00111 #if 0
00112
00115 virtual int FindClosestPoint(float x[3]);
00116 int FindClosestPoint(float x, float y, float z);
00117
00121 virtual int InitPointInsertion(itkPoints *newPts, float bounds[6],
00122 int estSize);
00123
00130 virtual void InsertPoint(int ptId, float x[3]);
00131
00139 virtual int InsertNextPoint(float x[3]);
00140
00144 int IsInsertedPoint(float x, float y, float z)
00145 {
00146 float xyz[3];
00147 xyz[0] = x; xyz[1] = y; xyz[2] = z;
00148 return this->IsInsertedPoint (xyz);
00149 };
00150 virtual int IsInsertedPoint(float x[3]);
00151
00158 virtual int InsertUniquePoint(float x[3], int &ptId);
00159
00162 virtual int FindClosestInsertedPoint(float x[3]);
00163 #endif
00164
00165 protected:
00166 PointLocator();
00167 ~PointLocator();
00168 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00169
00170 #if 0
00171
00172 void GetBucketNeighbors(int ijk[3], int ndivs[3], int level);
00173 void GetOverlappingBuckets(float x[3], int ijk[3], float dist, int level);
00174 void GetOverlappingBuckets(float x[3], float dist, int prevMinLevel[3],
00175 int prevMaxLevel[3]);
00176 void GenerateFace(int face, int i, int j, int k,
00177 itkPoints *pts, itkCellArray *polys);
00178 float Distance2ToBucket(float x[3], int nei[3]);
00179 float Distance2ToBounds(float x[3], float bounds[6]);
00180
00181
00182 float Bounds[6];
00183 itkIdList **HashTable;
00184 int NumberOfBuckets;
00185 float H[3];
00186 itkNeighborPoints *Buckets;
00187
00188 float InsertionTol2;
00189 float InsertionLevel;
00190 #endif
00191
00192 private:
00193 PointLocator(const Self&);
00194 void operator=(const Self&);
00195
00196 unsigned long *m_Divisions;
00197 unsigned long m_NumberOfPointsPerBucket;
00198
00199 PointsContainerPointer m_Points;
00200
00201 };
00202
00203 }
00204
00205 #ifndef ITK_MANUAL_INSTANTIATION
00206 #include "itkPointLocator.txx"
00207 #endif
00208
00209 #endif
00210
00211