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

itkIPLCommonImageIO.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkIPLCommonImageIO.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:34 $ 00007 Version: $Revision: 1.9 $ 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 00031 #ifndef __itkIPLCommonImageIO_h 00032 #define __itkIPLCommonImageIO_h 00033 00034 #include <fstream> 00035 #include "itkImageIOBase.h" 00036 #include "itkIOCommon.h" 00037 #include "itkGEImageHeader.h" 00038 //#include "idbm_hdr_def.h" 00039 00040 namespace itk 00041 { 00046 class ITK_EXPORT IPLCommonImageIO : public ImageIOBase 00047 { 00048 public: 00050 typedef IPLCommonImageIO Self; 00051 typedef ImageIOBase Superclass; 00052 typedef SmartPointer<Self> Pointer; 00053 typedef unsigned char U8; 00054 typedef signed char S8; 00055 typedef unsigned short U16; 00056 typedef signed short S16; 00057 typedef unsigned int U32; 00058 typedef signed int S32; 00059 typedef unsigned long U64; 00060 typedef signed long S64; 00061 typedef float F32; 00062 typedef double F64; 00063 00065 itkNewMacro(Self); 00066 00068 itkTypeMacro(IPLCommonImageIO, Superclass); 00069 00070 /*-------- This part of the interfaces deals with reading data. ----- */ 00071 00078 virtual bool CanReadFile(const char* FileNameToRead) ; 00079 00081 virtual void ReadImageInformation(); 00082 00084 virtual const std::type_info& GetPixelType() const; 00085 00087 virtual void Read(void* buffer); 00088 00092 virtual unsigned int GetComponentSize() const; 00093 00094 /*-------- This part of the interfaces deals with writing data. ----- */ 00095 00102 virtual bool CanWriteFile(const char * FileNameToWrite); 00103 00105 virtual void WriteImageInformation(); 00106 00109 virtual void Write(const void* buffer); 00110 enum ENUM_PLANE_SELECTION 00111 { 00112 NO_PLANE = 0, 00113 AXIAL = 1, 00114 CORONAL = 2, 00115 SAGITTAL = 3, 00116 UNKNOWN_PLANE = 5 00117 }; 00118 00119 00120 struct FILESORTINFOSTRUCT { 00121 char imageFileName[itk::IOCommon::ITK_MAXPATHLEN+1]; 00122 float SliceLocation; 00123 int SliceOffset; 00124 int echoNumber; 00125 void * data; 00126 }; 00127 typedef struct FILESORTINFOSTRUCT FILESORTINFO; 00128 protected: 00129 IPLCommonImageIO(); 00130 ~IPLCommonImageIO(); 00131 void PrintSelf(std::ostream& os, Indent indent) const; 00132 00133 00134 00135 struct FILENAMELISTSTRUCT 00136 { 00137 FILESORTINFO Info[itk::IOCommon::MAX_FILENAMELIST_SIZE]; 00138 int XDim; 00139 int YDim; 00140 int Key1; 00141 int Key2; 00142 int numImageInfoStructs; 00143 int maxImageFileNames; 00144 }; 00145 typedef struct FILENAMELISTSTRUCT FILENAMELIST; 00146 void InitializeFILENAMELIST( FILENAMELIST * const fnList ); 00147 int AddElementToList(FILENAMELIST * const fnList,char const * const filename, const float sliceLocation, const int offset, const int XDim, const int YDim, const int Key1, const int Key2 ); 00148 void sortImageListAscend (FILENAMELIST * const fnList); 00149 void sortImageListDescend (FILENAMELIST * const fnList); 00150 int statTimeToAscii (void *clock, char *timeString); 00151 virtual struct GEImageHeader *ReadHeader(const char *FileNameToRead); 00152 // 00153 // data members 00154 struct GEImageHeader *m_ImageHeader; 00155 ImageIOBase::ByteOrder m_system_byteOrder; 00156 FILENAMELIST m_fnlist; 00157 // 00158 // return 0 on success, -1 on failure 00159 int GetStringAt(std::ifstream &f,std::streamoff Offset,char *buf, 00160 size_t amount, bool throw_exception = true); 00161 int GetIntAt(std::ifstream &f,std::streamoff Offset,int *ip, 00162 bool throw_exception = true); 00163 int GetShortAt(std::ifstream &f,std::streamoff Offset,short *ip, 00164 bool throw_exception = true); 00165 int GetFloatAt(std::ifstream &f,std::streamoff Offset,float *ip, 00166 bool throw_exception = true); 00167 int GetDoubleAt(std::ifstream &f,std::streamoff Offset,double *ip, 00168 bool throw_exception = true); 00169 00170 short hdr2Short(char *hdr); 00171 int hdr2Int(char *hdr); 00172 float hdr2Float(char *hdr); 00173 double hdr2Double(char *hdr); 00174 private: 00175 IPLCommonImageIO(const Self&); //purposely not implemented 00176 void operator=(const Self&); //purposely not implemented 00177 }; 00178 00179 } // end namespace itk 00180 #define RAISE_EXCEPTION() \ 00181 { ExceptionObject exception(__FILE__, __LINE__); \ 00182 exception.SetDescription("File cannot be read"); \ 00183 throw exception; } 00184 00185 #define IOCHECK() \ 00186 if(f.fail()) \ 00187 { \ 00188 if(f.is_open()) \ 00189 f.close(); \ 00190 RAISE_EXCEPTION(); \ 00191 } 00192 00193 00194 #endif // __itkAnalyzeImageIO_h

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