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: 2004/01/08 00:39:06 $ 00007 Version: $Revision: 1.14 $ 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 "itkIPLFileNameList.h" 00039 //#include "idbm_hdr_def.h" 00040 00041 namespace itk 00042 { 00047 class ITK_EXPORT IPLCommonImageIO : public ImageIOBase 00048 { 00049 public: 00051 typedef IPLCommonImageIO Self; 00052 typedef ImageIOBase Superclass; 00053 typedef SmartPointer<Self> Pointer; 00054 typedef unsigned char U8; 00055 typedef signed char S8; 00056 typedef unsigned short U16; 00057 typedef signed short S16; 00058 typedef unsigned int U32; 00059 typedef signed int S32; 00060 typedef unsigned long U64; 00061 typedef signed long S64; 00062 typedef float F32; 00063 typedef double F64; 00064 00066 itkNewMacro(Self); 00067 00069 itkTypeMacro(IPLCommonImageIO, Superclass); 00070 00071 /*-------- This part of the interfaces deals with reading data. ----- */ 00072 00079 virtual bool CanReadFile(const char* FileNameToRead) ; 00080 00082 virtual void ReadImageInformation(); 00083 00085 virtual const std::type_info& GetPixelType() const; 00086 00088 virtual void Read(void* buffer); 00089 00093 virtual unsigned int GetComponentSize() const; 00094 00095 /*-------- This part of the interfaces deals with writing data. ----- */ 00096 00103 virtual bool CanWriteFile(const char * FileNameToWrite); 00104 00106 virtual void WriteImageInformation(); 00107 00110 virtual void Write(const void* buffer); 00111 00112 00113 protected: 00114 IPLCommonImageIO(); 00115 ~IPLCommonImageIO(); 00116 void PrintSelf(std::ostream& os, Indent indent) const; 00117 00118 int AddElementToList(char const * const filename, const float sliceLocation, const int offset, const int XDim, const int YDim, const int Key1, const int Key2 ); 00119 void sortImageListAscend (); 00120 void sortImageListDescend (); 00121 int statTimeToAscii (void *clock, char *timeString); 00122 virtual struct GEImageHeader *ReadHeader(const char *FileNameToRead); 00123 // 00124 // data members 00125 struct GEImageHeader *m_ImageHeader; 00126 ImageIOBase::ByteOrder m_system_byteOrder; 00127 IPLFileNameList *m_fnlist; 00128 // 00129 // return 0 on success, -1 on failure 00130 int GetStringAt(std::ifstream &f,std::streamoff Offset,char *buf, 00131 size_t amount, bool throw_exception = true); 00132 int GetIntAt(std::ifstream &f,std::streamoff Offset,int *ip, 00133 bool throw_exception = true); 00134 int GetShortAt(std::ifstream &f,std::streamoff Offset,short *ip, 00135 bool throw_exception = true); 00136 int GetFloatAt(std::ifstream &f,std::streamoff Offset,float *ip, 00137 bool throw_exception = true); 00138 int GetDoubleAt(std::ifstream &f,std::streamoff Offset,double *ip, 00139 bool throw_exception = true); 00140 00141 short hdr2Short(char *hdr); 00142 int hdr2Int(char *hdr); 00143 float hdr2Float(char *hdr); 00144 double hdr2Double(char *hdr); 00145 private: 00146 IPLCommonImageIO(const Self&); //purposely not implemented 00147 void operator=(const Self&); //purposely not implemented 00148 }; 00149 00150 } // end namespace itk 00151 #define RAISE_EXCEPTION() \ 00152 { ExceptionObject exception(__FILE__, __LINE__); \ 00153 exception.SetDescription("File cannot be read"); \ 00154 throw exception; } 00155 00156 #define IOCHECK() \ 00157 if(f.fail()) \ 00158 { \ 00159 if(f.is_open()) \ 00160 f.close(); \ 00161 RAISE_EXCEPTION(); \ 00162 } 00163 00164 00165 #endif // __itkAnalyzeImageIO_h

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