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

itkRawImageIO.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkRawImageIO.h,v $ 00005 Language: C++ 00006 Date: $Date: 2004/01/08 00:39:07 $ 00007 Version: $Revision: 1.27 $ 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 #ifndef __itkRawImageIO_h 00018 #define __itkRawImageIO_h 00019 00020 #include <fstream> 00021 #include "itkImageIOBase.h" 00022 #include "itkIndex.h" 00023 #include "itkImageRegion.h" 00024 #include "itkPixelTraits.h" 00025 #include "itkByteSwapper.h" 00026 #include "itkVersion.h" 00027 #include <string> 00028 00029 00030 namespace itk 00031 { 00032 00047 template <class TPixel, unsigned int VImageDimension=2> 00048 class ITK_EXPORT RawImageIO : public ImageIOBase 00049 { 00050 public: 00052 typedef RawImageIO Self; 00053 typedef ImageIOBase Superclass; 00054 typedef SmartPointer<Self> Pointer; 00055 00057 itkNewMacro(Self); 00058 00060 itkTypeMacro(RawImageIO, ImageIOBase); 00061 00064 typedef TPixel PixelType; 00065 00067 typedef typename PixelTraits<PixelType>::ValueType ComponentType; 00068 00070 typedef ByteSwapper<ComponentType> ByteSwapperType; 00071 00072 00075 void SetHeaderSize(unsigned long size); 00076 unsigned long GetHeaderSize(); 00077 00081 itkSetMacro(FileDimensionality, unsigned long); 00082 itkGetMacro(FileDimensionality, unsigned long); 00083 00085 virtual const std::type_info& GetPixelType() const 00086 {return typeid(PixelType);} 00087 00091 virtual unsigned int GetComponentSize() const 00092 {return sizeof(typename PixelTraits<PixelType>::ValueType);} 00093 00099 virtual bool SupportsDimension(unsigned long dim) 00100 {return (dim == m_FileDimensionality);} 00101 00102 /*-------- This part of the interface deals with reading data. ------ */ 00103 00107 virtual bool CanReadFile(const char*) 00108 {return false;} 00109 00112 virtual void ReadImageInformation() 00113 {return;} 00114 00116 virtual void Read(void* buffer); 00117 00119 itkGetConstMacro(ImageMask,unsigned short); 00120 void SetImageMask(unsigned long val) 00121 { 00122 if (val == m_ImageMask) { return; } 00123 m_ImageMask = ((unsigned short)(val)); 00124 this->Modified(); 00125 } 00126 00128 virtual void ReadHeader (const std::string = std::string()) {} 00129 00130 /*-------- This part of the interfaces deals with writing data. ----- */ 00131 00135 virtual bool CanWriteFile(const char*); 00136 00138 virtual void WriteImageInformation(void) 00139 {return;} 00140 00141 00143 virtual void Write(const void* buffer); 00144 00145 00146 virtual bool SetPixelType(const std::type_info& ) 00147 { return true; } 00148 00149 virtual void SetPixelType(const IODataType ) {} 00150 protected: 00151 RawImageIO(); 00152 ~RawImageIO(); 00153 void PrintSelf(std::ostream& os, Indent indent) const; 00154 00155 //void ComputeInternalFileName(unsigned long slice); 00156 void OpenFileForReading(std::ifstream& is); 00157 void OpenFileForWriting(std::ofstream& os); 00158 00159 private: 00160 RawImageIO(const Self&); //purposely not implemented 00161 void operator=(const Self&); //purposely not implemented 00162 00163 std::string m_InternalFileName; 00164 00165 unsigned long m_FileDimensionality; 00166 bool m_ManualHeaderSize; 00167 unsigned long m_HeaderSize; 00168 unsigned short m_ImageMask; 00169 }; 00170 00171 00172 00173 00174 00175 template <class TPixel, unsigned int VImageDimension> 00176 class ITK_EXPORT RawImageIOFactory : public ObjectFactoryBase 00177 { 00178 public: 00180 typedef RawImageIOFactory<TPixel,VImageDimension> Self; 00181 typedef ObjectFactoryBase Superclass; 00182 typedef SmartPointer<Self> Pointer; 00183 typedef SmartPointer<const Self> ConstPointer; 00184 00186 const char* GetITKSourceVersion(void) const 00187 { 00188 return ITK_SOURCE_VERSION; 00189 } 00190 00191 const char* GetDescription(void) const 00192 { 00193 return "Raw ImageIO Factory, allows the loading of Raw images into insight"; 00194 } 00195 00197 itkFactorylessNewMacro(Self); 00198 00200 itkTypeMacro(RawImageIOFactory, ObjectFactoryBase); 00201 00203 static void RegisterOneFactory(void) 00204 { 00205 ObjectFactoryBase::RegisterFactory( Self::New() ); 00206 } 00207 00208 00209 protected: 00210 RawImageIOFactory() {}; 00211 ~RawImageIOFactory() {}; 00212 typedef RawImageIO<TPixel,VImageDimension> myProductType; 00213 const myProductType* m_MyProduct; 00214 00215 private: 00216 RawImageIOFactory(const Self&); //purposely not implemented 00217 void operator=(const Self&); //purposely not implemented 00218 00219 }; 00220 00221 } // namespace itk 00222 00223 #ifndef ITK_MANUAL_INSTANTIATION 00224 #include "itkRawImageIO.txx" 00225 #endif 00226 00227 #endif

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