ITK  6.0.0
Insight Toolkit
itkVTKImageIO.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
36namespace itk
37{
50class ITKIOVTK_EXPORT VTKImageIO : public StreamingImageIOBase
51{
52public:
53 ITK_DISALLOW_COPY_AND_MOVE(VTKImageIO);
54
60
62 itkNewMacro(Self);
63
65 itkOverrideGetNameOfClassMacro(VTKImageIO);
66
67 // see super class for documentation
68 //
69 // overridden to return true only when supported
70 bool
71 CanStreamWrite() override;
72
73 // see super class for documentation
74 //
75 // overridden to return true only when supported
76 bool
77 CanStreamRead() override;
78
79
80 /*-------- This part of the interface deals with reading data. ------ */
81
84 bool
85 CanReadFile(const char *) override;
86
88 void
90
92 void
93 Read(void * buffer) override;
94
95 /*-------- This part of the interfaces deals with writing data. ----- */
96
99 bool
100 CanWriteFile(const char *) override;
101
104 void
106 {}
107
110 void
111 Write(const void * buffer) override;
112
115 GetHeaderSize() const override
116 {
117 return this->m_HeaderSize;
118 }
119
120protected:
122 ~VTKImageIO() override;
123
124 void
125 PrintSelf(std::ostream & os, Indent indent) const override;
126
127 void
128 InternalReadImageInformation(std::ifstream & file);
129
130 // Internal function to get next line from a given file (*.vtk)
131 int
132 GetNextLine(std::ifstream & ifs, std::string & line, bool lowerCase = true, SizeValueType count = 0);
133
134 void
135 WriteImageInformation(const void * buffer);
136
137 void
138 ReadHeaderSize(std::ifstream & file);
139
141 void
142 ReadBufferAsASCII(std::istream & is, void * buffer, IOComponentEnum ctype, SizeType numComp) override;
143
145 void
146 WriteBufferAsASCII(std::ostream & os, const void * buffer, IOComponentEnum ctype, SizeType numComp) override;
147
150 virtual void
152
155 virtual void
156 WriteSymmetricTensorBufferAsBinary(std::ostream & os, const void * buffer, StreamingImageIOBase::SizeType num);
157
158private:
159 void
160 SetPixelTypeFromString(const std::string & pixelType);
162
166
170
175
176 SizeType m_HeaderSize{};
177};
178} // end namespace itk
179
180#endif // itkVTKImageIO_h
itk::intmax_t SizeType
itk::SizeValueType SizeValueType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Base class for most ITK classes.
Definition: itkObject.h:62
A base class for specific ImageIO file formats which support streaming.
ImageIO class for reading VTK images.
Definition: itkVTKImageIO.h:51
virtual void ReadSymmetricTensorBufferAsBinary(std::istream &is, void *buffer, StreamingImageIOBase::SizeType num)
void PrintSelf(std::ostream &os, Indent indent) const override
void WriteImageInformation() override
SizeType GetIORegionSizeInBytes() const
void ReadImageInformation() override
~VTKImageIO() override
void InternalReadImageInformation(std::ifstream &file)
void Write(const void *buffer) override
SizeType GetIORegionSizeInComponents() const
bool CanReadFile(const char *) override
int GetNextLine(std::ifstream &ifs, std::string &line, bool lowerCase=true, SizeValueType count=0)
bool CanStreamWrite() override
void Read(void *buffer) override
SizeType GetHeaderSize() const override
bool CanStreamRead() override
void SetPixelTypeFromString(const std::string &pixelType)
void ReadBufferAsASCII(std::istream &is, void *buffer, IOComponentEnum ctype, SizeType numComp) override
virtual void WriteSymmetricTensorBufferAsBinary(std::ostream &os, const void *buffer, StreamingImageIOBase::SizeType num)
std::string GetComponentTypeAsString(IOComponentEnum)
bool CanWriteFile(const char *) override
void ReadHeaderSize(std::ifstream &file)
void WriteImageInformation(const void *buffer)
SizeType GetIORegionSizeInPixels() const
void WriteBufferAsASCII(std::ostream &os, const void *buffer, IOComponentEnum ctype, SizeType numComp) override
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....