ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkPointsLocator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkPointsLocator_h
00019 #define __itkPointsLocator_h
00020 
00021 #include "itkObject.h"
00022 
00023 #include "itkPoint.h"
00024 #include "itkIntTypes.h"
00025 #include "itkKdTree.h"
00026 #include "itkKdTreeGenerator.h"
00027 #include "itkVectorContainer.h"
00028 #include "itkVectorContainerToListSampleAdaptor.h"
00029 
00030 namespace itk
00031 {
00032 
00041 template<typename TPointIdentifier = IdentifierType, int VPointDimension = 3,
00042   typename TCoordRep = float, typename TPointsContainer =
00043   VectorContainer<TPointIdentifier, Point<TCoordRep, VPointDimension> >
00044   >
00045 class ITK_EXPORT PointsLocator : public Object
00046 {
00047 public:
00049   typedef PointsLocator               Self;
00050   typedef Object                      Superclass;
00051   typedef SmartPointer<Self>          Pointer;
00052   typedef SmartPointer<const Self>    ConstPointer;
00053 
00055   itkNewMacro( Self );
00056 
00058   itkTypeMacro( PointsLocator, Object );
00059 
00061   typedef TPointIdentifier                       PointIdentifier;
00062   typedef TCoordRep                              CoordRepType;
00063   typedef TPointsContainer                       PointsContainer;
00064   typedef typename PointsContainer::Pointer      PointsContainerPointer;
00065   typedef typename PointsContainer::ConstPointer PointsContainerConstPointer;
00066 
00067   typedef Point<CoordRepType, VPointDimension>   PointType;
00068 
00070   itkStaticConstMacro( PointDimension, unsigned int,  VPointDimension );
00071 
00073   typedef typename PointsContainer::ConstIterator PointsContainerConstIterator;
00074   typedef typename PointsContainer::Iterator      PointsContainerIterator;
00075 
00077   typedef Statistics::VectorContainerToListSampleAdaptor
00078     <PointsContainer>                                   SampleAdaptorType;
00079   typedef typename SampleAdaptorType::Pointer           SampleAdaptorPointer;
00080 
00082   typedef Statistics::KdTreeGenerator<SampleAdaptorType>    TreeGeneratorType;
00083   typedef typename TreeGeneratorType::Pointer               TreeGeneratorPointer;
00084   typedef typename TreeGeneratorType::KdTreeType            TreeType;
00085   typedef typename TreeType::ConstPointer                   TreeConstPointer;
00086   typedef typename TreeType::InstanceIdentifierVectorType   NeighborsIdentifierType;
00087 
00089   itkSetObjectMacro( Points, PointsContainer );
00090 
00092   itkGetConstObjectMacro( Points, PointsContainer );
00093 
00095   void Initialize();
00096 
00098   PointIdentifier FindClosestPoint( const PointType &query ) const;
00099 
00101   void Search( const PointType &, unsigned int, NeighborsIdentifierType & )
00102     const;
00103 
00105   void FindClosestNPoints( const PointType &, unsigned int,
00106     NeighborsIdentifierType & ) const;
00107 
00109   void Search( const PointType &, double, NeighborsIdentifierType & ) const;
00110 
00112   void FindPointsWithinRadius( const PointType &, double,
00113     NeighborsIdentifierType & ) const;
00114 
00115 protected:
00116   PointsLocator();
00117   ~PointsLocator();
00118   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00119 
00120 private:
00121   PointsLocator( const Self& ); //purposely not implemented
00122   void operator=( const Self& ); //purposely not implemented
00123 
00124   PointsContainerPointer   m_Points;
00125   SampleAdaptorPointer     m_SampleAdaptor;
00126   TreeGeneratorPointer     m_KdTreeGenerator;
00127   TreeConstPointer         m_Tree;
00128 };
00129 
00130 } // end namespace itk
00131 
00132 #ifndef ITK_MANUAL_INSTANTIATION
00133 #include "itkPointsLocator.hxx"
00134 #endif
00135 
00136 #endif
00137