00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageFileWriter_h
00018 #define __itkImageFileWriter_h
00019
00020 #include "itkProcessObject.h"
00021 #include "itkImageIOBase.h"
00022 #include "itkExceptionObject.h"
00023 #include "itkSize.h"
00024 #include "itkImageIORegion.h"
00025
00026 namespace itk
00027 {
00028
00030 class ImageFileWriterException : public ExceptionObject
00031 {
00032 public:
00034 itkTypeMacro( ImageFileWriterException, ExceptionObject );
00035
00037 ImageFileWriterException(const char *file, unsigned int line,
00038 const char* message = "Error in IO") :
00039 ExceptionObject(file, line)
00040 {
00041 SetDescription(message);
00042 }
00043
00045 ImageFileWriterException(const std::string &file, unsigned int line,
00046 const char* message = "Error in IO") :
00047 ExceptionObject(file, line)
00048 {
00049 SetDescription(message);
00050 }
00051 };
00052
00053
00075 template <class TInputImage>
00076 class ITK_EXPORT ImageFileWriter : public ProcessObject
00077 {
00078 public:
00080 typedef ImageFileWriter Self;
00081 typedef ProcessObject Superclass;
00082 typedef SmartPointer<Self> Pointer;
00083 typedef SmartPointer<const Self> ConstPointer;
00084
00086 itkNewMacro(Self);
00087
00089 itkTypeMacro(ImageFileWriter,ProcessObject);
00090
00092 typedef TInputImage InputImageType;
00093 typedef typename InputImageType::Pointer InputImagePointer;
00094 typedef typename InputImageType::RegionType InputImageRegionType;
00095 typedef typename InputImageType::PixelType InputImagePixelType;
00096
00098 void SetInput(const InputImageType *input);
00099 const InputImageType * GetInput(void);
00100 const InputImageType * GetInput(unsigned int idx);
00101
00103 itkSetStringMacro(FileName);
00104 itkGetStringMacro(FileName);
00105
00112 itkSetObjectMacro(ImageIO,ImageIOBase);
00113 itkGetObjectMacro(ImageIO,ImageIOBase);
00114
00122 virtual void Write(void);
00123
00126 void SetIORegion(const ImageIORegion & region);
00127 itkGetConstReferenceMacro( IORegion, ImageIORegion );
00128
00131 virtual void Update()
00132 {this->Write();}
00133
00135 itkSetMacro(UseCompression,bool);
00136 itkGetConstReferenceMacro(UseCompression,bool);
00137 itkBooleanMacro(UseCompression);
00138
00145 itkSetMacro(UseInputMetaDataDictionary,bool);
00146 itkGetConstReferenceMacro(UseInputMetaDataDictionary,bool);
00147 itkBooleanMacro(UseInputMetaDataDictionary);
00148
00149
00150 protected:
00151 ImageFileWriter();
00152 ~ImageFileWriter();
00153 void PrintSelf(std::ostream& os, Indent indent) const;
00154
00156 void GenerateData(void);
00157
00158 private:
00159 ImageFileWriter(const Self&);
00160 void operator=(const Self&);
00161
00162 std::string m_FileName;
00163
00164 ImageIOBase::Pointer m_ImageIO;
00165 bool m_UserSpecifiedImageIO;
00166
00167 ImageIORegion m_IORegion;
00168 bool m_UserSpecifiedIORegion;
00169 bool m_UseCompression;
00170 bool m_UseInputMetaDataDictionary;
00171 };
00172
00173
00174 }
00175
00176 #ifndef ITK_MANUAL_INSTANTIATION
00177 #include "itkImageFileWriter.txx"
00178 #endif
00179
00180 #endif // __itkImageFileWriter_h
00181