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

itkImageFileWriter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageFileWriter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-01-12 23:17:56 $
00007   Version:   $Revision: 1.21 $
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 __itkImageFileWriter_h
00018 #define __itkImageFileWriter_h
00019 
00020 #include "itkProcessObject.h"
00021 #include "itkImageIOBase.h"
00022 #include "itkExceptionObject.h"
00023 #include "itkSize.h"
00024 #include "itkImageIORegion.h"
00025 
00026 namespace itk
00027 {
00028 
00033 class ImageFileWriterException : public ExceptionObject 
00034 {
00035 public:
00037   itkTypeMacro( ImageFileWriterException, ExceptionObject );
00038 
00040   ImageFileWriterException(const char *file, unsigned int line, 
00041                            const char* message = "Error in IO",
00042                            const char* loc = "Unknown" ) : 
00043     ExceptionObject(file, line, message, loc)
00044   {
00045   }
00046 
00048   ImageFileWriterException(const std::string &file, unsigned int line, 
00049                            const char* message = "Error in IO",
00050                            const char* loc = "Unknown" ) :
00051     ExceptionObject(file, line, message, loc)
00052   {
00053   }
00054 };
00056 
00057 
00079 template <class TInputImage>
00080 class ITK_EXPORT ImageFileWriter : public ProcessObject
00081 {
00082 public:
00084   typedef ImageFileWriter           Self;
00085   typedef ProcessObject             Superclass;
00086   typedef SmartPointer<Self>        Pointer;
00087   typedef SmartPointer<const Self>  ConstPointer;
00088 
00090   itkNewMacro(Self);
00091 
00093   itkTypeMacro(ImageFileWriter,ProcessObject);
00094 
00096   typedef TInputImage                         InputImageType;
00097   typedef typename InputImageType::Pointer    InputImagePointer;
00098   typedef typename InputImageType::RegionType InputImageRegionType; 
00099   typedef typename InputImageType::PixelType  InputImagePixelType; 
00100 
00102   void SetInput(const InputImageType *input);
00103   const InputImageType * GetInput(void);
00104   const InputImageType * GetInput(unsigned int idx);
00106 
00108   itkSetStringMacro(FileName);
00109   itkGetStringMacro(FileName);
00111 
00122   void SetImageIO (ImageIOBase* io)
00123     {
00124     if (this->m_ImageIO != io)
00125       {
00126       this->Modified();
00127       this->m_ImageIO = io;
00128       }
00129     m_FactorySpecifiedImageIO = false;
00130     }
00131   itkGetObjectMacro(ImageIO,ImageIOBase);
00133 
00141   virtual void Write(void);
00142 
00145   void SetIORegion(const ImageIORegion & region);
00146   const ImageIORegion &GetIORegion(void) const 
00147     {
00148     return m_PasteIORegion;
00149     }
00151 
00152 
00155   itkSetMacro(NumberOfStreamDivisions,unsigned int);
00156   itkGetConstReferenceMacro(NumberOfStreamDivisions,unsigned int);
00158 
00159 
00162   virtual void Update()
00163     {
00164     this->Write();\
00165     }
00166 
00168   itkSetMacro(UseCompression,bool);
00169   itkGetConstReferenceMacro(UseCompression,bool);
00170   itkBooleanMacro(UseCompression);
00172 
00179   itkSetMacro(UseInputMetaDataDictionary,bool);
00180   itkGetConstReferenceMacro(UseInputMetaDataDictionary,bool);
00181   itkBooleanMacro(UseInputMetaDataDictionary);
00183 
00184 
00185 protected:
00186   ImageFileWriter();
00187   ~ImageFileWriter();
00188   void PrintSelf(std::ostream& os, Indent indent) const;
00189 
00191   void GenerateData(void);
00192 
00193 private:
00194   ImageFileWriter(const Self&); //purposely not implemented
00195   void operator=(const Self&); //purposely not implemented
00196 
00197   std::string        m_FileName;
00198   
00199   ImageIOBase::Pointer m_ImageIO;
00200   bool                 m_UserSpecifiedImageIO; // track whether the ImageIO
00201                                                 // is user specified
00202   
00203   ImageIORegion m_PasteIORegion;
00204   unsigned int  m_NumberOfStreamDivisions;
00205   bool          m_UserSpecifiedIORegion;    // track whether the region
00206                                             // is user specified
00207   bool          m_FactorySpecifiedImageIO;  //track whether the factory
00208                                             //  mechanism set the ImageIO
00209   bool m_UseCompression;
00210   bool m_UseInputMetaDataDictionary;        // whether to use the
00211                                             // MetaDataDictionary from the
00212                                             // input or not.
00213 };
00214 
00215   
00216 } // end namespace itk
00217   
00218 #ifndef ITK_MANUAL_INSTANTIATION
00219 #include "itkImageFileWriter.txx"
00220 #endif
00221 
00222 #endif // __itkImageFileWriter_h
00223 

Generated at Tue Sep 15 03:17:48 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000