ITK  6.0.0
Insight Toolkit
itkGiftiMeshIO.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 itkGiftiMeshIO_h
19#define itkGiftiMeshIO_h
20#include "ITKIOMeshGiftiExport.h"
21
22#include <memory>
23#include "itkMapContainer.h"
24#include "itkMatrix.h"
25#include "itkMeshIOBase.h"
26#include "itkRGBAPixel.h"
27
28#include <fstream>
29#include <string>
30
31namespace itk
32{
39class ITKIOMeshGifti_EXPORT GiftiMeshIO : public MeshIOBase
40{
41public:
42 ITK_DISALLOW_COPY_AND_MOVE(GiftiMeshIO);
43
49
57
59 itkNewMacro(Self);
60
62 itkOverrideGetNameOfClassMacro(GiftiMeshIO);
63
64 itkGetConstMacro(ReadPointData, bool);
65 itkSetMacro(ReadPointData, bool);
66 itkBooleanMacro(ReadPointData);
67
68 void
69 SetDirection(const DirectionType & direction);
70
71 itkGetConstReferenceMacro(Direction, DirectionType);
72
77 void
79 void
81
82 /*-------- This part of the interfaces deals with reading data. ----- */
83
89 bool
90 CanReadFile(const char * fileName) override;
91
93 void
95
97 void
98 ReadPoints(void * buffer) override;
99
100 void
101 ReadCells(void * buffer) override;
102
103 void
104 ReadPointData(void * buffer) override;
105
106 void
107 ReadCellData(void * buffer) override;
108
109 /*-------- This part of the interfaces deals with writing data. ----- */
110
116 bool
117 CanWriteFile(const char * fileName) override;
118
120 void
122
125 void
126 WritePoints(void * buffer) override;
127
128 void
129 WriteCells(void * buffer) override;
130
131 void
132 WritePointData(void * buffer) override;
133
134 void
135 WriteCellData(void * buffer) override;
136
137 void
138 Write() override;
139
140protected:
142 ~GiftiMeshIO() override;
143
144 void
145 PrintSelf(std::ostream & os, Indent indent) const override;
146
147 template <typename TInput, typename TOutput>
148 void
149 ConvertBuffer(TInput * input, TOutput * output, SizeValueType numberOfElements)
150 {
151 if (input && output)
152 {
153 for (SizeValueType ii = 0; ii < numberOfElements; ++ii)
154 {
155 output[ii] = static_cast<TOutput>(input[ii]);
156 }
157 }
158 }
159
160private:
161 // This proxy class provides a gifti_image pointer interface to the internal implementation
162 // of itk::GiftiImageIO, while hiding the gifticlib interface from the external ITK interface.
163 class GiftiImageProxy;
164
165 // Note that it is essential that m_GiftiImageHolder is defined before m_GiftiImage, to ensure that
166 // m_GiftiImage can directly get a proxy from m_GiftiImageHolder during GiftiImageIO construction.
167 const std::unique_ptr<GiftiImageProxy> m_GiftiImageHolder;
168
169 GiftiImageProxy & m_GiftiImage;
170
171 bool m_ReadPointData{};
172 DirectionType m_Direction{};
173
174 // Translate (G|N)ifti datatypes to IOComponentEnum
177
178 // Translate (G|N)ifti datatypes to IOPixelEnum
181
182 int
184};
185} // end namespace itk
186
187#endif
This class defines how to read and write Gifti file format.
const std::unique_ptr< GiftiImageProxy > m_GiftiImageHolder
~GiftiMeshIO() override
void SetLabelNameTable(const LabelNameContainer *labelMap)
void ConvertBuffer(TInput *input, TOutput *output, SizeValueType numberOfElements)
void Write() override
IOComponentEnum GetComponentTypeFromGifti(int datatype)
void WriteMeshInformation() override
void ReadPoints(void *buffer) override
void WriteCells(void *buffer) override
void SetDirection(const DirectionType &direction)
void WriteCellData(void *buffer) override
void ReadMeshInformation() override
bool CanWriteFile(const char *fileName) override
IOPixelEnum GetPixelTypeFromGifti(int datatype)
bool CanReadFile(const char *fileName) override
LabelColorContainerPointer GetLabelColorTable()
GiftiImageProxy & m_GiftiImage
void PrintSelf(std::ostream &os, Indent indent) const override
void ReadCells(void *buffer) override
void ReadCellData(void *buffer) override
void SetLabelColorTable(const LabelColorContainer *colorMap)
void ReadPointData(void *buffer) override
LabelNameContainerPointer GetLabelNameTable()
int GetNumberOfPixelComponentsFromGifti(int datatype)
void WritePoints(void *buffer) override
void WritePointData(void *buffer) override
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
A wrapper of the STL "map" container.
Abstract superclass defines mesh IO interface.
Definition: itkMeshIOBase.h:73
IdentifierType SizeValueType
Definition: itkMeshIOBase.h:89
Base class for most ITK classes.
Definition: itkObject.h:62
Represent Red, Green, Blue and Alpha components for color images.
Definition: itkRGBAPixel.h:60
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86