ITK  4.13.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 
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 
116  itkSetMacro(UseStreaming, bool);
117  itkGetConstReferenceMacro(UseStreaming, bool);
118  itkBooleanMacro(UseStreaming);
120 
121 protected:
122  ImageFileReader();
123  ~ImageFileReader() ITK_OVERRIDE;
124  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
125 
127  void DoConvertBuffer(void *buffer, size_t numberOfPixels);
128 
134  void TestFileExistanceAndReadability();
135 
138  virtual void GenerateOutputInformation(void) ITK_OVERRIDE;
139 
145  virtual void EnlargeOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
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  ITK_DISALLOW_COPY_AND_ASSIGN(ImageFileReader);
159 
160  std::string m_ExceptionMessage;
161 
162  // The region that the ImageIO class will return when we ask to
163  // produce the requested region.
164  ImageIORegion m_ActualIORegion;
165 };
166 } //namespace ITK
167 
168 #ifndef ITK_MANUAL_INSTANTIATION
169 #include "itkImageFileReader.hxx"
170 #endif
171 
172 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER
173 #include "itkImageIOFactoryRegisterManager.h"
174 #endif
175 
176 #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.