18#ifndef itkMeshIOBase_h
19#define itkMeshIOBase_h
20#include "ITKIOMeshBaseExport.h"
92#ifndef ITK_LEGACY_REMOVE
98 class [[deprecated(
"This class is intended to be removed from ITK 6.")]] UnknownType
107 itkSetStringMacro(FileName);
108 itkGetStringMacro(FileName);
110#if !defined(ITK_LEGACY_REMOVE)
112 static constexpr IOPixelEnum UNKNOWNPIXELTYPE = IOPixelEnum::UNKNOWNPIXELTYPE;
113 static constexpr IOPixelEnum SCALAR = IOPixelEnum::SCALAR;
114 static constexpr IOPixelEnum RGB = IOPixelEnum::RGB;
115 static constexpr IOPixelEnum RGBA = IOPixelEnum::RGBA;
116 static constexpr IOPixelEnum OFFSET = IOPixelEnum::OFFSET;
117 static constexpr IOPixelEnum VECTOR = IOPixelEnum::VECTOR;
118 static constexpr IOPixelEnum POINT = IOPixelEnum::POINT;
119 static constexpr IOPixelEnum COVARIANTVECTOR = IOPixelEnum::COVARIANTVECTOR;
120 static constexpr IOPixelEnum SYMMETRICSECONDRANKTENSOR = IOPixelEnum::SYMMETRICSECONDRANKTENSOR;
121 static constexpr IOPixelEnum DIFFUSIONTENSOR3D = IOPixelEnum::DIFFUSIONTENSOR3D;
122 static constexpr IOPixelEnum COMPLEX = IOPixelEnum::COMPLEX;
123 static constexpr IOPixelEnum FIXEDARRAY = IOPixelEnum::FIXEDARRAY;
124 static constexpr IOPixelEnum ARRAY = IOPixelEnum::ARRAY;
125 static constexpr IOPixelEnum MATRIX = IOPixelEnum::MATRIX;
126 static constexpr IOPixelEnum VARIABLELENGTHVECTOR = IOPixelEnum::VARIABLELENGTHVECTOR;
127 static constexpr IOPixelEnum VARIABLESIZEMATRIX = IOPixelEnum::VARIABLESIZEMATRIX;
130#if !defined(ITK_LEGACY_REMOVE)
132 static constexpr IOComponentEnum UNKNOWNCOMPONENTTYPE = IOComponentEnum::UNKNOWNCOMPONENTTYPE;
141 static constexpr IOComponentEnum ULONGLONG = IOComponentEnum::ULONGLONG;
148#if !defined(ITK_LEGACY_REMOVE)
150 static constexpr IOFileEnum ASCII = IOFileEnum::ASCII;
151 static constexpr IOFileEnum BINARY = IOFileEnum::BINARY;
152 static constexpr IOFileEnum TYPENOTAPPLICABLE = IOFileEnum::TYPENOTAPPLICABLE;
155#if !defined(ITK_LEGACY_REMOVE)
157 static constexpr IOByteOrderEnum BigEndian = IOByteOrderEnum::BigEndian;
158 static constexpr IOByteOrderEnum LittleEndian = IOByteOrderEnum::LittleEndian;
159 static constexpr IOByteOrderEnum OrderNotApplicable = IOByteOrderEnum::OrderNotApplicable;
162#if !defined(ITK_LEGACY_REMOVE)
164 static constexpr IOFileModeEnum ReadMode = IOFileModeEnum::ReadMode;
165 static constexpr IOFileModeEnum WriteMode = IOFileModeEnum::WriteMode;
168#if !defined(ITK_LEGACY_REMOVE)
170 static constexpr CellGeometryEnum VERTEX_CELL = CellGeometryEnum::VERTEX_CELL;
172 static constexpr CellGeometryEnum TRIANGLE_CELL = CellGeometryEnum::TRIANGLE_CELL;
173 static constexpr CellGeometryEnum QUADRILATERAL_CELL = CellGeometryEnum::QUADRILATERAL_CELL;
174 static constexpr CellGeometryEnum POLYGON_CELL = CellGeometryEnum::POLYGON_CELL;
175 static constexpr CellGeometryEnum TETRAHEDRON_CELL = CellGeometryEnum::TETRAHEDRON_CELL;
176 static constexpr CellGeometryEnum HEXAHEDRON_CELL = CellGeometryEnum::HEXAHEDRON_CELL;
177 static constexpr CellGeometryEnum QUADRATIC_EDGE_CELL = CellGeometryEnum::QUADRATIC_EDGE_CELL;
178 static constexpr CellGeometryEnum QUADRATIC_TRIANGLE_CELL = CellGeometryEnum::QUADRATIC_TRIANGLE_CELL;
179 static constexpr CellGeometryEnum LAST_ITK_CELL = CellGeometryEnum::LAST_ITK_CELL;
180 static constexpr CellGeometryEnum MAX_ITK_CELLS = CellGeometryEnum::MAX_ITK_CELLS;
207 template <
typename TComponent>
211 std::is_same_v<TComponent, unsigned char> ? IOComponentEnum::UCHAR
212 : std::is_same_v<TComponent, char> ? IOComponentEnum::CHAR
213 : std::is_same_v<TComponent, short> ? IOComponentEnum::SHORT
214 : std::is_same_v<TComponent, unsigned short> ? IOComponentEnum::USHORT
215 : std::is_same_v<TComponent, int> ? IOComponentEnum::INT
216 : std::is_same_v<TComponent, unsigned int> ? IOComponentEnum::UINT
217 : std::is_same_v<TComponent, long> ? IOComponentEnum::LONG
218 : std::is_same_v<TComponent, unsigned long> ? IOComponentEnum::ULONG
219 : std::is_same_v<TComponent, long long> ? IOComponentEnum::LONGLONG
220 : std::is_same_v<TComponent, unsigned long long> ? IOComponentEnum::ULONGLONG
221 : std::is_same_v<TComponent, float> ? IOComponentEnum::FLOAT
222 : std::is_same_v<TComponent, double> ? IOComponentEnum::DOUBLE
223 : std::is_same_v<TComponent, long double> ? IOComponentEnum::LDOUBLE
224 : IOComponentEnum::UNKNOWNCOMPONENTTYPE;
227 template <
typename T>
245 template <
typename T>
263 template <
typename T>
281 template <
typename T,
unsigned int VLength>
299 template <
typename T,
unsigned int VLength>
317 template <
typename T,
unsigned int VLength>
335 template <
typename T,
unsigned int VLength>
353 template <
typename T>
371 template <
typename T,
unsigned int VRows,
unsigned int VColumns>
389 template <
typename T>
391 SetPixelType(
const std::complex<T> & itkNotUsed(dummy),
bool usePointPixel =
true)
407 template <
typename T>
425 template <
typename T>
443 template <
typename T>
466 itkSetMacro(NumberOfPointPixelComponents,
unsigned int);
467 itkGetConstMacro(NumberOfPointPixelComponents,
unsigned int);
468 itkSetMacro(NumberOfCellPixelComponents,
unsigned int);
469 itkGetConstMacro(NumberOfCellPixelComponents,
unsigned int);
470 itkSetMacro(PointDimension,
unsigned int);
471 itkGetConstMacro(PointDimension,
unsigned int);
482 itkSetMacro(UpdatePoints,
bool);
483 itkGetConstMacro(UpdatePoints,
bool);
484 itkBooleanMacro(UpdatePoints);
485 itkSetMacro(UpdateCells,
bool);
486 itkGetConstMacro(UpdateCells,
bool);
487 itkBooleanMacro(UpdateCells);
488 itkSetMacro(UpdatePointData,
bool);
489 itkGetConstMacro(UpdatePointData,
bool);
490 itkBooleanMacro(UpdatePointData);
491 itkSetMacro(UpdateCellData,
bool);
492 itkGetConstMacro(UpdateCellData,
bool);
493 itkBooleanMacro(UpdateCellData);
553 itkSetMacro(UseCompression,
bool);
554 itkGetConstMacro(UseCompression,
bool);
555 itkBooleanMacro(UseCompression);
644 template <
typename T>
650 inputFile >> buffer[i];
655 template <
typename T>
659 inputFile.read(
reinterpret_cast<char *
>(buffer), numberOfComponents *
sizeof(T));
668 else if (
m_ByteOrder == IOByteOrderEnum::LittleEndian)
678 template <
typename T>
681 std::ofstream & outputFile,
696 template <
typename TOutput,
typename TInput>
700 if (
typeid(TInput) ==
typeid(TOutput))
711 outputFile.write(
reinterpret_cast<char *
>(buffer), numberOfComponents);
718 data[ii] =
static_cast<TOutput
>(buffer[ii]);
730 outputFile.write(
reinterpret_cast<char *
>(data.get()), numberOfComponents);
737 template <
typename TInput,
typename TOutput>
748 auto numberOfPoints =
static_cast<unsigned int>(input[inputIndex++]);
749 for (
unsigned int jj = 0; jj < numberOfPoints; ++jj)
751 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
760 template <
typename TInput,
typename TOutput>
772 auto nn =
static_cast<unsigned int>(input[inputIndex++]);
773 if (cellType == type)
775 output[outputIndex++] = nn;
776 for (
unsigned int jj = 0; jj < nn; ++jj)
778 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
791 template <
typename TInput,
typename TOutput>
796 unsigned int numberOfPoints,
805 output[outputIndex++] =
static_cast<TOutput
>(cellType);
806 output[outputIndex++] =
static_cast<TOutput
>(numberOfPoints);
807 for (
unsigned int jj = 0; jj < numberOfPoints; ++jj)
809 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
817 template <
typename TInput,
typename TOutput>
827 auto numberOfPoints =
static_cast<unsigned int>(input[inputIndex++]);
828 if (numberOfPoints > 2 && cellType == CellGeometryEnum::LINE_CELL)
830 output[outputIndex++] =
static_cast<TOutput
>(CellGeometryEnum::POLYLINE_CELL);
834 output[outputIndex++] =
static_cast<TOutput
>(cellType);
836 output[outputIndex++] =
static_cast<TOutput
>(numberOfPoints);
838 for (
unsigned int jj = 0; jj < numberOfPoints; ++jj)
840 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
Array class with size defined at construction time.
SizeValueType Size() const
static constexpr bool SystemIsBigEndian()
static void SwapRangeFromSystemToLittleEndian(T *p, BufferSizeType num)
static constexpr bool SystemIsLittleEndian()
static void SwapRangeFromSystemToBigEndian(T *p, BufferSizeType num)
A templated class holding a n-Dimensional covariant vector.
Represent a diffusion tensor as used in DTI images.
Simulate a standard C array with copy semantics.
Control indentation during Print() invocation.
A templated class holding a M x N size Matrix.
IOPixelEnum m_CellPixelType
virtual void SetFileType(const IOFileEnum _arg)
void ReadCellsBuffer(TInput *input, TOutput *output, CellGeometryEnum type)
void WriteBufferAsBinary(TInput *buffer, std::ofstream &outputFile, SizeValueType numberOfComponents)
void SetPixelType(const FixedArray< T, VLength > &dummy, bool usePointPixel=true)
unsigned int m_NumberOfPointPixelComponents
IOByteOrderEnum m_ByteOrder
SmartPointer< Self > Pointer
virtual void SetPointPixelComponentType(const itk::CommonEnums::IOComponent _arg)
SizeValueType m_NumberOfPoints
void SetPixelType(const T &dummy, bool usePointPixel=true)
void WriteBufferAsAscii(T *buffer, std::ofstream &outputFile, SizeValueType numberOfLines, SizeValueType numberOfComponents)
SizeValueType m_CellBufferSize
void SetFileTypeToBinary()
std::string GetFileTypeAsString(IOFileEnum) const
IdentifierType SizeValueType
void SetPixelType(const VariableSizeMatrix< T > &matrix, bool usePointPixel=true)
virtual void ReadPointData(void *buffer)=0
virtual void SetByteOrder(const IOByteOrderEnum _arg)
virtual void WritePoints(void *buffer)=0
static std::string GetComponentTypeAsString(IOComponentEnum)
ArrayOfExtensionsType m_SupportedReadExtensions
void SetPixelType(const RGBPixel< T > &dummy, bool usePointPixel=true)
void WriteCellsBuffer(TInput *input, TOutput *output, CellGeometryEnum cellType, unsigned int numberOfPoints, SizeValueType numberOfCells)
virtual void WriteMeshInformation()=0
virtual void WriteCells(void *buffer)=0
unsigned int m_PointDimension
unsigned int GetComponentSize(IOComponentEnum componentType) const
void AddSupportedReadExtension(const char *extension)
virtual void ReadMeshInformation()=0
virtual void ReadCells(void *buffer)=0
static std::string GetPixelTypeAsString(IOPixelEnum)
virtual void SetNumberOfCellPixelComponents(unsigned int _arg)
IOPixelEnum m_PointPixelType
void SetPixelType(const Vector< T, VLength > &dummy, bool usePointPixel=true)
void SetPixelType(const RGBAPixel< T > &dummy, bool usePointPixel=true)
virtual bool CanReadFile(const char *)=0
void ReadBufferAsBinary(T *buffer, std::ifstream &inputFile, SizeValueType numberOfComponents)
void SetPixelType(const std::complex< T > &dummy, bool usePointPixel=true)
SmartPointer< const Self > ConstPointer
const ArrayOfExtensionsType & GetSupportedReadExtensions() const
virtual void SetNumberOfPointPixelComponents(unsigned int _arg)
virtual void WriteCellData(void *buffer)=0
void SetPixelType(const VariableLengthVector< T > &vector, bool usePointPixel=true)
IOComponentEnum m_PointComponentType
std::string GetByteOrderAsString(IOByteOrderEnum) const
IOComponentEnum m_CellPixelComponentType
void ReadCellsBuffer(TInput *input, TOutput *output)
void PrintSelf(std::ostream &os, Indent indent) const override
void SetPixelType(const DiffusionTensor3D< T > &dummy, bool usePointPixel=true)
const ArrayOfExtensionsType & GetSupportedWriteExtensions() const
void SetPixelType(const SymmetricSecondRankTensor< T, VLength > dummy, bool usePointPixel=true)
SizeValueType m_NumberOfPointPixels
SizeValueType m_NumberOfCellPixels
virtual bool CanWriteFile(const char *)=0
void SetByteOrderToBigEndian()
IOComponentEnum m_PointPixelComponentType
std::streamoff StreamOffsetType
virtual void SetCellPixelComponentType(const itk::CommonEnums::IOComponent _arg)
void SetPixelType(const Matrix< T, VRows, VColumns > &dummy, bool usePointPixel=true)
~MeshIOBase() override=default
void SetByteOrderToLittleEndian()
void SetFileTypeToASCII()
virtual void WritePointData(void *buffer)=0
virtual void SetCellPixelType(const itk::CommonEnums::IOPixel _arg)
std::vector< std::string > ArrayOfExtensionsType
IOComponentEnum m_CellComponentType
LightProcessObject Superclass
virtual void ReadCellData(void *buffer)=0
void SetPixelType(const Array< T > &array, bool usePointPixel=true)
void AddSupportedWriteExtension(const char *extension)
ArrayOfExtensionsType m_SupportedWriteExtensions
virtual void ReadPoints(void *buffer)=0
void ReadBufferAsAscii(T *buffer, std::ifstream &inputFile, SizeValueType numberOfComponents)
virtual void SetPointPixelType(const itk::CommonEnums::IOPixel _arg)
unsigned int m_NumberOfCellPixelComponents
void SetPixelType(const CovariantVector< T, VLength > &dummy, bool usePointPixel=true)
SizeValueType m_NumberOfCells
void WriteCellsBuffer(TInput *input, TOutput *output, CellGeometryEnum cellType, SizeValueType numberOfCells)
Represent Red, Green, Blue and Alpha components for color images.
Represent Red, Green and Blue components for color images.
Implements transparent reference counting.
Represent a symmetric tensor of second rank.
A templated class holding a M x N size Matrix.
unsigned int Cols() const
unsigned int Rows() const
A templated class holding a n-Dimensional vector.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType IdentifierType
CommonEnums::IOComponent IOComponentEnum
std::string ConvertNumberToString(const TValue val)
CommonEnums::IOFile IOFileEnum
CommonEnums::IOByteOrder IOByteOrderEnum
CommonEnums::CellGeometry CellGeometryEnum
CommonEnums::IOPixel IOPixelEnum
CommonEnums::IOFileMode IOFileModeEnum
auto make_unique_for_overwrite(const vcl_size_t numberOfElements)
static constexpr IOComponentEnum CType