18 #ifndef itkMeshIOBase_h
19 #define itkMeshIOBase_h
20 #include "ITKIOMeshBaseExport.h"
102 itkSetStringMacro(FileName);
103 itkGetStringMacro(FileName);
106 #if !defined(ITK_LEGACY_REMOVE)
126 #if !defined(ITK_LEGACY_REMOVE)
144 #if !defined(ITK_LEGACY_REMOVE)
151 #if !defined(ITK_LEGACY_REMOVE)
158 #if !defined(ITK_LEGACY_REMOVE)
164 #if !defined(ITK_LEGACY_REMOVE)
202 template <
typename T>
208 template <
typename T>
214 SetNumberOfPointPixelComponents(1);
220 SetNumberOfCellPixelComponents(1);
226 template <
typename T>
232 SetNumberOfPointPixelComponents(3);
238 SetNumberOfCellPixelComponents(3);
244 template <
typename T>
250 SetNumberOfPointPixelComponents(4);
256 SetNumberOfCellPixelComponents(4);
262 template <
typename T,
unsigned int VLength>
268 SetNumberOfPointPixelComponents(VLength);
274 SetNumberOfCellPixelComponents(VLength);
280 template <
typename T,
unsigned int VLength>
286 SetNumberOfPointPixelComponents(VLength);
292 SetNumberOfCellPixelComponents(VLength);
298 template <
typename T,
unsigned int VLength>
304 SetNumberOfPointPixelComponents(VLength);
310 SetNumberOfCellPixelComponents(VLength);
316 template <
typename T,
unsigned int VLength>
322 SetNumberOfPointPixelComponents(VLength * (VLength + 1) / 2);
328 SetNumberOfCellPixelComponents(VLength * (VLength + 1) / 2);
334 template <
typename T>
340 SetNumberOfPointPixelComponents(6);
346 SetNumberOfCellPixelComponents(6);
352 template <
typename T,
unsigned int NR,
unsigned int NC>
358 SetNumberOfPointPixelComponents(NR * NC);
364 SetNumberOfCellPixelComponents(NR * NC);
370 template <
typename T>
372 SetPixelType(
const std::complex<T> & itkNotUsed(dummy),
bool UsePointPixel =
true)
376 SetNumberOfPointPixelComponents(2);
382 SetNumberOfCellPixelComponents(2);
388 template <
typename T>
394 SetNumberOfPointPixelComponents(array.
Size());
400 SetNumberOfCellPixelComponents(array.
Size());
406 template <
typename T>
412 SetNumberOfPointPixelComponents(vector.
Size());
418 SetNumberOfCellPixelComponents(vector.
Size());
424 template <
typename T>
430 SetNumberOfPointPixelComponents(matrix.
Rows() * matrix.
Cols());
436 SetNumberOfCellPixelComponents(matrix.
Rows() * matrix.
Cols());
446 itkSetMacro(NumberOfPointPixelComponents,
unsigned int);
447 itkGetConstMacro(NumberOfPointPixelComponents,
unsigned int);
448 itkSetMacro(NumberOfCellPixelComponents,
unsigned int);
449 itkGetConstMacro(NumberOfCellPixelComponents,
unsigned int);
450 itkSetMacro(PointDimension,
unsigned int);
451 itkGetConstMacro(PointDimension,
unsigned int);
462 itkSetMacro(UpdatePoints,
bool);
463 itkGetConstMacro(UpdatePoints,
bool);
464 itkSetMacro(UpdateCells,
bool);
465 itkGetConstMacro(UpdateCells,
bool);
466 itkSetMacro(UpdatePointData,
bool);
467 itkGetConstMacro(UpdatePointData,
bool);
468 itkSetMacro(UpdateCellData,
bool);
469 itkGetConstMacro(UpdateCellData,
bool);
481 std::string GetPixelTypeAsString(
IOPixelEnum)
const;
529 itkSetMacro(UseCompression,
bool);
530 itkGetConstMacro(UseCompression,
bool);
531 itkBooleanMacro(UseCompression);
536 std::string GetFileTypeAsString(
IOFileEnum)
const;
546 CanReadFile(
const char *) = 0;
551 ReadMeshInformation() = 0;
555 ReadPoints(
void * buffer) = 0;
558 ReadCells(
void * buffer) = 0;
561 ReadPointData(
void * buffer) = 0;
564 ReadCellData(
void * buffer) = 0;
571 CanWriteFile(
const char *) = 0;
574 WriteMeshInformation() = 0;
577 WritePoints(
void * buffer) = 0;
580 WriteCells(
void * buffer) = 0;
583 WritePointData(
void * buffer) = 0;
586 WriteCellData(
void * buffer) = 0;
595 const ArrayOfExtensionsType &
596 GetSupportedReadExtensions()
const;
602 const ArrayOfExtensionsType &
603 GetSupportedWriteExtensions()
const;
610 PrintSelf(std::ostream & os,
Indent indent)
const override;
614 AddSupportedReadExtension(
const char * extension);
618 AddSupportedWriteExtension(
const char * extension);
621 template <
typename T>
627 inputFile >> buffer[i];
633 template <
typename T>
637 inputFile.read(reinterpret_cast<char *>(buffer), numberOfComponents *
sizeof(T));
656 template <
typename T>
659 std::ofstream & outputFile,
668 outputFile << convert(buffer[ii * numberOfComponents + jj]) <<
" ";
676 template <
typename TOutput,
typename TInput>
680 if (
typeid(TInput) ==
typeid(TOutput))
692 outputFile.write(reinterpret_cast<char *>(buffer), numberOfComponents);
696 auto * data =
new TOutput[numberOfComponents];
699 data[ii] = static_cast<TOutput>(buffer[ii]);
711 outputFile.write(reinterpret_cast<char *>(data), 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++]);
743 template <
typename TInput,
typename TOutput>
755 auto cellType = static_cast<CellGeometryEnum>(input[inputIndex++]);
756 auto nn = static_cast<unsigned int>(input[inputIndex++]);
757 if (cellType == type)
759 output[outputIndex++] = nn;
760 for (
unsigned int jj = 0; jj < nn; jj++)
762 output[outputIndex++] = static_cast<TOutput>(input[inputIndex++]);
775 template <
typename TInput,
typename TOutput>
780 unsigned int numberOfPoints,
789 output[outputIndex++] = static_cast<TOutput>(cellType);
790 output[outputIndex++] = static_cast<TOutput>(numberOfPoints);
791 for (
unsigned int jj = 0; jj < numberOfPoints; jj++)
793 output[outputIndex++] = static_cast<TOutput>(input[inputIndex++]);
802 template <
typename TInput,
typename TOutput>
812 auto numberOfPoints = static_cast<unsigned int>(input[inputIndex++]);
813 output[outputIndex++] = static_cast<TOutput>(cellType);
814 output[outputIndex++] = static_cast<TOutput>(numberOfPoints);
815 for (
unsigned int jj = 0; jj < numberOfPoints; jj++)
817 output[outputIndex++] = static_cast<TOutput>(input[inputIndex++]);
833 bool m_UseCompression{
false };
847 unsigned int m_NumberOfPointPixelComponents{ 0 };
848 unsigned int m_NumberOfCellPixelComponents{ 0 };
851 unsigned int m_PointDimension{ 3 };
864 bool m_UpdatePoints{
false };
865 bool m_UpdateCells{
false };
866 bool m_UpdatePointData{
false };
867 bool m_UpdateCellData{
false };
873 #define MESHIOBASE_TYPEMAP(type, ctype) \
875 struct MeshIOBase::MapComponentType<type> \
877 static constexpr IOComponentEnum CType = ctype; \
893 #undef MESHIOBASE_TYPEMAP