ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkVTKImageIO.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 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef __itkVTKImageIO_h
29 #define __itkVTKImageIO_h
30 #include "ITKIOVTKExport.h"
31 
32 
33 #include <fstream>
35 
36 namespace itk
37 {
49 class ITKIOVTK_EXPORT VTKImageIO:
51 {
52 public:
54  typedef VTKImageIO Self;
58 
60  itkNewMacro(Self);
61 
63  itkTypeMacro(VTKImageIO, StreamingImageIOBase);
64 
65 // see super class for documentation
66  //
67  // overidden to return true only when supported
68  virtual bool CanStreamWrite(void) ITK_OVERRIDE;
69 
70  // see super class for documentation
71  //
72  // overidden to return true only when supported
73  virtual bool CanStreamRead(void) ITK_OVERRIDE;
74 
75 
76  /*-------- This part of the interface deals with reading data. ------ */
77 
80  virtual bool CanReadFile(const char *) ITK_OVERRIDE;
81 
83  virtual void ReadImageInformation() ITK_OVERRIDE;
84 
86  virtual void Read(void *buffer) ITK_OVERRIDE;
87 
88  /*-------- This part of the interfaces deals with writing data. ----- */
89 
92  virtual bool CanWriteFile(const char *) ITK_OVERRIDE;
93 
96  virtual void WriteImageInformation() ITK_OVERRIDE {}
97 
100  virtual void Write(const void *buffer) ITK_OVERRIDE;
101 
103  virtual SizeType GetHeaderSize() const ITK_OVERRIDE { return this->m_HeaderSize; }
104 
105 protected:
106  VTKImageIO();
107  ~VTKImageIO();
108 
109  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
110 
111  void InternalReadImageInformation(std::ifstream & file);
112 
113  void WriteImageInformation(const void *buffer);
114 
115  void ReadHeaderSize(std::ifstream & file);
116 
118  virtual void ReadBufferAsASCII(std::istream & os, void *buffer,
119  IOComponentType ctype,
120  SizeType numberOfBytesToBeRead) ITK_OVERRIDE;
121 
123  virtual void WriteBufferAsASCII(std::ostream & os, const void *buffer,
124  IOComponentType ctype,
125  SizeType numberOfBytesToWrite) ITK_OVERRIDE;
126 
129  virtual void ReadSymmetricTensorBufferAsBinary(std::istream& os,
130  void *buffer,
132 
135  virtual void WriteSymmetricTensorBufferAsBinary(std::ostream& os,
136  const void *buffer,
138 
139 private:
140  VTKImageIO(const Self &); //purposely not implemented
141  void operator=(const Self &); //purposely not implemented
142  void SetPixelTypeFromString(const std::string & pixelType);
143 
145  SizeType GetIORegionSizeInPixels() const;
146 
148  SizeType GetIORegionSizeInBytes() const;
149 
152  SizeType GetIORegionSizeInComponents() const;
153 
155 };
156 } // end namespace itk
157 
158 #endif // __itkVTKImageIO_h
Light weight base class for most itk classes.
A base class for specific ImageIO file formats which support streaming.
::itk::intmax_t SizeType
SmartPointer< Self > Pointer
Definition: itkVTKImageIO.h:56
ImageIO class for reading VTK images.
Definition: itkVTKImageIO.h:49
VTKImageIO Self
Definition: itkVTKImageIO.h:54
SizeType m_HeaderSize
Control indentation during Print() invocation.
Definition: itkIndent.h:49
SmartPointer< const Self > ConstPointer
Definition: itkVTKImageIO.h:57
virtual SizeType GetHeaderSize() const ITK_OVERRIDE
StreamingImageIOBase Superclass
Definition: itkVTKImageIO.h:55