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: 2007/04/19 13:58:17 $
00007   Version:   $Revision: 1.11 $
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 
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   itkGetMacro(StartIndex,unsigned long);
00144 
00147   itkSetMacro(IncrementIndex,unsigned long);
00148   itkGetMacro(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; //track whether the ImageIO is
00218                                                // user specified
00219   
00220 private:
00221   ImageSeriesWriter(const Self&); //purposely not implemented
00222   void operator=(const Self&); //purposely not implemented
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 } // end namespace itk
00244   
00245 #ifndef ITK_MANUAL_INSTANTIATION
00246 #include "itkImageSeriesWriter.txx"
00247 #endif
00248 
00249 #endif // __itkImageSeriesWriter_h
00250 

Generated at Wed Nov 5 22:16:06 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000