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 const char* loc = "Unknown") :
00041 ExceptionObject(file, line, message, loc)
00042 {
00043 }
00044
00046 ImageFileReaderException(const std::string &file, unsigned int line,
00047 const char* message = "Error in IO",
00048 const char* loc = "Unknown") :
00049 ExceptionObject(file, line, message, loc)
00050 {
00051 }
00052 };
00054
00055
00086 template <class TOutputImage,
00087 class ConvertPixelTraits=DefaultConvertPixelTraits<
00088 ITK_TYPENAME TOutputImage::IOPixelType > >
00089 class ITK_EXPORT ImageFileReader : public ImageSource<TOutputImage>
00090 {
00091 public:
00093 typedef ImageFileReader Self;
00094 typedef ImageSource<TOutputImage> Superclass;
00095 typedef SmartPointer<Self> Pointer;
00096
00098 itkNewMacro(Self);
00099
00101 itkTypeMacro(ImageFileReader, ImageSource);
00102
00104 typedef typename TOutputImage::SizeType SizeType;
00105
00107 typedef typename TOutputImage::RegionType ImageRegionType;
00108
00110 typedef typename TOutputImage::InternalPixelType OutputImagePixelType;
00111
00113 itkSetStringMacro(FileName);
00114 itkGetStringMacro(FileName);
00116
00123 void SetImageIO( ImageIOBase * imageIO );
00124 itkGetObjectMacro(ImageIO,ImageIOBase);
00126
00129 virtual void GenerateOutputInformation(void);
00130
00136 virtual void EnlargeOutputRequestedRegion(DataObject *output);
00137
00138
00139
00140 protected:
00141 ImageFileReader();
00142 ~ImageFileReader();
00143 void PrintSelf(std::ostream& os, Indent indent) const;
00144
00146 void DoConvertBuffer(void* buffer, unsigned long numberOfPixels);
00147
00153 void TestFileExistanceAndReadability();
00154
00156 virtual void GenerateData();
00157
00158 ImageIOBase::Pointer m_ImageIO;
00159 bool m_UserSpecifiedImageIO;
00160
00162 std::string m_FileName;
00163
00164 private:
00165 ImageFileReader(const Self&);
00166 void operator=(const Self&);
00167 std::string m_ExceptionMessage;
00168 };
00169
00170
00171 }
00172
00173 #ifndef ITK_MANUAL_INSTANTIATION
00174 #include "itkImageFileReader.txx"
00175 #endif
00176
00177 #endif // __itkImageFileReader_h
00178