DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkSpatiallyDenseSparseVectorImageFileReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Spatially Dense Sparse 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 __itkSpatiallyDenseSparseVectorImageFileReader_h
15 #define __itkSpatiallyDenseSparseVectorImageFileReader_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 #include "itkMacro.h"
24 
25 
26 namespace itk
27 {
28 
36 {
37 public:
39  itkTypeMacro( SpatiallyDenseSparseVectorImageFileReaderException, ExceptionObject );
40 
42  SpatiallyDenseSparseVectorImageFileReaderException(const char *file, unsigned int line,
43  const char* message = "Error in IO",
44  const char* loc = "Unknown") :
45  ExceptionObject(file, line, message, loc)
46  {
47  }
48 
50  SpatiallyDenseSparseVectorImageFileReaderException(const std::string& file, unsigned int line,
51  const char* message = "Error in IO",
52  const char* loc = "Unknown") :
53  ExceptionObject(file, line, message, loc)
54  {
55  }
56 };
57 
58 
66 template <class TOutputImage>
67 class ITKIOImageBase_HIDDEN SpatiallyDenseSparseVectorImageFileReader : public ImageSource<TOutputImage>
68 {
69 public:
72  typedef ImageSource<TOutputImage> Superclass;
73  typedef SmartPointer<Self> Pointer;
74 
76  itkNewMacro(Self);
77 
79  itkTypeMacro(SpatiallyDenseSparseVectorImageFileReader, ImageSource);
80 
82  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::OutputImageDimension);
83 
85  typedef TOutputImage OutputImageType;
86  typedef typename OutputImageType::Pointer OutputImagePointer;
87  typedef typename OutputImageType::SizeType OutputImageSizeType;
88  typedef typename OutputImageType::SpacingType OutputImageSpacingType;
89  typedef typename OutputImageType::IndexType OutputImageIndexType;
90  typedef typename OutputImageType::PointType OutputImagePointType;
91  typedef typename OutputImageType::DirectionType OutputImageDirectionType;
92  typedef typename OutputImageType::RegionType OutputImageRegionType;
93  typedef typename OutputImageType::PixelType OutputImagePixelType;
94  typedef typename OutputImageType::InternalPixelType OutputImageInternalPixelType;
95  typedef typename OutputImageType::ValueType OutputImageValueType;
96  typedef typename OutputImageType::KeyType OutputImageKeyType;
97  typedef typename OutputImageType::PixelContainer OutputImagePixelContainerType;
98  typedef typename OutputImageType::PixelContainerConstPointer OutputImagePixelContainerConstPointerType;
99  typedef typename OutputImageType::PixelMapType OutputImagePixelPixelMapType;
100  typedef typename OutputImageType::PixelMapConstIterator OutputImagePixelMapConstIteratorType;
101 
102  typedef Image<OutputImageKeyType, 1> KeyImageType;
103  typedef Image<OutputImageValueType, 1> ValueImageType;
104 
105  typedef ImageFileReader<KeyImageType> KeyImageFileReaderType;
106  typedef ImageFileReader<ValueImageType> ValueImageFileReaderType;
107 
109  itkSetStringMacro(FileName);
110  itkGetStringMacro(FileName);
111 
113  itkSetMacro(UseStreaming,bool);
114  itkGetConstReferenceMacro(UseStreaming,bool);
115  itkBooleanMacro(UseStreaming);
116 
118  itkGetObjectMacro(ImageIO,ImageIOBase);
119 
120 protected:
123  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
124 
126 // void DoConvertBuffer(void* buffer, size_t numberOfPixels);
127 
133 // void TestFileExistanceAndReadability();
134 
135  typename KeyImageType::Pointer m_KeyImage;
136  typename ValueImageType::Pointer m_ValueImage;
137 
138  typename KeyImageFileReaderType::Pointer m_KeyImageFileReader;
139  typename ValueImageFileReaderType::Pointer m_ValueImageFileReader;
140 
142  virtual void GenerateData() ITK_OVERRIDE;
143 
144  std::string m_FileName;
145  bool m_UseStreaming;
146  ImageIOBase::Pointer m_ImageIO;
147 
148 private:
149  SpatiallyDenseSparseVectorImageFileReader(const Self&); //purposely not implemented
150  void operator=(const Self&); //purposely not implemented
151 
152  std::string m_ExceptionMessage;
153 
154  // The region that the ImageIO class will return when we ask to
155  // produce the requested region.
156 // ImageIORegion m_ActualIORegion;
157 };
158 
159 
160 } //namespace ITK
161 
162 #ifndef ITK_MANUAL_INSTANTIATION
164 #endif
165 
166 #endif // __itkSparseSpatiallyDenseSparseVectorImageFileReader_h
STL namespace.
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
OutputImageType::PixelContainerConstPointer OutputImagePixelContainerConstPointerType
SpatiallyDenseSparseVectorImageFileReaderException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
SpatiallyDenseSparseVectorImageFileReaderException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")