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: 2006/02/16 16:16:55 $
00007   Version:   $Revision: 1.19 $
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                            const char* loc = "Unknown" ) : 
00040     ExceptionObject(file, line, message, loc)
00041   {
00042   }
00043 
00045   ImageFileWriterException(const std::string &file, unsigned int line, 
00046                            const char* message = "Error in IO",
00047                            const char* loc = "Unknown" ) :
00048     ExceptionObject(file, line, message, loc)
00049   {
00050   }
00051 };
00053 
00054 
00076 template <class TInputImage>
00077 class ITK_EXPORT ImageFileWriter : public ProcessObject
00078 {
00079 public:
00081   typedef ImageFileWriter           Self;
00082   typedef ProcessObject             Superclass;
00083   typedef SmartPointer<Self>        Pointer;
00084   typedef SmartPointer<const Self>  ConstPointer;
00085 
00087   itkNewMacro(Self);
00088 
00090   itkTypeMacro(ImageFileWriter,ProcessObject);
00091 
00093   typedef TInputImage InputImageType;
00094   typedef typename InputImageType::Pointer InputImagePointer;
00095   typedef typename InputImageType::RegionType InputImageRegionType; 
00096   typedef typename InputImageType::PixelType InputImagePixelType; 
00097 
00099   void SetInput(const InputImageType *input);
00100   const InputImageType * GetInput(void);
00101   const InputImageType * GetInput(unsigned int idx);
00103 
00105   itkSetStringMacro(FileName);
00106   itkGetStringMacro(FileName);
00108 
00119   void SetImageIO (ImageIOBase* io)
00120   {
00121     if (this->m_ImageIO != io)
00122       {
00123       this->Modified();
00124       this->m_ImageIO = io;
00125       }
00126     m_FactorySpecifiedImageIO = false;
00127   }
00128   itkGetObjectMacro(ImageIO,ImageIOBase);
00130 
00138   virtual void Write(void);
00139 
00142   void SetIORegion(const ImageIORegion & region);
00143   itkGetConstReferenceMacro( IORegion, ImageIORegion );
00145 
00148   virtual void Update()
00149   {this->Write();}
00150 
00152   itkSetMacro(UseCompression,bool);
00153   itkGetConstReferenceMacro(UseCompression,bool);
00154   itkBooleanMacro(UseCompression);
00156 
00163   itkSetMacro(UseInputMetaDataDictionary,bool);
00164   itkGetConstReferenceMacro(UseInputMetaDataDictionary,bool);
00165   itkBooleanMacro(UseInputMetaDataDictionary);
00167 
00168 
00169 protected:
00170   ImageFileWriter();
00171   ~ImageFileWriter();
00172   void PrintSelf(std::ostream& os, Indent indent) const;
00173 
00175   void GenerateData(void);
00176 
00177 private:
00178   ImageFileWriter(const Self&); //purposely not implemented
00179   void operator=(const Self&); //purposely not implemented
00180 
00181   std::string        m_FileName;
00182   
00183   ImageIOBase::Pointer m_ImageIO;
00184   bool m_UserSpecifiedImageIO; //track whether the ImageIO is user specified
00185   
00186   ImageIORegion m_IORegion;
00187   bool m_UserSpecifiedIORegion; //
00188                                 //track whether the region is user specified
00189   bool m_FactorySpecifiedImageIO; //track whether the factory mechanism set the ImageIO
00190   bool m_UseCompression;
00191   bool m_UseInputMetaDataDictionary; // whether to use the MetaDataDictionary from the input or not.
00192 };
00193 
00194   
00195 } // end namespace itk
00196   
00197 #ifndef ITK_MANUAL_INSTANTIATION
00198 #include "itkImageFileWriter.txx"
00199 #endif
00200 
00201 #endif // __itkImageFileWriter_h
00202   
00203 

Generated at Mon Mar 12 00:50:38 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000