ITK  5.0.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 ITK_TEMPLATE_EXPORT ImageFileReader:public ImageSource< TOutputImage >
77 {
78 public:
79  ITK_DISALLOW_COPY_AND_ASSIGN(ImageFileReader);
80 
85 
87  itkNewMacro(Self);
88 
90  itkTypeMacro(ImageFileReader, ImageSource);
91 
93  using SizeType = typename TOutputImage::SizeType;
94 
97 
100 
102  using OutputImagePixelType = typename TOutputImage::InternalPixelType;
103 
105  itkSetGetDecoratedInputMacro(FileName, std::string);
106 
113  void SetImageIO(ImageIOBase *imageIO);
114  itkGetModifiableObjectMacro(ImageIO, ImageIOBase);
116 
118  itkSetMacro(UseStreaming, bool);
119  itkGetConstReferenceMacro(UseStreaming, bool);
120  itkBooleanMacro(UseStreaming);
122 
123 protected:
124  ImageFileReader();
125  ~ImageFileReader() override = default;
126  void PrintSelf(std::ostream & os, Indent indent) const override;
127 
129  void DoConvertBuffer(void *buffer, size_t numberOfPixels);
130 
136  void TestFileExistanceAndReadability();
137 
140  void GenerateOutputInformation() override;
141 
147  void EnlargeOutputRequestedRegion(DataObject *output) override;
148 
150  void GenerateData() override;
151 
153 
154  bool m_UserSpecifiedImageIO; // keep track whether the
155  // ImageIO is user specified
156 
158 
159 private:
160  std::string m_ExceptionMessage;
161 
162  // The region that the ImageIO class will return when we ask to
163  // produce the requested region.
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
An ImageIORegion represents a structured region of data.
Abstract superclass defines image IO interface.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename OutputImageType::PixelType OutputImagePixelType
Data source that reads image data from a single file.
ImageIOBase::Pointer m_ImageIO
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename TOutputImage::SizeType SizeType
typename TOutputImage::RegionType ImageRegionType
ImageIORegion m_ActualIORegion
Base class for all data objects in ITK.
typename TOutputImage::IndexType IndexType