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
00076 template <class TOutputImage,
00077 class ConvertPixelTraits =
00078 DefaultConvertPixelTraits< ITK_TYPENAME TOutputImage::PixelType> >
00079 class ITK_EXPORT ImageFileReader : public ImageSource<TOutputImage>
00080 {
00081 public:
00083 typedef ImageFileReader Self;
00084 typedef ImageSource<TOutputImage> Superclass;
00085 typedef SmartPointer<Self> Pointer;
00086
00088 itkNewMacro(Self);
00089
00091 itkTypeMacro(ImageFileReader, ImageSource);
00092
00094 typedef typename TOutputImage::SizeType SizeType;
00095
00097 typedef typename TOutputImage::RegionType ImageRegionType;
00098
00100 typedef typename TOutputImage::PixelType OutputImagePixelType;
00101
00105 itkSetStringMacro(FileName);
00106 itkGetStringMacro(FileName);
00107
00111 itkSetStringMacro(FilePrefix);
00112 itkGetStringMacro(FilePrefix);
00113
00115 itkSetStringMacro(FilePattern);
00116 itkGetStringMacro(FilePattern);
00117
00122 void SetImageIO( ImageIOBase * imageIO );
00123 itkGetObjectMacro(ImageIO,ImageIOBase);
00124
00127 virtual void GenerateOutputInformation(void);
00128
00134 virtual void EnlargeOutputRequestedRegion(DataObject *output);
00135
00136
00137 protected:
00138 ImageFileReader();
00139 ~ImageFileReader();
00140 void PrintSelf(std::ostream& os, Indent indent) const;
00141
00143 void DoConvertBuffer(void* buffer, unsigned long numberOfPixels);
00144
00146 virtual void GenerateData();
00147
00148 ImageIOBase::Pointer m_ImageIO;
00149 bool m_UserSpecifiedImageIO;
00150
00151 std::string m_FileName;
00152 std::string m_FilePrefix;
00153 std::string m_FilePattern;
00154
00155 private:
00156 ImageFileReader(const Self&);
00157 void operator=(const Self&);
00158
00159 };
00160
00161
00162 }
00163
00164 #ifndef ITK_MANUAL_INSTANTIATION
00165 #include "itkImageFileReader.txx"
00166 #endif
00167
00168 #endif // __itkImageFileReader_h