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

itkImageToListAdaptor.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkImageToListAdaptor.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/12/15 01:00:46 $ 00007 Version: $Revision: 1.27 $ 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 __itkImageToListAdaptor_h 00018 #define __itkImageToListAdaptor_h 00019 00020 #include <typeinfo> 00021 00022 #include "itkImage.h" 00023 #include "itkPixelTraits.h" 00024 #include "itkListSampleBase.h" 00025 #include "itkSmartPointer.h" 00026 #include "itkImageRegionIterator.h" 00027 #include "itkFixedArray.h" 00028 #include "itkMacro.h" 00029 00030 namespace itk{ 00031 namespace Statistics{ 00032 00062 template < class TImage, 00063 class TMeasurementVector = 00064 ITK_TYPENAME TImage::PixelType > 00065 class ITK_EXPORT ImageToListAdaptor : 00066 public ListSampleBase< TMeasurementVector > 00067 { 00068 public: 00070 typedef ImageToListAdaptor Self; 00071 typedef ListSampleBase< TMeasurementVector > Superclass; 00072 typedef SmartPointer< Self > Pointer; 00073 typedef SmartPointer<const Self> ConstPointer; 00074 00076 itkTypeMacro(ImageToListAdaptor, ListSampleBase) ; 00077 00079 itkNewMacro(Self) ; 00080 00082 typedef TImage ImageType; 00083 typedef typename ImageType::Pointer ImagePointer ; 00084 typedef typename ImageType::ConstPointer ImageConstPointer ; 00085 typedef typename ImageType::IndexType IndexType ; 00086 typedef typename ImageType::PixelType PixelType ; 00087 typedef typename ImageType::PixelContainerConstPointer PixelContainerConstPointer ; 00088 typedef typename ImageType::PixelContainer::ElementIdentifier 00089 InstanceIdentifier; 00090 00092 typedef ImageRegionIterator< ImageType > IteratorType ; 00093 typedef PixelTraits< typename TImage::PixelType > PixelTraitsType ; 00094 00096 itkStaticConstMacro(MeasurementVectorSize, unsigned int, 00097 PixelTraitsType::Dimension); 00098 00101 typedef typename PixelTraitsType::ValueType MeasurementType ; 00102 typedef typename Superclass::FrequencyType FrequencyType ; 00103 00104 typedef TMeasurementVector MeasurementVectorType ; 00105 typedef MeasurementVectorType ValueType ; 00106 00108 void SetImage(const TImage* image) ; 00109 00111 const TImage* GetImage() const; 00112 00114 unsigned int Size() const ; 00115 00116 inline virtual const MeasurementVectorType & GetMeasurementVector(const InstanceIdentifier &id) const; 00117 00118 inline FrequencyType GetFrequency(const InstanceIdentifier &id) const ; 00119 00120 FrequencyType GetTotalFrequency() const ; 00121 00122 00123 class Iterator 00124 { 00125 public: 00126 00127 Iterator(){} 00128 00129 Iterator(InstanceIdentifier id, Pointer pContainer) 00130 :m_Id(id),m_Container(pContainer) 00131 {} 00132 00133 FrequencyType GetFrequency() const 00134 { return 1 ;} 00135 00136 const MeasurementVectorType & GetMeasurementVector() const 00137 { return m_Container->GetMeasurementVector(m_Id) ;} 00138 00139 InstanceIdentifier GetInstanceIdentifier() const 00140 { return m_Id ;} 00141 00142 Iterator& operator++() 00143 { ++m_Id ; return *this ;} 00144 00145 Iterator& operator+() 00146 { m_Id += n; return *this ;} 00147 00148 Iterator& operator+(int n) 00149 { m_Id += n; return *this ;} 00150 00151 Iterator& operator-(int n) 00152 { m_Id -= n; return *this ;} 00153 00154 bool operator!=(const Iterator &it) 00155 { 00156 if (m_Id != it.m_Id) 00157 {return true ;} 00158 00159 if (m_Container != it.m_Container) 00160 { return true ;} 00161 00162 return false ; 00163 } 00164 00165 bool operator==(const Iterator &it) 00166 { return !(*this != it);} 00167 00168 Iterator& operator = (const Iterator &iter) 00169 { 00170 m_Id = iter.m_Id; 00171 m_Container = iter.m_Container ; 00172 return *this ; 00173 } 00174 00175 Iterator(const Iterator &iter) 00176 { 00177 m_Id = iter.m_Id; 00178 m_Container = iter.m_Container ; 00179 } 00180 00181 private: 00182 InstanceIdentifier m_Id; // Current id 00183 Pointer m_Container ; 00184 } ; 00185 00186 00187 class ConstIterator 00188 { 00189 public: 00190 00191 ConstIterator(){} 00192 00193 ConstIterator(InstanceIdentifier id, ConstPointer pContainer) 00194 :m_Id(id),m_Container(pContainer) 00195 {} 00196 00197 FrequencyType GetFrequency() const 00198 { return 1 ;} 00199 00200 const MeasurementVectorType & GetMeasurementVector() const 00201 { return m_Container->GetMeasurementVector(m_Id) ;} 00202 00203 InstanceIdentifier GetInstanceIdentifier() const 00204 { return m_Id ;} 00205 00206 ConstIterator& operator++() 00207 { ++m_Id ; return *this ;} 00208 00209 ConstIterator& operator+() 00210 { m_Id += n; return *this ;} 00211 00212 ConstIterator& operator+(int n) 00213 { m_Id += n; return *this ;} 00214 00215 ConstIterator& operator-(int n) 00216 { m_Id -= n; return *this ;} 00217 00218 bool operator!=(const ConstIterator &it) 00219 { 00220 if (m_Id != it.m_Id) 00221 {return true ;} 00222 00223 if (m_Container != it.m_Container) 00224 { return true ;} 00225 00226 return false ; 00227 } 00228 00229 bool operator==(const ConstIterator &it) 00230 { return !(*this != it);} 00231 00232 ConstIterator& operator = (const ConstIterator &iter) 00233 { 00234 m_Id = iter.m_Id; 00235 m_Container = iter.m_Container ; 00236 return *this ; 00237 } 00238 00239 ConstIterator(const ConstIterator &iter) 00240 { 00241 m_Id = iter.m_Id; 00242 m_Container = iter.m_Container ; 00243 } 00244 00245 private: 00246 InstanceIdentifier m_Id; // Current id 00247 ConstPointer m_Container ; 00248 } ; 00249 00250 00251 00252 Iterator Begin() 00253 { 00254 Iterator iter(0, this); 00255 return iter; 00256 } 00257 00258 Iterator End() 00259 { 00260 Iterator iter(this->Size(), this); 00261 return iter; 00262 } 00263 00264 ConstIterator Begin() const 00265 { 00266 ConstIterator iter(0, this); 00267 return iter; 00268 } 00269 00270 ConstIterator End() const 00271 { 00272 ConstIterator iter(this->Size(), this); 00273 return iter; 00274 } 00275 00276 protected: 00277 ImageToListAdaptor() ; 00278 virtual ~ImageToListAdaptor() {} 00279 void PrintSelf(std::ostream& os, Indent indent) const; 00280 00281 PixelContainerConstPointer m_PixelContainer ; 00282 bool m_UseBuffer ; 00283 typename TImage::IndexType m_ImageBeginIndex ; 00284 typename TImage::IndexType m_ImageEndIndex ; 00285 00286 private: 00287 ImageToListAdaptor(const Self&) ; //purposely not implemented 00288 void operator=(const Self&) ; //purposely not implemented 00289 00290 ImageConstPointer m_Image ; 00291 } ; // end of class ImageToListAdaptor 00292 00293 } // end of namespace Statistics 00294 } // end of namespace itk 00295 00296 #ifndef ITK_MANUAL_INSTANTIATION 00297 #include "itkImageToListAdaptor.txx" 00298 #endif 00299 00300 #endif

Generated at Sun Apr 1 02:35:50 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000