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: 2007/12/15 13:55:14 $
00007   Version:   $Revision: 1.22 $
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 "itkImageIOBase.h"
00035 #include "itkIPLFileNameList.h"
00036 #include "itkGEImageHeader.h"
00037 
00038 namespace itk
00039 {
00047 class ITK_EXPORT IPLCommonImageIO : public ImageIOBase
00048 {
00049 public:
00051   typedef IPLCommonImageIO    Self;
00052   typedef ImageIOBase         Superclass;
00053   typedef SmartPointer<Self>  Pointer;
00054 
00055   typedef unsigned char  U8;
00056   typedef signed char    S8;
00057   typedef unsigned short U16;
00058   typedef signed short   S16;
00059   typedef unsigned int   U32;
00060   typedef signed int     S32;
00061   typedef unsigned long  U64;
00062   typedef signed long    S64;
00063   typedef float          F32;
00064   typedef double         F64;
00065 
00067   itkNewMacro(Self);
00068 
00070   itkTypeMacro(IPLCommonImageIO, Superclass);
00071 
00072   /*-------- This part of the interfaces deals with reading data. ----- */
00073   
00080   virtual bool CanReadFile(const char* FileNameToRead);
00081 
00083   virtual void ReadImageInformation();
00084 
00086   virtual void ModifyImageInformation() {};
00087 
00089   virtual const std::type_info& GetPixelTypeInfo() const;
00090 
00092   virtual const std::type_info& GetComponentTypeInfo() const;
00093 
00095   virtual void Read(void* buffer);
00096 
00100   virtual unsigned int GetComponentSize() const;
00101 
00102   /*-------- This part of the interfaces deals with writing data. ----- */
00103 
00110   virtual bool CanWriteFile(const char * FileNameToWrite);
00111 
00113   virtual void WriteImageInformation();
00114 
00117   virtual void Write(const void* buffer);
00118 
00120   virtual void SortImageListByNameAscend();
00121 
00123   virtual void SortImageListByNameDescend();
00124 
00125 
00126 protected:
00127   IPLCommonImageIO();
00128   ~IPLCommonImageIO();
00129   void PrintSelf(std::ostream& os, Indent indent) const;
00130 
00131   int AddElementToList(char const * const filename,
00132                        const float sliceLocation,
00133                        const int offset,
00134                        const int XDim,
00135                        const int YDim,
00136                        const int Key1,
00137                        const int Key2 );
00138   void sortImageListAscend ();
00139   void sortImageListDescend ();
00140   int statTimeToAscii (void *clock, char *timeString);
00141   virtual GEImageHeader *ReadHeader(const char *FileNameToRead);
00142   //
00143   // data members
00144   GEImageHeader         *m_ImageHeader;
00145   ImageIOBase::ByteOrder m_SystemByteOrder;
00146   IPLFileNameList       *m_FilenameList;
00147   //
00148   // return 0 on success, -1 on failure
00149   int GetStringAt(std::ifstream &f,std::streamoff Offset,char *buf,
00150                   size_t amount, bool throw_exception = true);
00151   int GetIntAt(std::ifstream &f,std::streamoff Offset,int *ip,
00152                bool throw_exception = true);
00153   int GetShortAt(std::ifstream &f,std::streamoff Offset,short *ip,
00154                  bool throw_exception = true);
00155   int GetFloatAt(std::ifstream &f,std::streamoff Offset,float *ip,
00156                  bool throw_exception = true);
00157   int GetDoubleAt(std::ifstream &f,std::streamoff Offset,double *ip,
00158                   bool throw_exception = true);
00159 
00160   short hdr2Short(char *hdr);
00161   int hdr2Int(char *hdr);
00162   float hdr2Float(char *hdr);
00163   double hdr2Double(char *hdr);
00164 private:
00165   IPLCommonImageIO(const Self&); //purposely not implemented
00166   void operator=(const Self&); //purposely not implemented
00167 };
00168 
00169 } // end namespace itk
00170 #define RAISE_EXCEPTION() \
00171         { ExceptionObject exception(__FILE__, __LINE__); \
00172         exception.SetDescription("File cannot be read"); \
00173         throw exception; }
00174 
00175 #define IOCHECK() \
00176       if(f.fail()) \
00177       { \
00178   if(f.is_open()) \
00179     f.close(); \
00180   RAISE_EXCEPTION(); \
00181       }
00182 
00183 
00184 #endif // __itkAnalyzeImageIO_h
00185 

Generated at Wed Nov 5 22:29:09 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000