ITK  4.4.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 
21 
22 #include <fstream>
23 #include "itkImageIOBase.h"
24 #include "metaObject.h"
25 #include "metaImage.h"
26 
27 namespace itk
28 {
39 class ITK_EXPORT MetaImageIO:public ImageIOBase
40 {
41 public:
43  typedef MetaImageIO Self;
46 
48  itkNewMacro(Self);
49 
51  itkTypeMacro(MetaImageIO, Superclass);
52 
58  virtual bool SupportsDimension(unsigned long)
59  {
60  return true;
61  }
62 
63  /*-------- This part of the interfaces deals with reading data. ----- */
64 
67  virtual bool CanReadFile(const char *);
68 
70  virtual void ReadImageInformation();
71 
73  virtual void Read(void *buffer);
74 
75  MetaImage * GetMetaImagePointer(void);
76 
77  /*-------- This part of the interfaces deals with writing data. ----- */
78 
81  virtual bool CanWriteFile(const char *);
82 
84  virtual void WriteImageInformation();
85 
88  virtual void Write(const void *buffer);
89 
93  virtual void SetDataFileName(const char *filename);
94 
97  virtual void SetDoublePrecision(unsigned int precision)
98  {
99  m_MetaImage.SetDoublePrecision(precision);
100  }
101 
106  virtual ImageIORegion
107  GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requested) const;
108 
109  virtual unsigned int
110  GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits,
111  const ImageIORegion & pasteRegion,
112  const ImageIORegion & largestPossibleRegion);
113 
114  virtual ImageIORegion
115  GetSplitRegionForWriting(unsigned int ithPiece,
116  unsigned int numberOfActualSplits,
117  const ImageIORegion & pasteRegion,
118  const ImageIORegion & largestPossibleRegion);
119 
123  virtual bool CanStreamRead()
124  {
125  if ( m_MetaImage.CompressedData() )
126  {
127  return false;
128  }
129  return true;
130  }
132 
138  virtual bool CanStreamWrite()
139  {
140  if ( this->GetUseCompression() )
141  {
142  return false;
143  }
144  return true;
145  }
147 
151  itkSetMacro(SubSamplingFactor, unsigned int);
152  itkGetConstMacro(SubSamplingFactor, unsigned int);
154 
155 protected:
156  MetaImageIO();
157  ~MetaImageIO();
158  void PrintSelf(std::ostream & os, Indent indent) const;
159 
160 private:
161 
162  MetaImage m_MetaImage;
163 
164  MetaImageIO(const Self &); //purposely not implemented
165  void operator=(const Self &); //purposely not implemented
166 
167  unsigned int m_SubSamplingFactor;
168 };
169 } // end namespace itk
170 
171 #endif // __itkMetaImageIO_h
172