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
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::PixelType
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
protected:
00137 ImageFileReader();
00138 ~ImageFileReader();
00139
void PrintSelf(std::ostream& os,
Indent indent)
const;
00140
00142
void DoConvertBuffer(
void* buffer,
unsigned long numberOfPixels);
00143
00145
virtual void GenerateData();
00146
00147
ImageIOBase::Pointer m_ImageIO;
00148
bool m_UserSpecifiedImageIO;
00149
00151 std::string m_FileName;
00152
00153
private:
00154 ImageFileReader(
const Self&);
00155
void operator=(
const Self&);
00156
00157 };
00158
00159
00160 }
00161
00162
#ifndef ITK_MANUAL_INSTANTIATION
00163
#include "itkImageFileReader.txx"
00164
#endif
00165
00166
#endif // __itkImageFileReader_h