ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkMetaImageIO.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 itkMetaImageIO_h
19 #define itkMetaImageIO_h
20 #include "ITKIOMetaExport.h"
21 
22 
23 #include <fstream>
24 #include "itkImageIOBase.h"
25 #include "metaObject.h"
26 #include "metaImage.h"
27 
28 namespace itk
29 {
40 class ITKIOMeta_EXPORT MetaImageIO:public ImageIOBase
41 {
42 public:
44  typedef MetaImageIO Self;
47 
49  itkNewMacro(Self);
50 
52  itkTypeMacro(MetaImageIO, Superclass);
53 
59  virtual bool SupportsDimension(unsigned long) ITK_OVERRIDE
60  {
61  return true;
62  }
63 
64  /*-------- This part of the interfaces deals with reading data. ----- */
65 
68  virtual bool CanReadFile(const char *) ITK_OVERRIDE;
69 
71  virtual void ReadImageInformation() ITK_OVERRIDE;
72 
74  virtual void Read(void *buffer) ITK_OVERRIDE;
75 
76  MetaImage * GetMetaImagePointer();
77 
78  /*-------- This part of the interfaces deals with writing data. ----- */
79 
82  virtual bool CanWriteFile(const char *) ITK_OVERRIDE;
83 
85  virtual void WriteImageInformation() ITK_OVERRIDE;
86 
89  virtual void Write(const void *buffer) ITK_OVERRIDE;
90 
94  virtual void SetDataFileName(const char *filename);
95 
98  virtual void SetDoublePrecision(unsigned int precision)
99  {
100  m_MetaImage.SetDoublePrecision(precision);
101  }
102 
107  virtual ImageIORegion
108  GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requested) const ITK_OVERRIDE;
109 
110  virtual unsigned int
111  GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits,
112  const ImageIORegion & pasteRegion,
113  const ImageIORegion & largestPossibleRegion) ITK_OVERRIDE;
114 
115  virtual ImageIORegion
116  GetSplitRegionForWriting(unsigned int ithPiece,
117  unsigned int numberOfActualSplits,
118  const ImageIORegion & pasteRegion,
119  const ImageIORegion & largestPossibleRegion) ITK_OVERRIDE;
120 
124  virtual bool CanStreamRead() ITK_OVERRIDE
125  {
126  if ( m_MetaImage.CompressedData() )
127  {
128  return false;
129  }
130  return true;
131  }
133 
139  virtual bool CanStreamWrite() ITK_OVERRIDE
140  {
141  if ( this->GetUseCompression() )
142  {
143  return false;
144  }
145  return true;
146  }
148 
152  itkSetMacro(SubSamplingFactor, unsigned int);
153  itkGetConstMacro(SubSamplingFactor, unsigned int);
155 
156 protected:
157  MetaImageIO();
158  ~MetaImageIO();
159  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
160 
161 private:
162 
163  MetaImage m_MetaImage;
164 
165  MetaImageIO(const Self &); //purposely not implemented
166  void operator=(const Self &); //purposely not implemented
167 
168  unsigned int m_SubSamplingFactor;
169 };
170 } // end namespace itk
171 
172 #endif // itkMetaImageIO_h
Light weight base class for most itk classes.
MetaImage m_MetaImage
An ImageIORegion represents a structured region of data.
Abstract superclass defines image IO interface.
SmartPointer< Self > Pointer
ImageIOBase Superclass
virtual bool SupportsDimension(unsigned long) override
MetaImageIO Self
virtual bool CanStreamRead() override
unsigned int m_SubSamplingFactor
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual bool CanStreamWrite() override
Base class for most ITK classes.
Definition: itkObject.h:57
Read MetaImage file format.