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 };
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; //track whether the ImageIO is user specified
00203   
00204 private:
00205   ImageSeriesWriter(const Self&); //purposely not implemented
00206   void operator=(const Self&); //purposely not implemented
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 } // end namespace itk
00226   
00227 #ifndef ITK_MANUAL_INSTANTIATION
00228 #include "itkImageSeriesWriter.txx"
00229 #endif
00230 
00231 #endif // __itkImageSeriesWriter_h
00232   

Generated at Wed May 24 23:25:56 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000