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

itkImageIOBase.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkImageIOBase.h,v $ 00005 Language: C++ 00006 Date: $Date: 2004/01/08 00:39:06 $ 00007 Version: $Revision: 1.29 $ 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 __itkImageIOBase_h 00018 #define __itkImageIOBase_h 00019 00020 #include "itkLightProcessObject.h" 00021 #include "itkObjectFactory.h" 00022 #include "itkIndent.h" 00023 #include "itkImageIORegion.h" 00024 #include <string> 00025 00026 namespace itk 00027 { 00028 00055 class ITK_EXPORT ImageIOBase : public LightProcessObject 00056 { 00057 public: 00059 typedef ImageIOBase Self; 00060 typedef LightProcessObject Superclass; 00061 typedef SmartPointer<Self> Pointer; 00062 00064 itkTypeMacro(ImageIOBase, Superclass); 00065 00067 itkSetStringMacro(FileName); 00068 itkGetStringMacro(FileName); 00069 00071 class UnknownType {}; 00072 00075 typedef enum {UNKNOWN,UCHAR,CHAR,USHORT,SHORT,UINT,INT, 00076 ULONG,LONG, FLOAT,DOUBLE, 00077 RGB,RGBA,OFFSET,VECTOR,POINT,COVARIANTVECTOR} IODataType; 00078 00082 void SetNumberOfDimensions(unsigned int); 00083 itkGetMacro(NumberOfDimensions, unsigned int); 00084 00088 virtual void SetDimensions(unsigned int i, unsigned int dim); 00089 virtual unsigned int GetDimensions(unsigned int i) const 00090 { return m_Dimensions[i]; } 00091 00094 virtual void SetOrigin(unsigned int i, double origin); 00095 virtual double GetOrigin(unsigned int i) const 00096 { return m_Origin[i]; } 00097 00100 virtual void SetSpacing(unsigned int i, double spacing); 00101 virtual double GetSpacing(unsigned int i) const 00102 { return m_Spacing[i]; } 00103 00110 itkSetMacro(IORegion, ImageIORegion); 00111 itkGetMacro(IORegion, ImageIORegion); 00112 00117 virtual const std::type_info& GetPixelType() const; 00118 virtual void SetPixelType(const IODataType ctype); 00119 00123 virtual bool SetPixelType(const std::type_info& ptype); 00124 00128 itkSetMacro(ComponentType,IODataType); 00129 itkGetMacro(ComponentType,IODataType); 00130 00133 itkSetMacro(NumberOfComponents,unsigned int); 00134 itkGetMacro(NumberOfComponents,unsigned int); 00135 00138 std::string ReturnTypeAsString(IODataType) const; 00139 00142 typedef enum {ASCII,Binary,TypeNotApplicable} FileType; 00143 00146 typedef enum {BigEndian,LittleEndian,OrderNotApplicable} ByteOrder; 00147 00150 itkSetMacro(FileType,FileType); 00151 itkGetConstMacro(FileType,FileType); 00152 void SetFileTypeToASCII() 00153 { this->SetFileType(ASCII); } 00154 void SetFileTypeToBinary() 00155 { this->SetFileType(Binary); } 00156 00168 itkSetMacro(ByteOrder,ByteOrder); 00169 itkGetConstMacro(ByteOrder,ByteOrder); 00170 void SetByteOrderToBigEndian() 00171 { this->SetByteOrder(BigEndian); } 00172 void SetByteOrderToLittleEndian() 00173 { this->SetByteOrder(LittleEndian); } 00174 00177 virtual unsigned int GetPixelStride () const; 00178 00180 unsigned int GetImageSizeInPixels() const; 00181 00183 unsigned int GetImageSizeInBytes() const; 00184 00187 unsigned int GetImageSizeInComponents() const; 00188 00189 /*-------- This part of the interfaces deals with reading data ----- */ 00190 00193 virtual bool CanReadFile(const char*) = 0; 00194 00197 virtual bool CanStreamRead() { return false; }; 00198 00201 virtual void ReadImageInformation() = 0; 00202 00204 virtual void Read(void* buffer) = 0; 00205 00206 00207 /*-------- This part of the interfaces deals with writing data ----- */ 00208 00211 virtual bool CanWriteFile(const char*) = 0; 00212 00215 virtual bool CanStreamWrite() { return false; }; 00216 00219 virtual void WriteImageInformation() = 0; 00220 00224 virtual void Write( const void* buffer) = 0; 00225 00226 /* --- Support reading and writing data as a series of files. --- */ 00227 00233 virtual bool SupportsDimension(unsigned long dim) 00234 {return (dim == 2);} 00235 00236 protected: 00237 ImageIOBase(); 00238 ~ImageIOBase(); 00239 void PrintSelf(std::ostream& os, Indent indent) const; 00240 00242 const std::type_info& ConvertToTypeInfo(IODataType ) const; 00243 unsigned int GetSizeOfType(IODataType ) const; 00244 00246 IODataType m_PixelType; 00247 00250 IODataType m_ComponentType; 00251 00253 ByteOrder m_ByteOrder; 00254 FileType m_FileType; 00255 00257 bool m_Initialized; 00258 00260 std::string m_FileName; 00261 00264 unsigned int m_NumberOfComponents; 00265 00267 unsigned int m_NumberOfDimensions; 00268 00271 ImageIORegion m_IORegion; 00272 00274 std::vector<unsigned int> m_Dimensions; 00275 00278 std::vector<double> m_Spacing; 00279 00281 std::vector<double> m_Origin; 00282 00285 std::vector<unsigned int> m_Strides; 00286 00288 virtual void Reset(const bool freeDynamic = true); 00289 00291 void Resize(const unsigned int numDimensions, 00292 const unsigned int* dimensions); 00293 00300 void ComputeStrides(); 00301 00304 virtual unsigned int GetPixelSize() const; 00305 00310 virtual unsigned int GetComponentSize() const; 00311 00314 unsigned int GetComponentStride() const; 00315 00318 unsigned int GetRowStride () const; 00319 00322 unsigned int GetSliceStride () const; 00323 00325 void WriteBufferAsASCII(std::ostream& os, const void *buffer, IODataType ctype, 00326 unsigned int numComp); 00327 00329 void ReadBufferAsASCII(std::istream& os, void *buffer, IODataType ctype, 00330 unsigned int numComp); 00331 00333 bool ReadBufferAsBinary(std::istream& os, void *buffer, unsigned int numComp); 00334 00335 private: 00336 ImageIOBase(const Self&); //purposely not implemented 00337 void operator=(const Self&); //purposely not implemented 00338 00339 }; 00340 00341 } // end namespace itk 00342 00343 #endif // __itkImageIOBase_h

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