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 __itkImageSeriesWriter_h
00018 #define __itkImageSeriesWriter_h
00019
00020 #include "itkProcessObject.h"
00021 #include "itkImageIOBase.h"
00022 #include "itkExceptionObject.h"
00023 #include "itkSize.h"
00024 #include "itkImageRegion.h"
00025 #include "itkImageFileWriter.h"
00026 #include <vector>
00027 #include <string>
00028
00029 namespace itk
00030 {
00031
00034 class ImageSeriesWriterException : public ExceptionObject
00035 {
00036 public:
00038 itkTypeMacro( ImageSeriesWriterException, ExceptionObject );
00039
00041 ImageSeriesWriterException(char *file, unsigned int line,
00042 const char* message = "Error in IO") :
00043 ExceptionObject(file, line)
00044 {
00045 SetDescription(message);
00046 }
00047
00049 ImageSeriesWriterException(const std::string &file, unsigned int line,
00050 const char* message = "Error in IO") :
00051 ExceptionObject(file, line)
00052 {
00053 SetDescription(message);
00054 }
00055 };
00057
00058
00080 template <class TInputImage, class TOutputImage>
00081 class ITK_EXPORT ImageSeriesWriter : public ProcessObject
00082 {
00083 public:
00085 typedef ImageSeriesWriter Self;
00086 typedef ProcessObject Superclass;
00087 typedef SmartPointer<Self> Pointer;
00088 typedef SmartPointer<const Self> ConstPointer;
00089
00091 itkNewMacro(Self);
00092
00094 itkTypeMacro(ImageSeriesWriter,ProcessObject);
00095
00097 typedef TInputImage InputImageType;
00098 typedef typename InputImageType::RegionType InputImageRegionType;
00099 typedef TOutputImage OutputImageType;
00100 typedef typename OutputImageType::RegionType OutputImageRegionType;
00101 typedef ImageFileWriter<TOutputImage> WriterType;
00102 typedef std::vector< std::string > FileNamesContainer;
00103
00105 typedef MetaDataDictionary DictionaryType;
00106 typedef MetaDataDictionary * DictionaryRawPointer;
00107 typedef std::vector< DictionaryRawPointer > DictionaryArrayType;
00108 typedef const DictionaryArrayType * DictionaryArrayRawPointer;
00109
00111 void SetInput(const InputImageType *input);
00112 const InputImageType *GetInput(void);
00113 const InputImageType *GetInput(unsigned int idx);
00115
00122 itkSetObjectMacro(ImageIO,ImageIOBase);
00123 itkGetObjectMacro(ImageIO,ImageIOBase);
00125
00130 virtual void Write(void);
00131
00134 virtual void Update()
00135 {
00136 this->Write();
00137 }
00138
00141 itkSetMacro(StartIndex,unsigned long);
00142 itkGetConstMacro(StartIndex,unsigned long);
00144
00147 itkSetMacro(IncrementIndex,unsigned long);
00148 itkGetConstMacro(IncrementIndex,unsigned long);
00150
00155 itkSetStringMacro(SeriesFormat);
00156 itkGetStringMacro(SeriesFormat);
00158
00161 void SetFileNames (const FileNamesContainer &name)
00162 {
00163 if ( m_FileNames != name)
00164 {
00165 m_FileNames = name;
00166 this->Modified();
00167 }
00168 }
00169 const FileNamesContainer & GetFileNames() const
00170 {
00171 return m_FileNames;
00172 }
00174
00177 void SetFileName (std::string const &name)
00178 {
00179 m_FileNames.clear();
00180 m_FileNames.push_back(name);
00181 this->Modified();
00182 }
00184
00187 void AddFileName (std::string const &name)
00188 {
00189 m_FileNames.push_back(name);
00190 this->Modified();
00191 }
00193
00196 itkSetMacro( MetaDataDictionaryArray, DictionaryArrayRawPointer);
00197
00199 itkSetMacro(UseCompression,bool);
00200 itkGetConstReferenceMacro(UseCompression,bool);
00201 itkBooleanMacro(UseCompression);
00203
00204 protected:
00205 ImageSeriesWriter();
00206 ~ImageSeriesWriter();
00207 void PrintSelf(std::ostream& os, Indent indent) const;
00208
00210 void GenerateData(void);
00211
00214 void GenerateNumericFileNamesAndWrite(void);
00215
00216 ImageIOBase::Pointer m_ImageIO;
00217 bool m_UserSpecifiedImageIO;
00218
00219
00220 private:
00221 ImageSeriesWriter(const Self&);
00222 void operator=(const Self&);
00223
00225 FileNamesContainer m_FileNames;
00226
00232 std::string m_SeriesFormat;
00233 unsigned long m_StartIndex;
00234 unsigned long m_IncrementIndex;
00235
00236 bool m_UseCompression;
00237
00239 DictionaryArrayRawPointer m_MetaDataDictionaryArray;
00240
00241
00242
00243
00244 void GenerateNumericFileNames(void);
00245 void WriteFiles();
00246 };
00247
00248
00249 }
00250
00251 #ifndef ITK_MANUAL_INSTANTIATION
00252 #include "itkImageSeriesWriter.txx"
00253 #endif
00254
00255 #endif // __itkImageSeriesWriter_h
00256