ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkImageFileReader.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkImageFileReader_h
19 #define itkImageFileReader_h
21 
22 #include "ITKIOImageBaseExport.h"
23 
24 #include "itkImageIOBase.h"
25 #include "itkImageSource.h"
26 #include "itkMacro.h"
27 #include "itkImageRegion.h"
30 
31 namespace itk
32 {
33 
73 template< typename TOutputImage,
74  typename ConvertPixelTraits = DefaultConvertPixelTraits<
75  typename TOutputImage::IOPixelType > >
76 class ITKIOImageBase_HIDDEN ImageFileReader:public ImageSource< TOutputImage >
77 {
78 public:
83 
85  itkNewMacro(Self);
86 
88  itkTypeMacro(ImageFileReader, ImageSource);
89 
91  typedef typename TOutputImage::SizeType SizeType;
92 
94  typedef typename TOutputImage::IndexType IndexType;
95 
97  typedef typename TOutputImage::RegionType ImageRegionType;
98 
100  typedef typename TOutputImage::InternalPixelType OutputImagePixelType;
101 
103  itkSetGetDecoratedInputMacro(FileName, std::string);
104 
111  void SetImageIO(ImageIOBase *imageIO);
112  itkGetModifiableObjectMacro(ImageIO, ImageIOBase);
114 
117  virtual void GenerateOutputInformation(void) ITK_OVERRIDE;
118 
124  virtual void EnlargeOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
125 
127  itkSetMacro(UseStreaming, bool);
128  itkGetConstReferenceMacro(UseStreaming, bool);
129  itkBooleanMacro(UseStreaming);
131 
132 protected:
133  ImageFileReader();
134  ~ImageFileReader();
135  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
136 
138  void DoConvertBuffer(void *buffer, size_t numberOfPixels);
139 
145  void TestFileExistanceAndReadability();
146 
148  virtual void GenerateData() ITK_OVERRIDE;
149 
150  ImageIOBase::Pointer m_ImageIO;
151 
152  bool m_UserSpecifiedImageIO; // keep track whether the
153  // ImageIO is user specified
154 
155  bool m_UseStreaming;
156 
157 private:
158  ImageFileReader(const Self &) ITK_DELETE_FUNCTION;
159  void operator=(const Self &) ITK_DELETE_FUNCTION;
160 
161  std::string m_ExceptionMessage;
162 
163  // The region that the ImageIO class will return when we ask to
164  // produce the requested region.
165  ImageIORegion m_ActualIORegion;
166 };
167 } //namespace ITK
168 
169 #ifndef ITK_MANUAL_INSTANTIATION
170 #include "itkImageFileReader.hxx"
171 #endif
172 
173 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER
174 #include "itkImageIOFactoryRegisterManager.h"
175 #endif
176 
177 #endif // itkImageFileReader_h
TOutputImage::RegionType ImageRegionType
TOutputImage::IndexType IndexType
An ImageIORegion represents a structured region of data.
Abstract superclass defines image IO interface.
TOutputImage::SizeType SizeType
Base class for all process objects that output image data.
SmartPointer< Self > Pointer
ImageSource< TOutputImage > Superclass
TOutputImage::InternalPixelType OutputImagePixelType
Data source that reads image data from a single file.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for all data objects in ITK.