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
00033 class ImageSeriesWriterException : public ExceptionObject
00034 {
00035 public:
00037 itkTypeMacro( ImageSeriesWriterException, ExceptionObject );
00038
00040 ImageSeriesWriterException(char *file, unsigned int line,
00041 const char* message = "Error in IO") :
00042 ExceptionObject(file, line)
00043 {
00044 SetDescription(message);
00045 }
00046
00048 ImageSeriesWriterException(const std::string &file, unsigned int line,
00049 const char* message = "Error in IO") :
00050 ExceptionObject(file, line)
00051 {
00052 SetDescription(message);
00053 }
00054 };
00056
00057
00079 template <class TInputImage, class TOutputImage>
00080 class ITK_EXPORT ImageSeriesWriter : public ProcessObject
00081 {
00082 public:
00084 typedef ImageSeriesWriter Self;
00085 typedef ProcessObject Superclass;
00086 typedef SmartPointer<Self> Pointer;
00087 typedef SmartPointer<const Self> ConstPointer;
00088
00090 itkNewMacro(Self);
00091
00093 itkTypeMacro(ImageSeriesWriter,ProcessObject);
00094
00096 typedef TInputImage InputImageType;
00097 typedef typename InputImageType::RegionType InputImageRegionType;
00098 typedef TOutputImage OutputImageType;
00099 typedef typename OutputImageType::RegionType OutputImageRegionType;
00100 typedef ImageFileWriter<TOutputImage> WriterType;
00101 typedef std::vector< std::string > FileNamesContainer;
00102
00104 typedef MetaDataDictionary DictionaryType;
00105 typedef MetaDataDictionary * DictionaryRawPointer;
00106 typedef std::vector< DictionaryRawPointer > DictionaryArrayType;
00107 typedef const DictionaryArrayType * DictionaryArrayRawPointer;
00108
00110 void SetInput(const InputImageType *input);
00111 const InputImageType *GetInput(void);
00112 const InputImageType *GetInput(unsigned int idx);
00114
00121 itkSetObjectMacro(ImageIO,ImageIOBase);
00122 itkGetObjectMacro(ImageIO,ImageIOBase);
00124
00129 virtual void Write(void);
00130
00133 virtual void Update()
00134 {
00135 this->Write();
00136 }
00137
00140 itkSetMacro(StartIndex,unsigned long);
00141 itkGetMacro(StartIndex,unsigned long);
00143
00146 itkSetMacro(IncrementIndex,unsigned long);
00147 itkGetMacro(IncrementIndex,unsigned long);
00149
00154 itkSetStringMacro(SeriesFormat);
00155 itkGetStringMacro(SeriesFormat);
00157
00160 void SetFileNames (const FileNamesContainer &name)
00161 {
00162 if ( m_FileNames != name)
00163 {
00164 m_FileNames = name;
00165 this->Modified();
00166 }
00167 };
00168 const FileNamesContainer & GetFileNames() const
00169 {
00170 return m_FileNames;
00171 }
00173
00176 void SetFileName (std::string const &name)
00177 {
00178 m_FileNames.clear();
00179 m_FileNames.push_back(name);
00180 this->Modified();
00181 }
00183
00186 void AddFileName (std::string const &name)
00187 {
00188 m_FileNames.push_back(name);
00189 this->Modified();
00190 }
00192
00193
00196 itkSetMacro( MetaDataDictionaryArray, DictionaryArrayRawPointer);
00197
00198 protected:
00199 ImageSeriesWriter();
00200 ~ImageSeriesWriter();
00201 void PrintSelf(std::ostream& os, Indent indent) const;
00202
00204 void GenerateData(void);
00205
00208 void GenerateNumericFileNamesAndWrite(void);
00209
00210 ImageIOBase::Pointer m_ImageIO;
00211 bool m_UserSpecifiedImageIO;
00212
00213 private:
00214 ImageSeriesWriter(const Self&);
00215 void operator=(const Self&);
00216
00218 FileNamesContainer m_FileNames;
00219
00225 std::string m_SeriesFormat;
00226 unsigned long m_StartIndex;
00227 unsigned long m_IncrementIndex;
00228
00230 DictionaryArrayRawPointer m_MetaDataDictionaryArray;
00231 };
00232
00233
00234 }
00235
00236 #ifndef ITK_MANUAL_INSTANTIATION
00237 #include "itkImageSeriesWriter.txx"
00238 #endif
00239
00240 #endif // __itkImageSeriesWriter_h
00241
00242