itkImageFileReader.h
Go to the documentation of this file.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
00034 class ImageFileReaderException : public ExceptionObject
00035 {
00036 public:
00038 itkTypeMacro( ImageFileReaderException, ExceptionObject );
00039
00041 ImageFileReaderException(const char *file, unsigned int line,
00042 const char* message = "Error in IO",
00043 const char* loc = "Unknown") :
00044 ExceptionObject(file, line, message, loc)
00045 {
00046 }
00047
00049 ImageFileReaderException(const std::string &file, unsigned int line,
00050 const char* message = "Error in IO",
00051 const char* loc = "Unknown") :
00052 ExceptionObject(file, line, message, loc)
00053 {
00054 }
00055 };
00057
00058
00091 template <class TOutputImage,
00092 class ConvertPixelTraits=DefaultConvertPixelTraits<
00093 ITK_TYPENAME TOutputImage::IOPixelType > >
00094 class ITK_EXPORT ImageFileReader : public ImageSource<TOutputImage>
00095 {
00096 public:
00098 typedef ImageFileReader Self;
00099 typedef ImageSource<TOutputImage> Superclass;
00100 typedef SmartPointer<Self> Pointer;
00101
00103 itkNewMacro(Self);
00104
00106 itkTypeMacro(ImageFileReader, ImageSource);
00107
00109 typedef typename TOutputImage::SizeType SizeType;
00110
00112 typedef typename TOutputImage::IndexType IndexType;
00113
00115 typedef typename TOutputImage::RegionType ImageRegionType;
00116
00118 typedef typename TOutputImage::InternalPixelType OutputImagePixelType;
00119
00121 itkSetStringMacro(FileName);
00122 itkGetStringMacro(FileName);
00124
00131 void SetImageIO( ImageIOBase * imageIO );
00132 itkGetObjectMacro(ImageIO,ImageIOBase);
00134
00137 virtual void GenerateOutputInformation(void);
00138
00144 virtual void EnlargeOutputRequestedRegion(DataObject *output);
00145
00147 itkSetMacro(UseStreaming,bool);
00148 itkGetConstReferenceMacro(UseStreaming,bool);
00149 itkBooleanMacro(UseStreaming);
00151
00152 protected:
00153 ImageFileReader();
00154 ~ImageFileReader();
00155 void PrintSelf(std::ostream& os, Indent indent) const;
00156
00158 void DoConvertBuffer(void* buffer, unsigned long numberOfPixels);
00159
00165 void TestFileExistanceAndReadability();
00166
00168 virtual void GenerateData();
00169
00170 ImageIOBase::Pointer m_ImageIO;
00171 bool m_UserSpecifiedImageIO;
00172
00173
00174 std::string m_FileName;
00175
00176 bool m_UseStreaming;
00177
00178 private:
00179 ImageFileReader(const Self&);
00180 void operator=(const Self&);
00181 std::string m_ExceptionMessage;
00182
00183
00184
00185 ImageRegionType m_StreamableRegion;
00186 };
00187
00188
00189 }
00190
00191 #ifndef ITK_MANUAL_INSTANTIATION
00192 #include "itkImageFileReader.txx"
00193 #endif
00194
00195 #endif // __itkImageFileReader_h
00196