18#ifndef itkMeshIOBase_h
19#define itkMeshIOBase_h
20#include "ITKIOMeshBaseExport.h"
104 itkSetStringMacro(FileName);
105 itkGetStringMacro(FileName);
107#if !defined(ITK_LEGACY_REMOVE)
109 static constexpr IOPixelEnum UNKNOWNPIXELTYPE = IOPixelEnum::UNKNOWNPIXELTYPE;
110 static constexpr IOPixelEnum SCALAR = IOPixelEnum::SCALAR;
111 static constexpr IOPixelEnum RGB = IOPixelEnum::RGB;
112 static constexpr IOPixelEnum RGBA = IOPixelEnum::RGBA;
113 static constexpr IOPixelEnum OFFSET = IOPixelEnum::OFFSET;
114 static constexpr IOPixelEnum VECTOR = IOPixelEnum::VECTOR;
115 static constexpr IOPixelEnum POINT = IOPixelEnum::POINT;
116 static constexpr IOPixelEnum COVARIANTVECTOR = IOPixelEnum::COVARIANTVECTOR;
117 static constexpr IOPixelEnum SYMMETRICSECONDRANKTENSOR = IOPixelEnum::SYMMETRICSECONDRANKTENSOR;
118 static constexpr IOPixelEnum DIFFUSIONTENSOR3D = IOPixelEnum::DIFFUSIONTENSOR3D;
119 static constexpr IOPixelEnum COMPLEX = IOPixelEnum::COMPLEX;
120 static constexpr IOPixelEnum FIXEDARRAY = IOPixelEnum::FIXEDARRAY;
121 static constexpr IOPixelEnum ARRAY = IOPixelEnum::ARRAY;
122 static constexpr IOPixelEnum MATRIX = IOPixelEnum::MATRIX;
123 static constexpr IOPixelEnum VARIABLELENGTHVECTOR = IOPixelEnum::VARIABLELENGTHVECTOR;
124 static constexpr IOPixelEnum VARIABLESIZEMATRIX = IOPixelEnum::VARIABLESIZEMATRIX;
127#if !defined(ITK_LEGACY_REMOVE)
129 static constexpr IOComponentEnum UNKNOWNCOMPONENTTYPE = IOComponentEnum::UNKNOWNCOMPONENTTYPE;
138 static constexpr IOComponentEnum ULONGLONG = IOComponentEnum::ULONGLONG;
145#if !defined(ITK_LEGACY_REMOVE)
147 static constexpr IOFileEnum ASCII = IOFileEnum::ASCII;
148 static constexpr IOFileEnum BINARY = IOFileEnum::BINARY;
149 static constexpr IOFileEnum TYPENOTAPPLICABLE = IOFileEnum::TYPENOTAPPLICABLE;
152#if !defined(ITK_LEGACY_REMOVE)
154 static constexpr IOByteOrderEnum BigEndian = IOByteOrderEnum::BigEndian;
155 static constexpr IOByteOrderEnum LittleEndian = IOByteOrderEnum::LittleEndian;
156 static constexpr IOByteOrderEnum OrderNotApplicable = IOByteOrderEnum::OrderNotApplicable;
159#if !defined(ITK_LEGACY_REMOVE)
161 static constexpr IOFileModeEnum ReadMode = IOFileModeEnum::ReadMode;
162 static constexpr IOFileModeEnum WriteMode = IOFileModeEnum::WriteMode;
165#if !defined(ITK_LEGACY_REMOVE)
167 static constexpr CellGeometryEnum VERTEX_CELL = CellGeometryEnum::VERTEX_CELL;
169 static constexpr CellGeometryEnum TRIANGLE_CELL = CellGeometryEnum::TRIANGLE_CELL;
170 static constexpr CellGeometryEnum QUADRILATERAL_CELL = CellGeometryEnum::QUADRILATERAL_CELL;
171 static constexpr CellGeometryEnum POLYGON_CELL = CellGeometryEnum::POLYGON_CELL;
172 static constexpr CellGeometryEnum TETRAHEDRON_CELL = CellGeometryEnum::TETRAHEDRON_CELL;
173 static constexpr CellGeometryEnum HEXAHEDRON_CELL = CellGeometryEnum::HEXAHEDRON_CELL;
174 static constexpr CellGeometryEnum QUADRATIC_EDGE_CELL = CellGeometryEnum::QUADRATIC_EDGE_CELL;
175 static constexpr CellGeometryEnum QUADRATIC_TRIANGLE_CELL = CellGeometryEnum::QUADRATIC_TRIANGLE_CELL;
176 static constexpr CellGeometryEnum LAST_ITK_CELL = CellGeometryEnum::LAST_ITK_CELL;
177 static constexpr CellGeometryEnum MAX_ITK_CELLS = CellGeometryEnum::MAX_ITK_CELLS;
203 template <
typename T>
209 template <
typename T>
227 template <
typename T>
245 template <
typename T>
263 template <
typename T,
unsigned int VLength>
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>
353 template <
typename T,
unsigned int VRows,
unsigned int VColumns>
371 template <
typename T>
373 SetPixelType(
const std::complex<T> & itkNotUsed(dummy),
bool usePointPixel =
true)
389 template <
typename T>
407 template <
typename T>
425 template <
typename T>
448 itkSetMacro(NumberOfPointPixelComponents,
unsigned int);
449 itkGetConstMacro(NumberOfPointPixelComponents,
unsigned int);
450 itkSetMacro(NumberOfCellPixelComponents,
unsigned int);
451 itkGetConstMacro(NumberOfCellPixelComponents,
unsigned int);
452 itkSetMacro(PointDimension,
unsigned int);
453 itkGetConstMacro(PointDimension,
unsigned int);
464 itkSetMacro(UpdatePoints,
bool);
465 itkGetConstMacro(UpdatePoints,
bool);
466 itkBooleanMacro(UpdatePoints);
467 itkSetMacro(UpdateCells,
bool);
468 itkGetConstMacro(UpdateCells,
bool);
469 itkBooleanMacro(UpdateCells);
470 itkSetMacro(UpdatePointData,
bool);
471 itkGetConstMacro(UpdatePointData,
bool);
472 itkBooleanMacro(UpdatePointData);
473 itkSetMacro(UpdateCellData,
bool);
474 itkGetConstMacro(UpdateCellData,
bool);
475 itkBooleanMacro(UpdateCellData);
535 itkSetMacro(UseCompression,
bool);
536 itkGetConstMacro(UseCompression,
bool);
537 itkBooleanMacro(UseCompression);
626 template <
typename T>
632 inputFile >> buffer[i];
637 template <
typename T>
641 inputFile.read(
reinterpret_cast<char *
>(buffer), numberOfComponents *
sizeof(T));
650 else if (
m_ByteOrder == IOByteOrderEnum::LittleEndian)
660 template <
typename T>
663 std::ofstream & outputFile,
678 template <
typename TOutput,
typename TInput>
682 if (
typeid(TInput) ==
typeid(TOutput))
693 outputFile.write(
reinterpret_cast<char *
>(buffer), numberOfComponents);
700 data[ii] =
static_cast<TOutput
>(buffer[ii]);
712 outputFile.write(
reinterpret_cast<char *
>(data.get()), numberOfComponents);
719 template <
typename TInput,
typename TOutput>
730 auto numberOfPoints =
static_cast<unsigned int>(input[inputIndex++]);
731 for (
unsigned int jj = 0; jj < numberOfPoints; ++jj)
733 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
742 template <
typename TInput,
typename TOutput>
754 auto nn =
static_cast<unsigned int>(input[inputIndex++]);
755 if (cellType == type)
757 output[outputIndex++] = nn;
758 for (
unsigned int jj = 0; jj < nn; ++jj)
760 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
773 template <
typename TInput,
typename TOutput>
778 unsigned int numberOfPoints,
787 output[outputIndex++] =
static_cast<TOutput
>(cellType);
788 output[outputIndex++] =
static_cast<TOutput
>(numberOfPoints);
789 for (
unsigned int jj = 0; jj < numberOfPoints; ++jj)
791 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
799 template <
typename TInput,
typename TOutput>
809 auto numberOfPoints =
static_cast<unsigned int>(input[inputIndex++]);
810 if (numberOfPoints > 2 && cellType == CellGeometryEnum::LINE_CELL)
812 output[outputIndex++] =
static_cast<TOutput
>(CellGeometryEnum::POLYLINE_CELL);
816 output[outputIndex++] =
static_cast<TOutput
>(cellType);
818 output[outputIndex++] =
static_cast<TOutput
>(numberOfPoints);
820 for (
unsigned int jj = 0; jj < numberOfPoints; ++jj)
822 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
877#define MESHIOBASE_TYPEMAP(type, ctype) \
879 struct MeshIOBase::MapComponentType<type> \
881 static constexpr IOComponentEnum CType = ctype; \
897#undef MESHIOBASE_TYPEMAP
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
std::string GetPixelTypeAsString(IOPixelEnum) const
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
std::string GetComponentTypeAsString(IOComponentEnum) const
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
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.
#define MESHIOBASE_TYPEMAP(type, ctype)
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