DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkVariableLengthVectorImageFileReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Variable Length Vector Image File Reader
4 
5  Copyright (c) Pew-Thian Yap. All rights reserved.
6  See http://www.unc.edu/~ptyap/ for details.
7 
8  This software is distributed WITHOUT ANY WARRANTY; without even
9  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10  PURPOSE. See the above copyright notices for more information.
11 
12  =========================================================================*/
13 
14 #ifndef __itkVariableLengthVectorImageFileReader_h
15 #define __itkVariableLengthVectorImageFileReader_h
16 
17 #include "itkExceptionObject.h"
18 #include "itkImage.h"
19 #include "itkImageSource.h"
20 #include "itkImageIOBase.h"
21 #include "itkImageFileReader.h"
22 #include "itksys/SystemTools.hxx"
23 
24 namespace itk
25 {
26 
32 class VariableLengthVectorImageFileReaderException : public ExceptionObject
33 {
34 public:
36  itkTypeMacro( VariableLengthVectorImageFileReaderException, ExceptionObject );
37 
39  VariableLengthVectorImageFileReaderException(const char *file, unsigned int line,
40  const char* message = "Error in IO",
41  const char* loc = "Unknown") :
42  ExceptionObject(file, line, message, loc)
43  {
44  }
45 
47  VariableLengthVectorImageFileReaderException(const std::string& file, unsigned int line,
48  const char* message = "Error in IO",
49  const char* loc = "Unknown") :
50  ExceptionObject(file, line, message, loc)
51  {
52  }
53 };
54 
55 
60 template <class TOutputImage>
61 class ITKIOImageBase_HIDDEN VariableLengthVectorImageFileReader : public ImageSource<TOutputImage>
62 {
63 public:
66  typedef ImageSource<TOutputImage> Superclass;
67  typedef SmartPointer<Self> Pointer;
68 
70  itkNewMacro(Self);
71 
73  itkTypeMacro(VariableLengthVectorImageFileReader, ImageSource);
74 
76  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::OutputImageDimension);
77 
79  typedef TOutputImage OutputImageType;
80  typedef typename OutputImageType::Pointer OutputImagePointer;
81  typedef typename OutputImageType::SizeType OutputImageSizeType;
82  typedef typename OutputImageType::SpacingType OutputImageSpacingType;
83  typedef typename OutputImageType::IndexType OutputImageIndexType;
84  typedef typename OutputImageType::PointType OutputImagePointType;
85  typedef typename OutputImageType::DirectionType OutputImageDirectionType;
86  typedef typename OutputImageType::RegionType OutputImageRegionType;
87  typedef typename OutputImageType::PixelType OutputImagePixelType;
88  typedef typename OutputImageType::PixelContainer OutputImagePixelContainerType;
89  typedef typename OutputImageType::PixelContainer::Pointer OutputImagePixelContainerPointerType;
90 // typedef typename OutputImageType::PixelContainer::PixelMapType OutputImagePixelMapType;
91 // typedef typename OutputImagePixelMapType::iterator OutputImagePixelMapIteratorType;
92 
94  itkSetStringMacro(FileName);
95  itkGetStringMacro(FileName);
96 
98  itkSetMacro(UseStreaming,bool);
99  itkGetConstReferenceMacro(UseStreaming,bool);
100  itkBooleanMacro(UseStreaming);
101 
103  itkGetObjectMacro(ImageIO,ImageIOBase);
104 
105 protected:
108  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
109 
111 // void DoConvertBuffer(void* buffer, size_t numberOfPixels);
112 
118 // void TestFileExistanceAndReadability();
119 
120  typedef unsigned int LengthType;
121  typedef Image<LengthType, ImageDimension> LengthImageType;
122  typedef Image<typename OutputImagePixelType::ValueType, 1> ValueImageType;
123 
124  typename LengthImageType::Pointer m_LengthImage;
125  typename ValueImageType::Pointer m_ValueImage;
126 
127  typedef itk::ImageFileReader<LengthImageType> LengthImageFileReaderType;
128  typedef itk::ImageFileReader<ValueImageType> ValueImageFileReaderType;
129 
130  typename LengthImageFileReaderType::Pointer m_LengthImageFileReader;
131  typename ValueImageFileReaderType::Pointer m_ValueImageFileReader;
132 
134  virtual void GenerateData() ITK_OVERRIDE;
135 
136  std::string m_FileName;
137  bool m_UseStreaming;
138  ImageIOBase::Pointer m_ImageIO;
139 
140 private:
141  VariableLengthVectorImageFileReader(const Self&); //purposely not implemented
142  void operator=(const Self&); //purposely not implemented
143 
144  std::string m_ExceptionMessage;
145 
146  // The region that the ImageIO class will return when we ask to
147  // produce the requested region.
148 // ImageIORegion m_ActualIORegion;
149 };
150 
151 
152 } //namespace ITK
153 
154 #ifndef ITK_MANUAL_INSTANTIATION
156 #endif
157 
158 #endif // __itkSparseVariableLengthVectorImageFileReader_h
VariableLengthVectorImageFileReaderException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
OutputImageType::PixelContainer::Pointer OutputImagePixelContainerPointerType
VariableLengthVectorImageFileReaderException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
STL namespace.
itk::ImageFileReader< LengthImageType > LengthImageFileReaderType
itk::ImageFileReader< ValueImageType > ValueImageFileReaderType
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
Image< typename OutputImagePixelType::ValueType, 1 > ValueImageType