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 __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
00033 class ImageFileWriterException : public ExceptionObject
00034 {
00035 public:
00037 itkTypeMacro( ImageFileWriterException, ExceptionObject );
00038
00040 ImageFileWriterException(const char *file, unsigned int line,
00041 const char* message = "Error in IO",
00042 const char* loc = "Unknown" ) :
00043 ExceptionObject(file, line, message, loc)
00044 {
00045 }
00046
00048 ImageFileWriterException(const std::string &file, unsigned int line,
00049 const char* message = "Error in IO",
00050 const char* loc = "Unknown" ) :
00051 ExceptionObject(file, line, message, loc)
00052 {
00053 }
00054 };
00056
00057
00079 template <class TInputImage>
00080 class ITK_EXPORT ImageFileWriter : public ProcessObject
00081 {
00082 public:
00084 typedef ImageFileWriter Self;
00085 typedef ProcessObject Superclass;
00086 typedef SmartPointer<Self> Pointer;
00087 typedef SmartPointer<const Self> ConstPointer;
00088
00090 itkNewMacro(Self);
00091
00093 itkTypeMacro(ImageFileWriter,ProcessObject);
00094
00096 typedef TInputImage InputImageType;
00097 typedef typename InputImageType::Pointer InputImagePointer;
00098 typedef typename InputImageType::RegionType InputImageRegionType;
00099 typedef typename InputImageType::PixelType InputImagePixelType;
00100
00102 void SetInput(const InputImageType *input);
00103 const InputImageType * GetInput(void);
00104 const InputImageType * GetInput(unsigned int idx);
00106
00108 itkSetStringMacro(FileName);
00109 itkGetStringMacro(FileName);
00111
00122 void SetImageIO (ImageIOBase* io)
00123 {
00124 if (this->m_ImageIO != io)
00125 {
00126 this->Modified();
00127 this->m_ImageIO = io;
00128 }
00129 m_FactorySpecifiedImageIO = false;
00130 }
00131 itkGetObjectMacro(ImageIO,ImageIOBase);
00133
00141 virtual void Write(void);
00142
00145 void SetIORegion(const ImageIORegion & region);
00146 const ImageIORegion &GetIORegion(void) const
00147 {
00148 return m_PasteIORegion;
00149 }
00151
00152
00155 itkSetMacro(NumberOfStreamDivisions,unsigned int);
00156 itkGetConstReferenceMacro(NumberOfStreamDivisions,unsigned int);
00158
00159
00162 virtual void Update()
00163 {
00164 this->Write();\
00165 }
00166
00168 itkSetMacro(UseCompression,bool);
00169 itkGetConstReferenceMacro(UseCompression,bool);
00170 itkBooleanMacro(UseCompression);
00172
00179 itkSetMacro(UseInputMetaDataDictionary,bool);
00180 itkGetConstReferenceMacro(UseInputMetaDataDictionary,bool);
00181 itkBooleanMacro(UseInputMetaDataDictionary);
00183
00184
00185 protected:
00186 ImageFileWriter();
00187 ~ImageFileWriter();
00188 void PrintSelf(std::ostream& os, Indent indent) const;
00189
00191 void GenerateData(void);
00192
00193 private:
00194 ImageFileWriter(const Self&);
00195 void operator=(const Self&);
00196
00197 std::string m_FileName;
00198
00199 ImageIOBase::Pointer m_ImageIO;
00200 bool m_UserSpecifiedImageIO;
00201
00202
00203 ImageIORegion m_PasteIORegion;
00204 unsigned int m_NumberOfStreamDivisions;
00205 bool m_UserSpecifiedIORegion;
00206
00207 bool m_FactorySpecifiedImageIO;
00208
00209 bool m_UseCompression;
00210 bool m_UseInputMetaDataDictionary;
00211
00212
00213 };
00214
00215
00216 }
00217
00218 #ifndef ITK_MANUAL_INSTANTIATION
00219 #include "itkImageFileWriter.txx"
00220 #endif
00221
00222 #endif // __itkImageFileWriter_h
00223