ITK  4.6.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
20 #include "ITKIOImageBaseExport.h"
21 
22 #include "itkImageIOBase.h"
23 #include "itkImageSource.h"
24 #include "itkMacro.h"
25 #include "itkImageRegion.h"
28 
29 namespace itk
30 {
36 class ITK_ABI_EXPORT ImageFileReaderException:public ExceptionObject
37 {
38 public:
41 
43  ImageFileReaderException(const char *file, unsigned int line,
44  const char *message = "Error in IO",
45  const char *loc = "Unknown"):
46  ExceptionObject(file, line, message, loc)
47  {}
48 
50  ImageFileReaderException(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 
57  virtual ~ImageFileReaderException() throw( )
58  {}
59 };
61 
101 template< typename TOutputImage,
102  typename ConvertPixelTraits = DefaultConvertPixelTraits<
103  typename TOutputImage::IOPixelType > >
104 class ITKIOImageBase_HIDDEN ImageFileReader:public ImageSource< TOutputImage >
105 {
106 public:
111 
113  itkNewMacro(Self);
114 
116  itkTypeMacro(ImageFileReader, ImageSource);
117 
119  typedef typename TOutputImage::SizeType SizeType;
120 
122  typedef typename TOutputImage::IndexType IndexType;
123 
125  typedef typename TOutputImage::RegionType ImageRegionType;
126 
128  typedef typename TOutputImage::InternalPixelType OutputImagePixelType;
129 
131  itkSetGetDecoratedInputMacro(FileName, std::string);
132 
139  void SetImageIO(ImageIOBase *imageIO);
140  itkGetModifiableObjectMacro(ImageIO, ImageIOBase);
142 
145  virtual void GenerateOutputInformation(void);
146 
152  virtual void EnlargeOutputRequestedRegion(DataObject *output);
153 
155  itkSetMacro(UseStreaming, bool);
156  itkGetConstReferenceMacro(UseStreaming, bool);
157  itkBooleanMacro(UseStreaming);
159 
160 protected:
161  ImageFileReader();
162  ~ImageFileReader();
163  void PrintSelf(std::ostream & os, Indent indent) const;
164 
166  void DoConvertBuffer(void *buffer, size_t numberOfPixels);
167 
173  void TestFileExistanceAndReadability();
174 
176  virtual void GenerateData();
177 
179 
180  bool m_UserSpecifiedImageIO; // keep track whether the
181  // ImageIO is user specified
182 
184 
185 private:
186  ImageFileReader(const Self &); //purposely not implemented
187  void operator=(const Self &); //purposely not implemented
188 
189  std::string m_ExceptionMessage;
190 
191  // The region that the ImageIO class will return when we ask to
192  // produce the requested region.
194 };
195 } //namespace ITK
196 
197 #ifndef ITK_MANUAL_INSTANTIATION
198 #include "itkImageFileReader.hxx"
199 #endif
200 
201 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER
202 #include "itkImageIOFactoryRegisterManager.h"
203 #endif
204 
205 #endif // __itkImageFileReader_h
Base exception class for IO conflicts.
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
Standard exception handling object.
Data source that reads image data from a single file.
ImageIOBase::Pointer m_ImageIO
ImageFileReaderException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ImageFileReaderException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
ImageIORegion m_ActualIORegion
Base class for all data objects in ITK.