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: 2006/06/29 18:57:18 $
00007   Version:   $Revision: 1.28 $
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                            const char* loc = "Unknown") :
00041     ExceptionObject(file, line, message, loc)
00042   {
00043   }
00044 
00046   ImageFileReaderException(const std::string &file, unsigned int line, 
00047                            const char* message = "Error in IO",
00048                            const char* loc = "Unknown") : 
00049     ExceptionObject(file, line, message, loc)
00050   {
00051   }
00052 };
00054 
00055 
00086 template <class TOutputImage,
00087           class ConvertPixelTraits=DefaultConvertPixelTraits< 
00088                    ITK_TYPENAME TOutputImage::IOPixelType > >
00089 class ITK_EXPORT ImageFileReader : public ImageSource<TOutputImage>
00090 {
00091 public:
00093   typedef ImageFileReader         Self;
00094   typedef ImageSource<TOutputImage>  Superclass;
00095   typedef SmartPointer<Self>  Pointer;
00096 
00098   itkNewMacro(Self);
00099 
00101   itkTypeMacro(ImageFileReader, ImageSource);
00102 
00104   typedef typename TOutputImage::SizeType  SizeType;
00105 
00107   typedef typename TOutputImage::RegionType  ImageRegionType;
00108 
00110   typedef typename TOutputImage::InternalPixelType OutputImagePixelType;
00111 
00113   itkSetStringMacro(FileName);
00114   itkGetStringMacro(FileName);
00116 
00123   void  SetImageIO( ImageIOBase * imageIO );
00124   itkGetObjectMacro(ImageIO,ImageIOBase);
00126 
00129   virtual void GenerateOutputInformation(void);
00130 
00136   virtual void EnlargeOutputRequestedRegion(DataObject *output);
00137 
00138 
00139 
00140 protected:
00141   ImageFileReader();
00142   ~ImageFileReader();
00143   void PrintSelf(std::ostream& os, Indent indent) const;
00144   
00146   void DoConvertBuffer(void* buffer, unsigned long numberOfPixels);
00147 
00153   void TestFileExistanceAndReadability();
00154 
00156   virtual void GenerateData();
00157 
00158   ImageIOBase::Pointer m_ImageIO;
00159   bool m_UserSpecifiedImageIO; //keep track whether the ImageIO is user specified
00160 
00162   std::string m_FileName;
00163 
00164 private:
00165   ImageFileReader(const Self&); //purposely not implemented
00166   void operator=(const Self&); //purposely not implemented
00167   std::string m_ExceptionMessage;  
00168 };
00169 
00170 
00171 } //namespace ITK
00172 
00173 #ifndef ITK_MANUAL_INSTANTIATION
00174 #include "itkImageFileReader.txx"
00175 #endif
00176 
00177 #endif // __itkImageFileReader_h
00178 

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