ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkVTIImageIO.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#ifndef itkVTIImageIO_h
19#define itkVTIImageIO_h
20#include "ITKIOVTKExport.h"
21
22#include <fstream>
23#include "itkImageIOBase.h"
24
25namespace itk
26{
94class ITKIOVTK_EXPORT VTIImageIO : public ImageIOBase
95{
96public:
97 ITK_DISALLOW_COPY_AND_MOVE(VTIImageIO);
98
104
106 itkNewMacro(Self);
107
109 itkOverrideGetNameOfClassMacro(VTIImageIO);
110
111 /*-------- This part of the interface deals with reading data. ------ */
112
115 bool
116 CanReadFile(const char *) override;
117
119 void
121
123 void
124 Read(void * buffer) override;
125
126 /*-------- This part of the interfaces deals with writing data. ----- */
127
130 bool
131 CanWriteFile(const char *) override;
132
135 void
137 {}
138
141 void
142 Write(const void * buffer) override;
143
152 static void
154 std::size_t componentSize,
155 std::size_t numComponents,
156 IOByteOrderEnum fileByteOrder,
157 IOByteOrderEnum targetByteOrder);
158
159protected:
161 ~VTIImageIO() override;
162
163 void
164 PrintSelf(std::ostream & os, Indent indent) const override;
165
166private:
168 static IOComponentEnum
169 VTKTypeStringToITKComponent(const std::string & vtkType);
170
172 static std::string
174
177 static SizeType
178 DecodeBase64(const std::string & encoded, std::vector<unsigned char> & decoded);
179
181 static std::string
182 EncodeBase64(const unsigned char * data, SizeType numBytes);
183
185 static std::string
186 TrimString(const std::string & s);
187
188 // Encoding format of the data array found in the file.
189 // (Plain comment, not doxygen, to satisfy KWStyle's `\class` rule for
190 // class-like declarations.)
191 enum class DataEncoding : std::uint8_t
192 {
194 Base64, // binary data encoded in base64 (format="binary")
195 RawAppended, // raw binary appended data (format="appended" with encoding="raw")
196 Base64Appended, // base64-encoded appended data (format="appended" with encoding="base64")
197 ZLibBase64, // zlib-compressed data encoded in base64 (inline)
198 ZLibAppended, // zlib-compressed raw appended data
199 ZLibBase64Appended // zlib-compressed base64 appended data
200 };
201
203
206 std::string m_AsciiDataContent{};
207
210 std::string m_Base64DataContent{};
211
214 std::streampos m_AppendedDataOffset{ 0 };
215
219
221 bool m_HeaderTypeUInt64{ false };
222
224 bool m_IsZLibCompressed{ false };
225
228
231
236 static void
237 DecompressZLib(const unsigned char * compressedData,
238 std::size_t compressedDataSize,
239 bool headerUInt64,
240 std::vector<unsigned char> & uncompressed);
241};
242} // end namespace itk
243
244#endif // itkVTIImageIO_h
itk::intmax_t SizeType
itk::IOByteOrderEnum IOByteOrderEnum
itk::IOComponentEnum IOComponentEnum
Control indentation during Print() invocation.
Definition itkIndent.h:50
Implements transparent reference counting.
static void DecompressZLib(const unsigned char *compressedData, std::vcl_size_t compressedDataSize, bool headerUInt64, std::vector< unsigned char > &uncompressed)
SmartPointer< Self > Pointer
static std::string TrimString(const std::string &s)
DataEncoding m_DataEncoding
bool CanWriteFile(const char *) override
std::string m_AsciiDataContent
SizeType m_DataArrayOffset
static std::string EncodeBase64(const unsigned char *data, SizeType numBytes)
SmartPointer< const Self > ConstPointer
std::streampos m_AppendedDataOffset
void PrintSelf(std::ostream &os, Indent indent) const override
static std::string ITKComponentToVTKTypeString(IOComponentEnum t)
bool CanReadFile(const char *) override
std::string m_Base64DataContent
static SizeType DecodeBase64(const std::string &encoded, std::vector< unsigned char > &decoded)
static IOComponentEnum VTKTypeStringToITKComponent(const std::string &vtkType)
std::string m_AppendedBase64Content
static void SwapBufferForByteOrder(void *buffer, std::vcl_size_t componentSize, std::vcl_size_t numComponents, IOByteOrderEnum fileByteOrder, IOByteOrderEnum targetByteOrder)
~VTIImageIO() override
void Read(void *buffer) override
ImageIOBase Superclass
void WriteImageInformation() override
void ReadImageInformation() override
void Write(const void *buffer) override
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....