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: 2007/03/17 21:02:11 $
00007   Version:   $Revision: 1.20 $
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   itkGetConstReferenceMacro( IORegion, ImageIORegion );
00148 
00151   virtual void Update()
00152     {
00153     this->Write();\
00154     }
00155 
00157   itkSetMacro(UseCompression,bool);
00158   itkGetConstReferenceMacro(UseCompression,bool);
00159   itkBooleanMacro(UseCompression);
00161 
00168   itkSetMacro(UseInputMetaDataDictionary,bool);
00169   itkGetConstReferenceMacro(UseInputMetaDataDictionary,bool);
00170   itkBooleanMacro(UseInputMetaDataDictionary);
00172 
00173 
00174 protected:
00175   ImageFileWriter();
00176   ~ImageFileWriter();
00177   void PrintSelf(std::ostream& os, Indent indent) const;
00178 
00180   void GenerateData(void);
00181 
00182 private:
00183   ImageFileWriter(const Self&); //purposely not implemented
00184   void operator=(const Self&); //purposely not implemented
00185 
00186   std::string        m_FileName;
00187   
00188   ImageIOBase::Pointer m_ImageIO;
00189   bool                 m_UserSpecifiedImageIO; // track whether the ImageIO
00190                                                 // is user specified
00191   
00192   ImageIORegion m_IORegion;
00193   bool          m_UserSpecifiedIORegion;    // track whether the region
00194                                             // is user specified
00195   bool          m_FactorySpecifiedImageIO;  //track whether the factory
00196                                             //  mechanism set the ImageIO
00197   bool m_UseCompression;
00198   bool m_UseInputMetaDataDictionary;        // whether to use the
00199                                             // MetaDataDictionary from the
00200                                             // input or not.
00201 };
00202 
00203   
00204 } // end namespace itk
00205   
00206 #ifndef ITK_MANUAL_INSTANTIATION
00207 #include "itkImageFileWriter.txx"
00208 #endif
00209 
00210 #endif // __itkImageFileWriter_h
00211 

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