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 };
00055
00056
00078 template <class TInputImage, class TOutputImage>
00079 class ITK_EXPORT ImageSeriesWriter : public ProcessObject
00080 {
00081 public:
00083 typedef ImageSeriesWriter Self;
00084 typedef ProcessObject Superclass;
00085 typedef SmartPointer<Self> Pointer;
00086 typedef SmartPointer<const Self> ConstPointer;
00087
00089 itkNewMacro(Self);
00090
00092 itkTypeMacro(ImageSeriesWriter,ProcessObject);
00093
00095 typedef TInputImage InputImageType;
00096 typedef typename InputImageType::RegionType InputImageRegionType;
00097 typedef TOutputImage OutputImageType;
00098 typedef typename OutputImageType::RegionType OutputImageRegionType;
00099 typedef ImageFileWriter<TOutputImage> WriterType;
00100 typedef std::vector< std::string > FileNamesContainer;
00101
00103 typedef MetaDataDictionary DictionaryType;
00104 typedef MetaDataDictionary * DictionaryRawPointer;
00105 typedef std::vector< DictionaryRawPointer > DictionaryArrayType;
00106 typedef const DictionaryArrayType * DictionaryArrayRawPointer;
00107
00109 void SetInput(const InputImageType *input);
00110 const InputImageType *GetInput(void);
00111 const InputImageType *GetInput(unsigned int idx);
00112
00119 itkSetObjectMacro(ImageIO,ImageIOBase);
00120 itkGetObjectMacro(ImageIO,ImageIOBase);
00121
00126 virtual void Write(void);
00127
00130 virtual void Update()
00131 {
00132 this->Write();
00133 }
00134
00137 itkSetMacro(StartIndex,unsigned long);
00138 itkGetMacro(StartIndex,unsigned long);
00139
00142 itkSetMacro(IncrementIndex,unsigned long);
00143 itkGetMacro(IncrementIndex,unsigned long);
00144
00149 itkSetStringMacro(SeriesFormat);
00150 itkGetStringMacro(SeriesFormat);
00151
00154 void SetFileNames (const FileNamesContainer &name)
00155 {
00156 if ( m_FileNames != name)
00157 {
00158 m_FileNames = name;
00159 this->Modified();
00160 }
00161 };
00162 const FileNamesContainer & GetFileNames() const
00163 {
00164 return m_FileNames;
00165 }
00166
00169 void SetFileName (std::string const &name)
00170 {
00171 m_FileNames.clear();
00172 m_FileNames.push_back(name);
00173 this->Modified();
00174 }
00175
00178 void AddFileName (std::string const &name)
00179 {
00180 m_FileNames.push_back(name);
00181 this->Modified();
00182 }
00183
00184
00187 itkSetMacro( MetaDataDictionaryArray, DictionaryArrayRawPointer);
00188
00189 protected:
00190 ImageSeriesWriter();
00191 ~ImageSeriesWriter();
00192 void PrintSelf(std::ostream& os, Indent indent) const;
00193
00195 void GenerateData(void);
00196
00199 void GenerateNumericFileNamesAndWrite(void);
00200
00201 ImageIOBase::Pointer m_ImageIO;
00202 bool m_UserSpecifiedImageIO;
00203
00204 private:
00205 ImageSeriesWriter(const Self&);
00206 void operator=(const Self&);
00207
00209 FileNamesContainer m_FileNames;
00210
00216 std::string m_SeriesFormat;
00217 unsigned long m_StartIndex;
00218 unsigned long m_IncrementIndex;
00219
00221 DictionaryArrayRawPointer m_MetaDataDictionaryArray;
00222 };
00223
00224
00225 }
00226
00227 #ifndef ITK_MANUAL_INSTANTIATION
00228 #include "itkImageSeriesWriter.txx"
00229 #endif
00230
00231 #endif // __itkImageSeriesWriter_h
00232