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 const char* loc = "Unknown" ) :
00040 ExceptionObject(file, line, message, loc)
00041 {
00042 }
00043
00045 ImageFileWriterException(const std::string &file, unsigned int line,
00046 const char* message = "Error in IO",
00047 const char* loc = "Unknown" ) :
00048 ExceptionObject(file, line, message, loc)
00049 {
00050 }
00051 };
00053
00054
00076 template <class TInputImage>
00077 class ITK_EXPORT ImageFileWriter : public ProcessObject
00078 {
00079 public:
00081 typedef ImageFileWriter Self;
00082 typedef ProcessObject Superclass;
00083 typedef SmartPointer<Self> Pointer;
00084 typedef SmartPointer<const Self> ConstPointer;
00085
00087 itkNewMacro(Self);
00088
00090 itkTypeMacro(ImageFileWriter,ProcessObject);
00091
00093 typedef TInputImage InputImageType;
00094 typedef typename InputImageType::Pointer InputImagePointer;
00095 typedef typename InputImageType::RegionType InputImageRegionType;
00096 typedef typename InputImageType::PixelType InputImagePixelType;
00097
00099 void SetInput(const InputImageType *input);
00100 const InputImageType * GetInput(void);
00101 const InputImageType * GetInput(unsigned int idx);
00103
00105 itkSetStringMacro(FileName);
00106 itkGetStringMacro(FileName);
00108
00119 void SetImageIO (ImageIOBase* io)
00120 {
00121 if (this->m_ImageIO != io)
00122 {
00123 this->Modified();
00124 this->m_ImageIO = io;
00125 }
00126 m_FactorySpecifiedImageIO = false;
00127 }
00128 itkGetObjectMacro(ImageIO,ImageIOBase);
00130
00138 virtual void Write(void);
00139
00142 void SetIORegion(const ImageIORegion & region);
00143 itkGetConstReferenceMacro( IORegion, ImageIORegion );
00145
00148 virtual void Update()
00149 {this->Write();}
00150
00152 itkSetMacro(UseCompression,bool);
00153 itkGetConstReferenceMacro(UseCompression,bool);
00154 itkBooleanMacro(UseCompression);
00156
00163 itkSetMacro(UseInputMetaDataDictionary,bool);
00164 itkGetConstReferenceMacro(UseInputMetaDataDictionary,bool);
00165 itkBooleanMacro(UseInputMetaDataDictionary);
00167
00168
00169 protected:
00170 ImageFileWriter();
00171 ~ImageFileWriter();
00172 void PrintSelf(std::ostream& os, Indent indent) const;
00173
00175 void GenerateData(void);
00176
00177 private:
00178 ImageFileWriter(const Self&);
00179 void operator=(const Self&);
00180
00181 std::string m_FileName;
00182
00183 ImageIOBase::Pointer m_ImageIO;
00184 bool m_UserSpecifiedImageIO;
00185
00186 ImageIORegion m_IORegion;
00187 bool m_UserSpecifiedIORegion;
00188
00189 bool m_FactorySpecifiedImageIO;
00190 bool m_UseCompression;
00191 bool m_UseInputMetaDataDictionary;
00192 };
00193
00194
00195 }
00196
00197 #ifndef ITK_MANUAL_INSTANTIATION
00198 #include "itkImageFileWriter.txx"
00199 #endif
00200
00201 #endif // __itkImageFileWriter_h
00202
00203