00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageFileReader_h
00018 #define __itkImageFileReader_h
00019
00020 #include "itkImageIOBase.h"
00021 #include "itkImageSource.h"
00022 #include "itkExceptionObject.h"
00023 #include "itkSize.h"
00024 #include "itkImageRegion.h"
00025 #include "itkDefaultConvertPixelTraits.h"
00026
00027 namespace itk
00028 {
00029
00031 class ImageFileReaderException : public ExceptionObject
00032 {
00033 public:
00035 itkTypeMacro( ImageFileReaderException, ExceptionObject );
00036
00038 ImageFileReaderException(char *file, unsigned int line,
00039 const char* message = "Error in IO") :
00040 ExceptionObject(file, line)
00041 {
00042 SetDescription(message);
00043 }
00044
00046 ImageFileReaderException(const std::string &file, unsigned int line,
00047 const char* message = "Error in IO") :
00048 ExceptionObject(file, line)
00049 {
00050 SetDescription(message);
00051 }
00052 };
00053
00054
00073 template <class TOutputImage,
00074 class ConvertPixelTraits =
00075 DefaultConvertPixelTraits< ITK_TYPENAME TOutputImage::PixelType> >
00076 class ITK_EXPORT ImageFileReader : public ImageSource<TOutputImage>
00077 {
00078 public:
00080 typedef ImageFileReader Self;
00081 typedef ImageSource<TOutputImage> Superclass;
00082 typedef SmartPointer<Self> Pointer;
00083
00085 itkNewMacro(Self);
00086
00088 itkTypeMacro(ImageFileReader, ImageSource);
00089
00091 typedef typename TOutputImage::SizeType SizeType;
00092
00094 typedef typename TOutputImage::RegionType ImageRegionType;
00095
00097 typedef typename TOutputImage::PixelType OutputImagePixelType;
00098
00102 itkSetStringMacro(FileName);
00103 itkGetStringMacro(FileName);
00104
00108 itkSetStringMacro(FilePrefix);
00109 itkGetStringMacro(FilePrefix);
00110
00112 itkSetStringMacro(FilePattern);
00113 itkGetStringMacro(FilePattern);
00114
00119 itkSetObjectMacro(ImageIO,ImageIOBase);
00120 itkGetObjectMacro(ImageIO,ImageIOBase);
00121
00124 virtual void GenerateOutputInformation(void);
00125
00126 protected:
00127 ImageFileReader();
00128 ~ImageFileReader();
00129 void PrintSelf(std::ostream& os, Indent indent) const;
00130
00132 void DoConvertBuffer(void* buffer, unsigned long numberOfPixels);
00133
00135 virtual void GenerateData();
00136
00137 ImageIOBase::Pointer m_ImageIO;
00138 bool m_UserSpecified;
00139
00140 std::string m_FileName;
00141 std::string m_FilePrefix;
00142 std::string m_FilePattern;
00143
00144 private:
00145 ImageFileReader(const Self&);
00146 void operator=(const Self&);
00147
00148 };
00149
00150
00151 }
00152
00153 #ifndef ITK_MANUAL_INSTANTIATION
00154 #include "itkImageFileReader.txx"
00155 #endif
00156
00157 #endif // __itkImageFileReader_h