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);
486 std::string GetPixelTypeAsString(
IOPixelEnum)
const;
534 itkSetMacro(UseCompression,
bool);
535 itkGetConstMacro(UseCompression,
bool);
536 itkBooleanMacro(UseCompression);
541 std::string GetFileTypeAsString(
IOFileEnum)
const;
551 CanReadFile(
const char *) = 0;
556 ReadMeshInformation() = 0;
560 ReadPoints(
void * buffer) = 0;
563 ReadCells(
void * buffer) = 0;
566 ReadPointData(
void * buffer) = 0;
569 ReadCellData(
void * buffer) = 0;
576 CanWriteFile(
const char *) = 0;
579 WriteMeshInformation() = 0;
582 WritePoints(
void * buffer) = 0;
585 WriteCells(
void * buffer) = 0;
588 WritePointData(
void * buffer) = 0;
591 WriteCellData(
void * buffer) = 0;
600 const ArrayOfExtensionsType &
601 GetSupportedReadExtensions()
const;
607 const ArrayOfExtensionsType &
608 GetSupportedWriteExtensions()
const;
615 PrintSelf(std::ostream & os,
Indent indent)
const override;
619 AddSupportedReadExtension(
const char * extension);
623 AddSupportedWriteExtension(
const char * extension);
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>
758 auto cellType = static_cast<CellGeometryEnum>(input[inputIndex++]);
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