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(const 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
00085 template <class TOutputImage,
00086 class ConvertPixelTraits =
00087 DefaultConvertPixelTraits< ITK_TYPENAME TOutputImage::PixelType> >
00088 class ITK_EXPORT ImageFileReader : public ImageSource<TOutputImage>
00089 {
00090 public:
00092 typedef ImageFileReader Self;
00093 typedef ImageSource<TOutputImage> Superclass;
00094 typedef SmartPointer<Self> Pointer;
00095
00097 itkNewMacro(Self);
00098
00100 itkTypeMacro(ImageFileReader, ImageSource);
00101
00103 typedef typename TOutputImage::SizeType SizeType;
00104
00106 typedef typename TOutputImage::RegionType ImageRegionType;
00107
00109 typedef typename TOutputImage::InternalPixelType OutputImagePixelType;
00110
00112 itkSetStringMacro(FileName);
00113 itkGetStringMacro(FileName);
00114
00121 void SetImageIO( ImageIOBase * imageIO );
00122 itkGetObjectMacro(ImageIO,ImageIOBase);
00123
00126 virtual void GenerateOutputInformation(void);
00127
00133 virtual void EnlargeOutputRequestedRegion(DataObject *output);
00134
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
00150 void TestFileExistanceAndReadability();
00151
00153 virtual void GenerateData();
00154
00155 ImageIOBase::Pointer m_ImageIO;
00156 bool m_UserSpecifiedImageIO;
00157
00159 std::string m_FileName;
00160
00161 private:
00162 ImageFileReader(const Self&);
00163 void operator=(const Self&);
00164
00165 };
00166
00167
00168 }
00169
00170 #ifndef ITK_MANUAL_INSTANTIATION
00171 #include "itkImageFileReader.txx"
00172 #endif
00173
00174 #endif // __itkImageFileReader_h