Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkPointSetToListAdaptor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Insight Segmentation & Registration Toolkit
00004 Module:    $RCSfile: itkPointSetToListAdaptor.h,v $
00005 Language:  C++
00006 Date:      $Date: 2003/12/15 01:00:46 $
00007 Version:   $Revision: 1.12 $
00008 
00009 Copyright (c) Insight Software Consortium. All rights reserved.
00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012 This software is distributed WITHOUT ANY WARRANTY; without even 
00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014 PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkPointSetToListAdaptor_h
00018 #define __itkPointSetToListAdaptor_h
00019 
00020 #include <typeinfo>
00021 
00022 #include "itkPointSet.h"
00023 #include "itkListSampleBase.h"
00024 #include "itkSmartPointer.h"
00025 
00026 namespace itk{ 
00027 namespace Statistics{
00028 
00042 template < class TPointSet >
00043 class ITK_EXPORT PointSetToListAdaptor :
00044     public ListSampleBase< typename TPointSet::PointType >
00045 {
00046 public:
00048   typedef PointSetToListAdaptor Self;
00049   typedef ListSampleBase< typename TPointSet::PointType > Superclass ;
00050   typedef SmartPointer< Self > Pointer;
00051   typedef SmartPointer<const Self> ConstPointer;
00052   
00054   itkTypeMacro(PointSetToListAdaptor, ListSampleBase) ;
00055   
00057   itkNewMacro(Self) ;
00058   
00060   itkStaticConstMacro(MeasurementVectorSize, unsigned int,
00061                       TPointSet::PointDimension);
00062 
00064   typedef TPointSet PointSetType;
00065   typedef typename TPointSet::Pointer PointSetPointer ;
00066   typedef typename TPointSet::PointIdentifier InstanceIdentifier;
00067   typedef typename TPointSet::PointsContainerPointer PointsContainerPointer ;
00068   typedef typename TPointSet::PointsContainerIterator PointsContainerIterator ;
00069   typedef typename TPointSet::PointType PointType ;
00070 
00071 
00074   typedef typename Superclass::MeasurementType MeasurementType ;
00075   typedef typename Superclass::MeasurementVectorType MeasurementVectorType;
00076   typedef MeasurementVectorType ValueType ;
00077   typedef typename Superclass::FrequencyType FrequencyType ;
00078 
00080   void SetPointSet(TPointSet* pointSet) ;
00081 
00083   TPointSet* GetPointSet() ;
00084 
00086   unsigned int Size() const ;
00087 
00090   const MeasurementVectorType & GetMeasurementVector(const InstanceIdentifier &id) const;
00091 
00094   void SetMeasurement(const InstanceIdentifier &id, 
00095                       const unsigned int &dim,
00096                       const MeasurementType &value) ;
00097 
00099   FrequencyType GetFrequency(const InstanceIdentifier &id) const ;
00100 
00102   FrequencyType GetTotalFrequency() const ;
00103 
00104  
00105   class Iterator
00106   {
00107   public:
00108     
00109     Iterator(){}
00110     
00111     Iterator(PointsContainerIterator iter)
00112       :m_Iter(iter)
00113     {}
00114     
00115     FrequencyType GetFrequency() const
00116     { return 1 ;}
00117 
00118     const MeasurementVectorType & GetMeasurementVector() const
00119     { return (MeasurementVectorType&) m_Iter.Value() ;} 
00120 
00121     InstanceIdentifier GetInstanceIdentifier() const
00122     { return m_Iter.Index() ;}
00123 
00124     Iterator& operator++()
00125     { ++m_Iter ; return *this ;}
00126     
00127     Iterator& operator--()
00128     { --m_Iter ; return *this ;}
00129 
00130     bool operator!=(const Iterator &it)
00131     { return (m_Iter != it.m_Iter) ;}
00132     
00133     bool operator==(const Iterator &it)
00134     { return (m_Iter == it.m_Iter) ;}
00135     
00136     Iterator& operator = (const Iterator &iter)
00137     { 
00138       m_Iter = iter.m_Iter; 
00139       return iter ;
00140     }
00141 
00142     Iterator(const Iterator &iter)
00143     { m_Iter = iter.m_Iter; }
00144     
00145   private:
00146     PointsContainerIterator m_Iter ;
00147   } ;
00148    
00149  
00150   class ConstIterator
00151   {
00152   public:
00153     
00154     ConstIterator(){}
00155     
00156     ConstIterator(PointsContainerIterator iter)
00157       :m_Iter(iter)
00158     {}
00159     
00160     FrequencyType GetFrequency() const
00161     { return 1 ;}
00162 
00163     const MeasurementVectorType & GetMeasurementVector() const
00164     { return (MeasurementVectorType&) m_Iter.Value() ;} 
00165 
00166     InstanceIdentifier GetInstanceIdentifier() const
00167     { return m_Iter.Index() ;}
00168 
00169     ConstIterator& operator++()
00170     { ++m_Iter ; return *this ;}
00171     
00172     ConstIterator& operator--()
00173     { --m_Iter ; return *this ;}
00174 
00175     bool operator!=(const ConstIterator &it)
00176     { return (m_Iter != it.m_Iter) ;}
00177     
00178     bool operator==(const ConstIterator &it)
00179     { return (m_Iter == it.m_Iter) ;}
00180     
00181     ConstIterator& operator = (const ConstIterator &iter)
00182     { 
00183       m_Iter = iter.m_Iter; 
00184       return iter ;
00185     }
00186 
00187     ConstIterator(const ConstIterator &iter)
00188     { m_Iter = iter.m_Iter; }
00189     
00190   private:
00191     PointsContainerIterator m_Iter ;
00192   } ;
00193    
00195   Iterator Begin()
00196   { 
00197     Iterator iter(m_PointsContainer->Begin());
00198     return iter; 
00199   }
00200   
00202   Iterator End()        
00203   {
00204     Iterator iter(m_PointsContainer->End()); 
00205     return iter; 
00206   }
00207    
00209   ConstIterator Begin() const
00210   { 
00211     ConstIterator iter(m_PointsContainer->Begin());
00212     return iter; 
00213   }
00214   
00216   ConstIterator End() const
00217   {
00218     ConstIterator iter(m_PointsContainer->End()); 
00219     return iter; 
00220   }
00221   
00222 protected:
00223   PointSetToListAdaptor() ;
00224   virtual ~PointSetToListAdaptor() {}
00225   void PrintSelf(std::ostream& os, Indent indent) const;  
00226 
00227 private:
00228   PointSetToListAdaptor(const Self&) ; //purposely not implemented
00229   void operator=(const Self&) ; //purposely not implemented
00230 
00232   mutable PointSetPointer m_PointSet ;
00235   PointsContainerPointer m_PointsContainer ;
00237   mutable PointType m_TempPoint ;
00238 } ; // end of class PointSetToListAdaptor
00239 
00240 } // end of namespace Statistics
00241 } // end of namespace itk
00242 
00243 
00244 #ifndef ITK_MANUAL_INSTANTIATION
00245 #include "itkPointSetToListAdaptor.txx"
00246 #endif
00247 
00248 #endif

Generated at Wed Mar 30 00:07:55 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000