Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkImageSeriesWriter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageSeriesWriter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/09/03 23:09:17 $
00007   Version:   $Revision: 1.9 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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; //track whether the ImageIO is user specified
00212   
00213 private:
00214   ImageSeriesWriter(const Self&); //purposely not implemented
00215   void operator=(const Self&); //purposely not implemented
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 } // end namespace itk
00235   
00236 #ifndef ITK_MANUAL_INSTANTIATION
00237 #include "itkImageSeriesWriter.txx"
00238 #endif
00239 
00240 #endif // __itkImageSeriesWriter_h
00241   
00242 

Generated at Mon Mar 12 01:09:16 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000