diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c047a8637f..324cf840bb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,17 @@ cmake_minimum_required( FATAL_ERROR ) +## For experimental purpose only! +message( + WARNING + "Experimental build: Changes the default char type to unsigned!" +) +if(CMAKE_GENERATOR MATCHES "Visual Studio") + add_compile_options(/J) +else() + add_compile_options(-funsigned-char) +endif() + # # Now enumerate specific policies newer than ITK_NEWEST_VALIDATED_POLICIES_VERSION # that may need to be individually set to NEW/OLD diff --git a/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx b/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx index 6daf59a87ee..0fc128d5185 100644 --- a/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx +++ b/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx @@ -24,6 +24,7 @@ #include "itkMakeUniqueForOverwrite.h" #include +#include // For is_signed_v. namespace itk { @@ -83,19 +84,20 @@ GetType() } GetH5TypeSpecialize(float, H5::PredType::NATIVE_FLOAT) GetH5TypeSpecialize(double, H5::PredType::NATIVE_DOUBLE) + GetH5TypeSpecialize(signed char, H5::PredType::NATIVE_SCHAR) GetH5TypeSpecialize(char, H5::PredType::NATIVE_CHAR) + GetH5TypeSpecialize(unsigned char, H5::PredType::NATIVE_UCHAR) - GetH5TypeSpecialize(char, H5::PredType::NATIVE_CHAR) GetH5TypeSpecialize(unsigned char, H5::PredType::NATIVE_UCHAR) + GetH5TypeSpecialize(short, H5::PredType::NATIVE_SHORT) + GetH5TypeSpecialize(short unsigned int, H5::PredType::NATIVE_USHORT) - GetH5TypeSpecialize(short, H5::PredType::NATIVE_SHORT) - GetH5TypeSpecialize(short unsigned int, H5::PredType::NATIVE_USHORT) + GetH5TypeSpecialize(int, H5::PredType::NATIVE_INT) + GetH5TypeSpecialize(unsigned int, H5::PredType::NATIVE_UINT) - GetH5TypeSpecialize(int, H5::PredType::NATIVE_INT) GetH5TypeSpecialize(unsigned int, H5::PredType::NATIVE_UINT) + GetH5TypeSpecialize(long, H5::PredType::NATIVE_LONG) + GetH5TypeSpecialize(long unsigned int, H5::PredType::NATIVE_ULONG) - GetH5TypeSpecialize(long, H5::PredType::NATIVE_LONG) - GetH5TypeSpecialize(long unsigned int, H5::PredType::NATIVE_ULONG) - - GetH5TypeSpecialize(long long, H5::PredType::NATIVE_LLONG) - GetH5TypeSpecialize(unsigned long long, H5::PredType::NATIVE_ULLONG) + GetH5TypeSpecialize(long long, H5::PredType::NATIVE_LLONG) + GetH5TypeSpecialize(unsigned long long, H5::PredType::NATIVE_ULLONG) /* The following types are not implemented. This comment serves * to indicate that the full complement of possible H5::PredType @@ -105,7 +107,7 @@ GetH5TypeSpecialize(float, H5::PredType::NATIVE_FLOAT) GetH5TypeSpecialize(doubl #undef GetH5TypeSpecialize - inline IOComponentEnum PredTypeToComponentType(H5::DataType & type) + inline IOComponentEnum PredTypeToComponentType(H5::DataType & type) { if (type == H5::PredType::NATIVE_UCHAR) { @@ -113,7 +115,11 @@ GetH5TypeSpecialize(float, H5::PredType::NATIVE_FLOAT) GetH5TypeSpecialize(doubl } if (type == H5::PredType::NATIVE_CHAR) { - return IOComponentEnum::CHAR; + return std::is_signed_v ? IOComponentEnum::SCHAR : IOComponentEnum::UCHAR; + } + else if (type == H5::PredType::NATIVE_SCHAR) + { + return IOComponentEnum::SCHAR; } else if (type == H5::PredType::NATIVE_USHORT) { @@ -166,7 +172,7 @@ ComponentToPredType(IOComponentEnum cType) case IOComponentEnum::UCHAR: return H5::PredType::NATIVE_UCHAR; case IOComponentEnum::SCHAR: - return H5::PredType::NATIVE_CHAR; + return H5::PredType::NATIVE_SCHAR; case IOComponentEnum::USHORT: return H5::PredType::NATIVE_USHORT; case IOComponentEnum::SHORT: @@ -784,6 +790,10 @@ HDF5ImageIO::ReadImageInformation() { this->StoreMetaData(&metaDict, localMetaDataName, name, metaDataDims[0]); } + else if (metaDataType == H5::PredType::NATIVE_SCHAR) + { + this->StoreMetaData(&metaDict, localMetaDataName, name, metaDataDims[0]); + } else if (metaDataType == H5::PredType::NATIVE_UCHAR) { if (doesAttrExist(metaDataSet, "isBool")) diff --git a/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx b/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx index 8ad42590a37..04c7f28e210 100644 --- a/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx +++ b/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx @@ -828,7 +828,7 @@ VTKPolyDataMeshIO::ReadMeshInformation() } \ case IOComponentEnum::SCHAR: \ { \ - function(param, static_cast(buffer)); \ + function(param, static_cast(buffer)); \ break; \ } \ case IOComponentEnum::USHORT: \ @@ -1696,7 +1696,7 @@ VTKPolyDataMeshIO::WriteMeshInformation() } \ case IOComponentEnum::SCHAR: \ { \ - function(outputFile, static_cast(buffer), " char"); \ + function(outputFile, static_cast(buffer), " char"); \ break; \ } \ case IOComponentEnum::USHORT: \ @@ -1819,8 +1819,8 @@ VTKPolyDataMeshIO::WritePoints(void * buffer) } \ case IOComponentEnum::SCHAR: \ { \ - UpdateCellInformation(static_cast(buffer)); \ - function(outputFile, static_cast(buffer)); \ + UpdateCellInformation(static_cast(buffer)); \ + function(outputFile, static_cast(buffer)); \ break; \ } \ case IOComponentEnum::USHORT: \