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: 2005/09/28 15:41:55 $
00007 Version:   $Revision: 1.17 $
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 {
00050 class ITK_EXPORT IPLCommonImageIO : public ImageIOBase
00051 {
00052 public:
00054   typedef IPLCommonImageIO            Self;
00055   typedef ImageIOBase  Superclass;
00056   typedef SmartPointer<Self>  Pointer;
00057   typedef unsigned char U8;
00058   typedef signed char S8;
00059   typedef unsigned short U16;
00060   typedef signed short S16;
00061   typedef unsigned int U32;
00062   typedef signed int S32;
00063   typedef unsigned long U64;
00064   typedef signed long S64;
00065   typedef float F32;
00066   typedef double F64;
00067 
00069   itkNewMacro(Self);
00070 
00072   itkTypeMacro(IPLCommonImageIO, Superclass);
00073 
00074   /*-------- This part of the interfaces deals with reading data. ----- */
00075 
00082   virtual bool CanReadFile(const char* FileNameToRead) ;
00083 
00085   virtual void ReadImageInformation();
00086 
00088   virtual const std::type_info& GetPixelTypeInfo() const;
00089 
00091   virtual const std::type_info& GetComponentTypeInfo() const;
00092   
00094   virtual void Read(void* buffer);
00095 
00099   virtual unsigned int GetComponentSize() const;
00100 
00101   /*-------- This part of the interfaces deals with writing data. ----- */
00102 
00109   virtual bool CanWriteFile(const char * FileNameToWrite);
00110 
00112   virtual void WriteImageInformation();
00113 
00116   virtual void Write(const void* buffer);
00117 
00119   virtual void SortImageListByNameAscend();
00120 
00122   virtual void SortImageListByNameDescend();
00123 
00124 
00125   protected:
00126   IPLCommonImageIO();
00127   ~IPLCommonImageIO();
00128   void PrintSelf(std::ostream& os, Indent indent) const;
00129 
00130   int AddElementToList(char const * const filename, const float sliceLocation, const int offset, const int XDim, const int YDim, const int Key1, const int Key2 );
00131   void sortImageListAscend ();
00132   void sortImageListDescend ();
00133   int statTimeToAscii (void *clock, char *timeString);
00134   virtual struct GEImageHeader *ReadHeader(const char *FileNameToRead);
00135   //
00136   // data members
00137   struct GEImageHeader *m_ImageHeader;
00138   ImageIOBase::ByteOrder m_system_byteOrder;
00139   IPLFileNameList *m_fnlist;
00140   //
00141   // return 0 on success, -1 on failure
00142   int GetStringAt(std::ifstream &f,std::streamoff Offset,char *buf,
00143                   size_t amount, bool throw_exception = true);
00144   int GetIntAt(std::ifstream &f,std::streamoff Offset,int *ip,
00145                bool throw_exception = true);
00146   int GetShortAt(std::ifstream &f,std::streamoff Offset,short *ip,
00147                  bool throw_exception = true);
00148   int GetFloatAt(std::ifstream &f,std::streamoff Offset,float *ip,
00149                  bool throw_exception = true);
00150   int GetDoubleAt(std::ifstream &f,std::streamoff Offset,double *ip,
00151                   bool throw_exception = true);
00152 
00153   short hdr2Short(char *hdr);
00154   int hdr2Int(char *hdr);
00155   float hdr2Float(char *hdr);
00156   double hdr2Double(char *hdr);
00157 private:
00158   IPLCommonImageIO(const Self&); //purposely not implemented
00159   void operator=(const Self&); //purposely not implemented
00160 };
00161 
00162 } // end namespace itk
00163 #define RAISE_EXCEPTION() \
00164         { ExceptionObject exception(__FILE__, __LINE__); \
00165         exception.SetDescription("File cannot be read"); \
00166         throw exception; }
00167 
00168 #define IOCHECK() \
00169       if(f.fail()) \
00170       { \
00171   if(f.is_open()) \
00172     f.close(); \
00173   RAISE_EXCEPTION(); \
00174       }
00175 
00176 
00177 #endif // __itkAnalyzeImageIO_h

Generated at Wed May 24 23:29:34 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000