Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 22 additions & 12 deletions Modules/IO/HDF5/src/itkHDF5ImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "itkMakeUniqueForOverwrite.h"

#include <algorithm>
#include <type_traits> // For is_signed_v.

namespace itk
{
Expand Down Expand Up @@ -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
Expand All @@ -105,15 +107,19 @@ 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)
{
return IOComponentEnum::UCHAR;
}
if (type == H5::PredType::NATIVE_CHAR)
{
return IOComponentEnum::CHAR;
return std::is_signed_v<char> ? IOComponentEnum::SCHAR : IOComponentEnum::UCHAR;
}
else if (type == H5::PredType::NATIVE_SCHAR)
{
return IOComponentEnum::SCHAR;
}
else if (type == H5::PredType::NATIVE_USHORT)
{
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -784,6 +790,10 @@ HDF5ImageIO::ReadImageInformation()
{
this->StoreMetaData<char>(&metaDict, localMetaDataName, name, metaDataDims[0]);
}
else if (metaDataType == H5::PredType::NATIVE_SCHAR)
{
this->StoreMetaData<signed char>(&metaDict, localMetaDataName, name, metaDataDims[0]);
}
else if (metaDataType == H5::PredType::NATIVE_UCHAR)
{
if (doesAttrExist(metaDataSet, "isBool"))
Expand Down
8 changes: 4 additions & 4 deletions Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ VTKPolyDataMeshIO::ReadMeshInformation()
} \
case IOComponentEnum::SCHAR: \
{ \
function(param, static_cast<char *>(buffer)); \
function(param, static_cast<signed char *>(buffer)); \
break; \
} \
case IOComponentEnum::USHORT: \
Expand Down Expand Up @@ -1696,7 +1696,7 @@ VTKPolyDataMeshIO::WriteMeshInformation()
} \
case IOComponentEnum::SCHAR: \
{ \
function(outputFile, static_cast<char *>(buffer), " char"); \
function(outputFile, static_cast<signed char *>(buffer), " char"); \
break; \
} \
case IOComponentEnum::USHORT: \
Expand Down Expand Up @@ -1819,8 +1819,8 @@ VTKPolyDataMeshIO::WritePoints(void * buffer)
} \
case IOComponentEnum::SCHAR: \
{ \
UpdateCellInformation(static_cast<char *>(buffer)); \
function(outputFile, static_cast<char *>(buffer)); \
UpdateCellInformation(static_cast<signed char *>(buffer)); \
function(outputFile, static_cast<signed char *>(buffer)); \
break; \
} \
case IOComponentEnum::USHORT: \
Expand Down
Loading