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

itkImageFileReader.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageFileReader.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/09/25 19:03:02 $
00007   Version:   $Revision: 1.24 $
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 __itkImageFileReader_h
00018 #define __itkImageFileReader_h
00019 
00020 #include "itkImageIOBase.h"
00021 #include "itkImageSource.h"
00022 #include "itkExceptionObject.h"
00023 #include "itkSize.h"
00024 #include "itkImageRegion.h"
00025 #include "itkDefaultConvertPixelTraits.h"
00026 
00027 namespace itk
00028 {
00029 
00031 class ImageFileReaderException : public ExceptionObject 
00032 {
00033 public:
00035   itkTypeMacro( ImageFileReaderException, ExceptionObject );
00036 
00038   ImageFileReaderException(const char *file, unsigned int line, 
00039                            const char* message = "Error in IO") : 
00040     ExceptionObject(file, line)
00041   {
00042     SetDescription(message);
00043   }
00044 
00046   ImageFileReaderException(const std::string &file, unsigned int line, 
00047                            const char* message = "Error in IO") : 
00048     ExceptionObject(file, line)
00049   {
00050     SetDescription(message);
00051   }
00052 };
00053 
00054 
00085 template <class TOutputImage,
00086           class ConvertPixelTraits = 
00087           DefaultConvertPixelTraits< ITK_TYPENAME TOutputImage::PixelType> >
00088 class ITK_EXPORT ImageFileReader : public ImageSource<TOutputImage>
00089 {
00090 public:
00092   typedef ImageFileReader         Self;
00093   typedef ImageSource<TOutputImage>  Superclass;
00094   typedef SmartPointer<Self>  Pointer;
00095   
00097   itkNewMacro(Self);
00098 
00100   itkTypeMacro(ImageFileReader, ImageSource);
00101 
00103   typedef typename TOutputImage::SizeType  SizeType;
00104 
00106   typedef typename TOutputImage::RegionType  ImageRegionType;
00107 
00109   typedef typename TOutputImage::InternalPixelType OutputImagePixelType;
00110   
00112   itkSetStringMacro(FileName);
00113   itkGetStringMacro(FileName);
00114   
00121   void  SetImageIO( ImageIOBase * imageIO );
00122   itkGetObjectMacro(ImageIO,ImageIOBase);
00123   
00126   virtual void GenerateOutputInformation(void);
00127 
00133   virtual void EnlargeOutputRequestedRegion(DataObject *output);
00134 
00135 
00136 
00137 protected:
00138   ImageFileReader();
00139   ~ImageFileReader();
00140   void PrintSelf(std::ostream& os, Indent indent) const;
00141   
00143   void DoConvertBuffer(void* buffer, unsigned long numberOfPixels);
00144 
00150   void TestFileExistanceAndReadability();
00151 
00153   virtual void GenerateData();
00154 
00155   ImageIOBase::Pointer m_ImageIO;
00156   bool m_UserSpecifiedImageIO; //keep track whether the ImageIO is user specified
00157 
00159   std::string m_FileName;
00160   
00161 private:
00162   ImageFileReader(const Self&); //purposely not implemented
00163   void operator=(const Self&); //purposely not implemented
00164   
00165 };
00166 
00167 
00168 } //namespace ITK
00169 
00170 #ifndef ITK_MANUAL_INSTANTIATION
00171 #include "itkImageFileReader.txx"
00172 #endif
00173 
00174 #endif // __itkImageFileReader_h

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