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: 2007/09/06 18:31:36 $
00007   Version:   $Revision: 1.31 $
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 
00034 class ImageFileReaderException : public ExceptionObject 
00035 {
00036 public:
00038   itkTypeMacro( ImageFileReaderException, ExceptionObject );
00039 
00041   ImageFileReaderException(const char *file, unsigned int line, 
00042                            const char* message = "Error in IO",
00043                            const char* loc = "Unknown") :
00044     ExceptionObject(file, line, message, loc)
00045   {
00046   }
00047 
00049   ImageFileReaderException(const std::string &file, unsigned int line, 
00050                            const char* message = "Error in IO",
00051                            const char* loc = "Unknown") : 
00052     ExceptionObject(file, line, message, loc)
00053   {
00054   }
00055 };
00057 
00058 
00091 template <class TOutputImage,
00092           class ConvertPixelTraits=DefaultConvertPixelTraits< 
00093                    ITK_TYPENAME TOutputImage::IOPixelType > >
00094 class ITK_EXPORT ImageFileReader : public ImageSource<TOutputImage>
00095 {
00096 public:
00098   typedef ImageFileReader           Self;
00099   typedef ImageSource<TOutputImage> Superclass;
00100   typedef SmartPointer<Self>        Pointer;
00101 
00103   itkNewMacro(Self);
00104 
00106   itkTypeMacro(ImageFileReader, ImageSource);
00107 
00109   typedef typename TOutputImage::SizeType  SizeType;
00110 
00112   typedef typename TOutputImage::IndexType  IndexType;
00113 
00115   typedef typename TOutputImage::RegionType  ImageRegionType;
00116 
00118   typedef typename TOutputImage::InternalPixelType OutputImagePixelType;
00119 
00121   itkSetStringMacro(FileName);
00122   itkGetStringMacro(FileName);
00124 
00131   void  SetImageIO( ImageIOBase * imageIO );
00132   itkGetObjectMacro(ImageIO,ImageIOBase);
00134 
00137   virtual void GenerateOutputInformation(void);
00138 
00144   virtual void EnlargeOutputRequestedRegion(DataObject *output);
00145 
00147   itkSetMacro(UseStreaming,bool);
00148   itkGetConstReferenceMacro(UseStreaming,bool);
00149   itkBooleanMacro(UseStreaming);
00151 
00152 protected:
00153   ImageFileReader();
00154   ~ImageFileReader();
00155   void PrintSelf(std::ostream& os, Indent indent) const;
00156   
00158   void DoConvertBuffer(void* buffer, unsigned long numberOfPixels);
00159 
00165   void TestFileExistanceAndReadability();
00166 
00168   virtual void GenerateData();
00169 
00170   ImageIOBase::Pointer m_ImageIO;
00171   bool                 m_UserSpecifiedImageIO; // keep track whether the
00172                                                // ImageIO is user specified 
00173 
00174   std::string m_FileName; // The file to be read
00175 
00176   bool m_UseStreaming;
00177   
00178 private:
00179   ImageFileReader(const Self&); //purposely not implemented
00180   void operator=(const Self&); //purposely not implemented
00181   std::string m_ExceptionMessage;  
00182 
00183   // The region that the ImageIO class will return when we ask it to produce a
00184   // requested region.
00185   ImageRegionType m_StreamableRegion; 
00186 };
00187 
00188 
00189 } //namespace ITK
00190 
00191 #ifndef ITK_MANUAL_INSTANTIATION
00192 #include "itkImageFileReader.txx"
00193 #endif
00194 
00195 #endif // __itkImageFileReader_h
00196 

Generated at Tue Jul 29 20:29:27 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000