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

itkImageBase.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkImageBase.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:10 $ 00007 Version: $Revision: 1.46 $ 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 Portions of this code are covered under the VTK copyright. 00013 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. 00014 00015 This software is distributed WITHOUT ANY WARRANTY; without even 00016 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 PURPOSE. See the above copyright notices for more information. 00018 00019 =========================================================================*/ 00020 #ifndef __itkImageBase_h 00021 #define __itkImageBase_h 00022 00023 #include "itkDataObject.h" 00024 #include "itkProcessObject.h" 00025 #include "itkIndex.h" 00026 #include "itkOffset.h" 00027 #include "itkSize.h" 00028 #include "itkImageRegion.h" 00029 00030 namespace itk 00031 { 00032 00039 template <typename TImage> 00040 struct GetImageDimension 00041 { 00042 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension); 00043 }; 00044 00045 00073 template<unsigned int VImageDimension=2> 00074 class ITK_EXPORT ImageBase : public DataObject 00075 { 00076 public: 00078 typedef ImageBase Self; 00079 typedef DataObject Superclass; 00080 typedef SmartPointer<Self> Pointer; 00081 typedef SmartPointer<const Self> ConstPointer; 00082 00084 itkNewMacro(Self); 00085 00087 itkTypeMacro(ImageBase, DataObject); 00088 00093 itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension ); 00094 00096 typedef Index<VImageDimension> IndexType; 00097 typedef typename IndexType::IndexValueType IndexValueType; 00098 00101 typedef Offset<VImageDimension> OffsetType; 00102 typedef typename OffsetType::OffsetValueType OffsetValueType; 00103 00105 typedef Size<VImageDimension> SizeType; 00106 typedef typename SizeType::SizeValueType SizeValueType; 00107 00109 typedef ImageRegion<VImageDimension> RegionType; 00110 00112 void Initialize(); 00113 00115 static unsigned int GetImageDimension() 00116 { return VImageDimension; } 00117 00122 virtual const double* GetSpacing() const; 00123 00128 virtual const double * GetOrigin() const; 00129 00136 virtual void SetLargestPossibleRegion(const RegionType &region); 00137 00144 virtual const RegionType& GetLargestPossibleRegion() const 00145 { return m_LargestPossibleRegion;}; 00146 00150 virtual void SetBufferedRegion(const RegionType &region); 00151 00155 virtual const RegionType& GetBufferedRegion() const 00156 { return m_BufferedRegion;}; 00157 00165 virtual void SetRequestedRegion(const RegionType &region); 00166 00174 virtual void SetRequestedRegion(DataObject *data); 00175 00180 virtual const RegionType& GetRequestedRegion() const 00181 { return m_RequestedRegion;}; 00182 00192 const OffsetValueType *GetOffsetTable() const { return m_OffsetTable; }; 00193 00196 OffsetValueType ComputeOffset(const IndexType &ind) const 00197 { 00198 // need to add bounds checking for the region/buffer? 00199 OffsetValueType offset=0; 00200 const IndexType &bufferedRegionIndex = m_BufferedRegion.GetIndex(); 00201 00202 // data is arranged as [][][][slice][row][col] 00203 // with Index[0] = col, Index[1] = row, Index[2] = slice 00204 for (int i=VImageDimension-1; i > 0; i--) 00205 { 00206 offset += (ind[i] - bufferedRegionIndex[i])*m_OffsetTable[i]; 00207 } 00208 offset += (ind[0] - bufferedRegionIndex[0]); 00209 00210 return offset; 00211 } 00212 00215 IndexType ComputeIndex(OffsetValueType offset) const 00216 { 00217 IndexType index; 00218 const IndexType &bufferedRegionIndex = m_BufferedRegion.GetIndex(); 00219 00220 for (int i=VImageDimension-1; i > 0; i--) 00221 { 00222 index[i] = static_cast<IndexValueType>(offset / m_OffsetTable[i]); 00223 offset -= (index[i] * m_OffsetTable[i]); 00224 index[i] += bufferedRegionIndex[i]; 00225 } 00226 index[0] = bufferedRegionIndex[0] + static_cast<IndexValueType>(offset); 00227 00228 return index; 00229 } 00230 00240 virtual void CopyInformation(const DataObject *data); 00241 00249 virtual void UpdateOutputInformation(); 00250 00254 virtual void SetRequestedRegionToLargestPossibleRegion(); 00255 00265 virtual bool RequestedRegionIsOutsideOfTheBufferedRegion(); 00266 00275 virtual bool VerifyRequestedRegion(); 00276 00277 protected: 00278 ImageBase(); 00279 ~ImageBase(); 00280 virtual void PrintSelf(std::ostream& os, Indent indent) const; 00281 00286 void ComputeOffsetTable(); 00287 00288 protected: 00290 double m_Spacing[VImageDimension]; 00291 double m_Origin[VImageDimension]; 00292 private: 00293 ImageBase(const Self&); //purposely not implemented 00294 void operator=(const Self&); //purposely not implemented 00295 00296 OffsetValueType m_OffsetTable[VImageDimension+1]; 00297 00298 RegionType m_LargestPossibleRegion; 00299 RegionType m_RequestedRegion; 00300 RegionType m_BufferedRegion; 00301 }; 00302 00303 00304 } // end namespace itk 00305 00306 #ifndef ITK_MANUAL_INSTANTIATION 00307 #include "itkImageBase.txx" 00308 #endif 00309 00310 #endif 00311

Generated at Sat Mar 31 02:20:53 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000