From a265fa5a0cbe35a819fb19a9fa1fd81892b82355 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Sun, 31 Oct 2021 17:37:50 +0100 Subject: [PATCH] [MeL/VTK] Additional check for type sizes. --- MeshLib/MeshGenerators/VtkMeshConverter.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MeshLib/MeshGenerators/VtkMeshConverter.h b/MeshLib/MeshGenerators/VtkMeshConverter.h index f7ba3cbcab8..55a0d0b6763 100644 --- a/MeshLib/MeshGenerators/VtkMeshConverter.h +++ b/MeshLib/MeshGenerators/VtkMeshConverter.h @@ -104,6 +104,23 @@ private: MeshLib::Properties& properties, MeshLib::MeshItemType type) { + // Keep for debugging purposes, since the vtk array type and the end + // type T are not always the same. + // DBUG( + // "Converting a vtk array '{:s}' with data type '{:s}' of " + // "size {:d} to a type '{:s}' of size {:d}.", + // array.GetName(), array.GetDataTypeAsString(), + // array.GetDataTypeSize(), typeid(T).name(), sizeof(T)); + + if (sizeof(T) != array.GetDataTypeSize()) + { + OGS_FATAL( + "Trying to convert a vtk array '{:s}' with data type '{:s}' of " + "size {:d} to a different sized type '{:s}' of size {:d}.", + array.GetName(), array.GetDataTypeAsString(), + array.GetDataTypeSize(), typeid(T).name(), sizeof(T)); + } + vtkIdType const nTuples(array.GetNumberOfTuples()); int const nComponents(array.GetNumberOfComponents()); char const* const array_name(array.GetName()); -- GitLab