18#ifndef itkMeshIOBase_h
19#define itkMeshIOBase_h
20#include "ITKIOMeshBaseExport.h"
103 itkSetStringMacro(FileName);
104 itkGetStringMacro(FileName);
107#if !defined(ITK_LEGACY_REMOVE)
127#if !defined(ITK_LEGACY_REMOVE)
145#if !defined(ITK_LEGACY_REMOVE)
152#if !defined(ITK_LEGACY_REMOVE)
159#if !defined(ITK_LEGACY_REMOVE)
165#if !defined(ITK_LEGACY_REMOVE)
203 template <
typename T>
209 template <
typename T>
215 SetNumberOfPointPixelComponents(1);
221 SetNumberOfCellPixelComponents(1);
227 template <
typename T>
233 SetNumberOfPointPixelComponents(3);
239 SetNumberOfCellPixelComponents(3);
245 template <
typename T>
251 SetNumberOfPointPixelComponents(4);
257 SetNumberOfCellPixelComponents(4);
263 template <
typename T,
unsigned int VLength>
269 SetNumberOfPointPixelComponents(VLength);
275 SetNumberOfCellPixelComponents(VLength);
281 template <
typename T,
unsigned int VLength>
287 SetNumberOfPointPixelComponents(VLength);
293 SetNumberOfCellPixelComponents(VLength);
299 template <
typename T,
unsigned int VLength>
305 SetNumberOfPointPixelComponents(VLength);
311 SetNumberOfCellPixelComponents(VLength);
317 template <
typename T,
unsigned int VLength>
323 SetNumberOfPointPixelComponents(VLength * (VLength + 1) / 2);
329 SetNumberOfCellPixelComponents(VLength * (VLength + 1) / 2);
335 template <
typename T>
341 SetNumberOfPointPixelComponents(6);
347 SetNumberOfCellPixelComponents(6);
353 template <
typename T,
unsigned int VRows,
unsigned int VColumns>
359 SetNumberOfPointPixelComponents(VRows * VColumns);
365 SetNumberOfCellPixelComponents(VRows * VColumns);
371 template <
typename T>
373 SetPixelType(
const std::complex<T> & itkNotUsed(dummy),
bool usePointPixel =
true)
377 SetNumberOfPointPixelComponents(2);
383 SetNumberOfCellPixelComponents(2);
389 template <
typename T>
395 SetNumberOfPointPixelComponents(array.
Size());
401 SetNumberOfCellPixelComponents(array.
Size());
407 template <
typename T>
413 SetNumberOfPointPixelComponents(vector.Size());
419 SetNumberOfCellPixelComponents(vector.Size());
425 template <
typename T>
431 SetNumberOfPointPixelComponents(matrix.
Rows() * matrix.
Cols());
437 SetNumberOfCellPixelComponents(matrix.
Rows() * matrix.
Cols());
447 itkSetMacro(NumberOfPointPixelComponents,
unsigned int);
448 itkGetConstMacro(NumberOfPointPixelComponents,
unsigned int);
449 itkSetMacro(NumberOfCellPixelComponents,
unsigned int);
450 itkGetConstMacro(NumberOfCellPixelComponents,
unsigned int);
451 itkSetMacro(PointDimension,
unsigned int);
452 itkGetConstMacro(PointDimension,
unsigned int);
463 itkSetMacro(UpdatePoints,
bool);
464 itkGetConstMacro(UpdatePoints,
bool);
465 itkBooleanMacro(UpdatePoints);
466 itkSetMacro(UpdateCells,
bool);
467 itkGetConstMacro(UpdateCells,
bool);
468 itkBooleanMacro(UpdateCells);
469 itkSetMacro(UpdatePointData,
bool);
470 itkGetConstMacro(UpdatePointData,
bool);
471 itkBooleanMacro(UpdatePointData);
472 itkSetMacro(UpdateCellData,
bool);
473 itkGetConstMacro(UpdateCellData,
bool);
474 itkBooleanMacro(UpdateCellData);
534 itkSetMacro(UseCompression,
bool);
535 itkGetConstMacro(UseCompression,
bool);
536 itkBooleanMacro(UseCompression);
626 template <
typename T>
632 inputFile >> buffer[i];
638 template <
typename T>
642 inputFile.read(
reinterpret_cast<char *
>(buffer), numberOfComponents *
sizeof(T));
661 template <
typename T>
664 std::ofstream & outputFile,
680 template <
typename TOutput,
typename TInput>
684 if (
typeid(TInput) ==
typeid(TOutput))
696 outputFile.write(
reinterpret_cast<char *
>(buffer), numberOfComponents);
700 const auto data = make_unique_for_overwrite<TOutput[]>(numberOfComponents);
703 data[ii] =
static_cast<TOutput
>(buffer[ii]);
715 outputFile.write(
reinterpret_cast<char *
>(data.get()), numberOfComponents);
722 template <
typename TInput,
typename TOutput>
733 auto numberOfPoints =
static_cast<unsigned int>(input[inputIndex++]);
734 for (
unsigned int jj = 0; jj < numberOfPoints; ++jj)
736 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
746 template <
typename TInput,
typename TOutput>
759 auto nn =
static_cast<unsigned int>(input[inputIndex++]);
760 if (cellType == type)
762 output[outputIndex++] = nn;
763 for (
unsigned int jj = 0; jj < nn; ++jj)
765 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
778 template <
typename TInput,
typename TOutput>
783 unsigned int numberOfPoints,
792 output[outputIndex++] =
static_cast<TOutput
>(cellType);
793 output[outputIndex++] =
static_cast<TOutput
>(numberOfPoints);
794 for (
unsigned int jj = 0; jj < numberOfPoints; ++jj)
796 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
805 template <
typename TInput,
typename TOutput>
815 auto numberOfPoints =
static_cast<unsigned int>(input[inputIndex++]);
822 output[outputIndex++] =
static_cast<TOutput
>(cellType);
824 output[outputIndex++] =
static_cast<TOutput
>(numberOfPoints);
827 for (
unsigned int jj = 0; jj < numberOfPoints; ++jj)
829 output[outputIndex++] =
static_cast<TOutput
>(input[inputIndex++]);
841 std::string m_FileName{};
844 bool m_UseCompression{
false };
858 unsigned int m_NumberOfPointPixelComponents{ 0 };
859 unsigned int m_NumberOfCellPixelComponents{ 0 };
862 unsigned int m_PointDimension{ 3 };
875 bool m_UpdatePoints{
false };
876 bool m_UpdateCells{
false };
877 bool m_UpdatePointData{
false };
878 bool m_UpdateCellData{
false };
884#define MESHIOBASE_TYPEMAP(type, ctype) \
886 struct MeshIOBase::MapComponentType<type> \
888 static constexpr IOComponentEnum CType = ctype; \
904#undef MESHIOBASE_TYPEMAP
Array class with size defined at construction time.
SizeValueType Size() const
Perform machine dependent byte swapping.
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.
Light weight base class for most itk classes.
LightProcessObject is the base class for all process objects (source, filters, mappers) in the Insigh...
A templated class holding a M x N size Matrix.
Abstract superclass defines mesh IO interface.
void ReadCellsBuffer(TInput *input, TOutput *output, CellGeometryEnum type)
void WriteBufferAsBinary(TInput *buffer, std::ofstream &outputFile, SizeValueType numberOfComponents)
void SetPixelType(const RGBPixel< T > &, bool usePointPixel=true)
std::string GetPixelTypeAsString(IOPixelEnum) const
void WriteBufferAsAscii(T *buffer, std::ofstream &outputFile, SizeValueType numberOfLines, SizeValueType numberOfComponents)
void SetFileTypeToBinary()
std::string GetFileTypeAsString(IOFileEnum) const
IdentifierType SizeValueType
void SetPixelType(const VariableSizeMatrix< T > &matrix, bool usePointPixel=true)
virtual void ReadPointData(void *buffer)=0
void SetPixelType(const FixedArray< T, VLength > &, bool usePointPixel=true)
virtual void WritePoints(void *buffer)=0
std::string GetComponentTypeAsString(IOComponentEnum) const
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 GetComponentSize(IOComponentEnum componentType) const
void AddSupportedReadExtension(const char *extension)
void SetPixelType(const T &, bool usePointPixel=true)
virtual void ReadMeshInformation()=0
virtual void ReadCells(void *buffer)=0
void SetPixelType(const SymmetricSecondRankTensor< T, VLength >, bool usePointPixel=true)
virtual bool CanReadFile(const char *)=0
void ReadBufferAsBinary(T *buffer, std::ifstream &inputFile, SizeValueType numberOfComponents)
const ArrayOfExtensionsType & GetSupportedReadExtensions() const
virtual void WriteCellData(void *buffer)=0
void SetPixelType(const VariableLengthVector< T > &vector, bool usePointPixel=true)
std::string GetByteOrderAsString(IOByteOrderEnum) const
void ReadCellsBuffer(TInput *input, TOutput *output)
void PrintSelf(std::ostream &os, Indent indent) const override
const ArrayOfExtensionsType & GetSupportedWriteExtensions() const
virtual bool CanWriteFile(const char *)=0
void SetPixelType(const RGBAPixel< T > &, bool usePointPixel=true)
void SetByteOrderToBigEndian()
std::streamoff StreamOffsetType
~MeshIOBase() override=default
void SetByteOrderToLittleEndian()
void SetFileTypeToASCII()
virtual void WritePointData(void *buffer)=0
void SetPixelType(const Matrix< T, VRows, VColumns > &, bool usePointPixel=true)
std::vector< std::string > ArrayOfExtensionsType
void SetPixelType(const DiffusionTensor3D< T > &, bool usePointPixel=true)
void SetPixelType(const std::complex< T > &, bool usePointPixel=true)
virtual void ReadCellData(void *buffer)=0
void SetPixelType(const Array< T > &array, bool usePointPixel=true)
void AddSupportedWriteExtension(const char *extension)
void SetPixelType(const CovariantVector< T, VLength > &, bool usePointPixel=true)
virtual void ReadPoints(void *buffer)=0
void SetPixelType(const Vector< T, VLength > &, bool usePointPixel=true)
void ReadBufferAsAscii(T *buffer, std::ifstream &inputFile, SizeValueType numberOfComponents)
void WriteCellsBuffer(TInput *input, TOutput *output, CellGeometryEnum cellType, SizeValueType numberOfCells)
Base class for most ITK classes.
Represent Red, Green, Blue and Alpha components for color images.
Represent Red, Green and Blue components for color images.
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.
@ SYMMETRICSECONDRANKTENSOR
@ QUADRATIC_TRIANGLE_CELL
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
std::string ConvertNumberToString(const TValue val)
SizeValueType IdentifierType
MESHIOBASE_TYPEMAP(unsigned char, IOComponentEnum::UCHAR)