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: 2005/07/20 18:09:06 $
00007   Version:   $Revision: 1.18 $
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 
00030 class ImageFileWriterException : public ExceptionObject 
00031 {
00032 public:
00034   itkTypeMacro( ImageFileWriterException, ExceptionObject );
00035 
00037   ImageFileWriterException(const char *file, unsigned int line, 
00038                            const char* message = "Error in IO") : 
00039     ExceptionObject(file, line)
00040   {
00041     SetDescription(message);
00042   }
00043 
00045   ImageFileWriterException(const std::string &file, unsigned int line, 
00046                            const char* message = "Error in IO") : 
00047     ExceptionObject(file, line)
00048   {
00049     SetDescription(message);
00050   }
00051 };
00052 
00053 
00075 template <class TInputImage>
00076 class ITK_EXPORT ImageFileWriter : public ProcessObject
00077 {
00078 public:
00080   typedef ImageFileWriter           Self;
00081   typedef ProcessObject             Superclass;
00082   typedef SmartPointer<Self>        Pointer;
00083   typedef SmartPointer<const Self>  ConstPointer;
00084 
00086   itkNewMacro(Self);
00087 
00089   itkTypeMacro(ImageFileWriter,ProcessObject);
00090 
00092   typedef TInputImage InputImageType;
00093   typedef typename InputImageType::Pointer InputImagePointer;
00094   typedef typename InputImageType::RegionType InputImageRegionType; 
00095   typedef typename InputImageType::PixelType InputImagePixelType; 
00096   
00098   void SetInput(const InputImageType *input);
00099   const InputImageType * GetInput(void);
00100   const InputImageType * GetInput(unsigned int idx);
00101   
00103   itkSetStringMacro(FileName);
00104   itkGetStringMacro(FileName);
00105   
00116   void SetImageIO (ImageIOBase* io)
00117   {
00118     if (this->m_ImageIO != io)
00119       {
00120       this->Modified();
00121       this->m_ImageIO = io;
00122       }
00123     m_FactorySpecifiedImageIO = false;
00124   }
00125   itkGetObjectMacro(ImageIO,ImageIOBase);
00126   
00134   virtual void Write(void);
00135 
00138   void SetIORegion(const ImageIORegion & region);
00139   itkGetConstReferenceMacro( IORegion, ImageIORegion );
00140 
00143   virtual void Update()
00144   {this->Write();}
00145 
00147   itkSetMacro(UseCompression,bool);
00148   itkGetConstReferenceMacro(UseCompression,bool);
00149   itkBooleanMacro(UseCompression);
00150 
00157   itkSetMacro(UseInputMetaDataDictionary,bool);
00158   itkGetConstReferenceMacro(UseInputMetaDataDictionary,bool);
00159   itkBooleanMacro(UseInputMetaDataDictionary);
00160 
00161 
00162 protected:
00163   ImageFileWriter();
00164   ~ImageFileWriter();
00165   void PrintSelf(std::ostream& os, Indent indent) const;
00166 
00168   void GenerateData(void);
00169   
00170 private:
00171   ImageFileWriter(const Self&); //purposely not implemented
00172   void operator=(const Self&); //purposely not implemented
00173 
00174   std::string        m_FileName;
00175   
00176   ImageIOBase::Pointer m_ImageIO;
00177   bool m_UserSpecifiedImageIO; //track whether the ImageIO is user specified
00178   
00179   ImageIORegion m_IORegion;
00180   bool m_UserSpecifiedIORegion; //
00181                                 //track whether the region is user specified
00182   bool m_FactorySpecifiedImageIO; //track whether the factory mechanism set the ImageIO
00183   bool m_UseCompression;
00184   bool m_UseInputMetaDataDictionary; // whether to use the MetaDataDictionary from the input or not.
00185 };
00186 
00187   
00188 } // end namespace itk
00189   
00190 #ifndef ITK_MANUAL_INSTANTIATION
00191 #include "itkImageFileWriter.txx"
00192 #endif
00193 
00194 #endif // __itkImageFileWriter_h
00195   

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