00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageIO_h
00018 #define __itkImageIO_h
00019
00020 #include "itkIntTypes.h"
00021 #include "itkProcessObject.h"
00022 #include "itkObjectFactory.h"
00023 #include "itkImageIOCommon.h"
00024 #include <string>
00025 #include "itkIndent.h"
00026 #include <deque>
00027 #include <ctype.h>
00028
00029 namespace itk
00030 {
00031
00032 class ITK_EXPORT ImageIO : public ProcessObject
00033 {
00034 public:
00036 typedef ImageIO Self;
00037 typedef SmartPointer<Self> Pointer;
00038 typedef ProcessObject Superclass;
00039
00041 itkTypeMacro(ImageIO, Superclass);
00042
00045 virtual void ReadHeader(const std::string fileName="") = 0;
00046
00048 virtual const double* GetOrigin() const =0;
00049
00051 virtual const double* GetSpacing() const =0;
00052
00054 typedef std::deque<std::string> FileExtensionsListType;
00055
00060 virtual FileExtensionsListType& GetSupportedFileExtensions() const = 0;
00061
00063 itkSetStringMacro(FileName);
00064 itkGetStringMacro(FileName);
00065
00070 itkSetStringMacro(FilePrefix);
00071 itkGetStringMacro(FilePrefix);
00072
00074 itkSetStringMacro(FilePattern);
00075 itkGetStringMacro(FilePattern);
00076
00079 itkSetMacro(NumberOfComponents,unsigned int);
00080 itkGetConstMacro(NumberOfComponents,unsigned int);
00081
00084 void* GetFileData();
00085
00088 itkSetMacro(NumberOfDimensions, unsigned int);
00089 itkGetMacro(NumberOfDimensions, unsigned int);
00090
00092 virtual unsigned int GetDimensions(unsigned int i) const;
00093
00096 itkSetMacro(PixelType, AtomicPixelType);
00097 itkGetMacro(PixelType, AtomicPixelType);
00098
00101 virtual unsigned int GetPixelStride () const;
00102
00104 enum ByteOrder {LittleEndian, BigEndian};
00105
00106 protected:
00107 ImageIO();
00108 ~ImageIO();
00109 void PrintSelf(std::ostream& os, Indent indent) const;
00110
00112 bool m_Initialized;
00113
00115 std::string m_FileName;
00116 std::string m_FilePrefix;
00117 std::string m_FilePattern;
00118
00120 AtomicPixelType m_PixelType;
00121
00124 unsigned int m_NumberOfComponents;
00125
00127 unsigned int m_NumberOfDimensions;
00128
00130 unsigned int m_Dimensions[ITK_MAX_DIMENSIONS];
00131
00134 unsigned int m_Strides[ITK_MAX_DIMENSIONS];
00135
00137 void* m_FileData;
00138
00140 virtual void Reset(const bool freeDynamic = true);
00141
00143 void Resize(const unsigned int numDimensions,
00144 const unsigned int* dimensions);
00145
00152 void ComputeStrides();
00153
00155 unsigned int ImageSizeInPixels() const;
00156
00159 unsigned int ImageSizeInComponents() const;
00160
00162 unsigned int ImageSizeInBytes() const;
00163
00166 unsigned int GetComponentStride() const;
00167
00170 unsigned int GetRowStride () const;
00171
00174 unsigned int GetSliceStride () const;
00175
00176 private:
00177 ImageIO(const Self&);
00178 void operator=(const Self&);
00179
00180
00181 };
00182
00183 }
00184
00185 #endif // __itkImageIO_h