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/08/03 23:39:04 $
00007 Version:   $Revision: 1.16 $
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& GetPixelTypeInfo() const;
00086 
00088   virtual const std::type_info& GetComponentTypeInfo() const;
00089   
00091   virtual void Read(void* buffer);
00092 
00096   virtual unsigned int GetComponentSize() const;
00097 
00098   /*-------- This part of the interfaces deals with writing data. ----- */
00099 
00106   virtual bool CanWriteFile(const char * FileNameToWrite);
00107 
00109   virtual void WriteImageInformation();
00110 
00113   virtual void Write(const void* buffer);
00114 
00116   virtual void SortImageListByNameAscend();
00117 
00119   virtual void SortImageListByNameDescend();
00120 
00121 
00122   protected:
00123   IPLCommonImageIO();
00124   ~IPLCommonImageIO();
00125   void PrintSelf(std::ostream& os, Indent indent) const;
00126 
00127   int AddElementToList(char const * const filename, const float sliceLocation, const int offset, const int XDim, const int YDim, const int Key1, const int Key2 );
00128   void sortImageListAscend ();
00129   void sortImageListDescend ();
00130   int statTimeToAscii (void *clock, char *timeString);
00131   virtual struct GEImageHeader *ReadHeader(const char *FileNameToRead);
00132   //
00133   // data members
00134   struct GEImageHeader *m_ImageHeader;
00135   ImageIOBase::ByteOrder m_system_byteOrder;
00136   IPLFileNameList *m_fnlist;
00137   //
00138   // return 0 on success, -1 on failure
00139   int GetStringAt(std::ifstream &f,std::streamoff Offset,char *buf,
00140                   size_t amount, bool throw_exception = true);
00141   int GetIntAt(std::ifstream &f,std::streamoff Offset,int *ip,
00142                bool throw_exception = true);
00143   int GetShortAt(std::ifstream &f,std::streamoff Offset,short *ip,
00144                  bool throw_exception = true);
00145   int GetFloatAt(std::ifstream &f,std::streamoff Offset,float *ip,
00146                  bool throw_exception = true);
00147   int GetDoubleAt(std::ifstream &f,std::streamoff Offset,double *ip,
00148                   bool throw_exception = true);
00149 
00150   short hdr2Short(char *hdr);
00151   int hdr2Int(char *hdr);
00152   float hdr2Float(char *hdr);
00153   double hdr2Double(char *hdr);
00154 private:
00155   IPLCommonImageIO(const Self&); //purposely not implemented
00156   void operator=(const Self&); //purposely not implemented
00157 };
00158 
00159 } // end namespace itk
00160 #define RAISE_EXCEPTION() \
00161         { ExceptionObject exception(__FILE__, __LINE__); \
00162         exception.SetDescription("File cannot be read"); \
00163         throw exception; }
00164 
00165 #define IOCHECK() \
00166       if(f.fail()) \
00167       { \
00168   if(f.is_open()) \
00169     f.close(); \
00170   RAISE_EXCEPTION(); \
00171       }
00172 
00173 
00174 #endif // __itkAnalyzeImageIO_h

Generated at Tue Mar 29 23:59:35 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000