ITK  4.2.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 {
36 class ITK_EXPORT MetaImageIO:public ImageIOBase
37 {
38 public:
40  typedef MetaImageIO Self;
43 
45  itkNewMacro(Self);
46 
48  itkTypeMacro(MetaImageIO, Superclass);
49 
55  virtual bool SupportsDimension(unsigned long)
56  {
57  return true;
58  }
59 
60  /*-------- This part of the interfaces deals with reading data. ----- */
61 
64  virtual bool CanReadFile(const char *);
65 
67  virtual void ReadImageInformation();
68 
70  virtual void Read(void *buffer);
71 
72  MetaImage * GetMetaImagePointer(void);
73 
74  /*-------- This part of the interfaces deals with writing data. ----- */
75 
78  virtual bool CanWriteFile(const char *);
79 
81  virtual void WriteImageInformation();
82 
85  virtual void Write(const void *buffer);
86 
90  virtual void SetDataFileName(const char *filename);
91 
94  virtual void SetDoublePrecision(unsigned int precision)
95  {
96  m_MetaImage.SetDoublePrecision(precision);
97  }
98 
103  virtual ImageIORegion
104  GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requested) const;
105 
106  virtual unsigned int
107  GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits,
108  const ImageIORegion & pasteRegion,
109  const ImageIORegion & largestPossibleRegion);
110 
111  virtual ImageIORegion
112  GetSplitRegionForWriting(unsigned int ithPiece,
113  unsigned int numberOfActualSplits,
114  const ImageIORegion & pasteRegion,
115  const ImageIORegion & largestPossibleRegion);
116 
120  virtual bool CanStreamRead()
121  {
122  if ( m_MetaImage.CompressedData() )
123  {
124  return false;
125  }
126  return true;
127  }
129 
135  virtual bool CanStreamWrite()
136  {
137  if ( this->GetUseCompression() )
138  {
139  return false;
140  }
141  return true;
142  }
144 
148  itkSetMacro(SubSamplingFactor, unsigned int);
149  itkGetConstMacro(SubSamplingFactor, unsigned int);
150 protected:
151  MetaImageIO();
152  ~MetaImageIO();
153  void PrintSelf(std::ostream & os, Indent indent) const;
155 
156 private:
157 
158  MetaImage m_MetaImage;
159 
160  MetaImageIO(const Self &); //purposely not implemented
161  void operator=(const Self &); //purposely not implemented
162 
163  unsigned int m_SubSamplingFactor;
164 };
165 } // end namespace itk
166 
167 #endif // __itkMetaImageIO_h
168