From 051df5f1cf2ab9746b592cb7535f0a7b7c947d6e Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 21 Oct 2024 13:55:58 +0200 Subject: [PATCH] BUG: Replace `SetPoints` with `SetPointsByCoordinates` in wrapping tests When the points are specified by a flat VectorContainer of coordinates, passing those points to `SetPoints` may lead to undefined behavior. `SetPointsByCoordinates` is in that case preferred. - Partially addresses issue https://github.com/InsightSoftwareConsortium/ITK/issues/4848 "`PointSet::SetPoints(PointsVectorContainer *)` overload leads to undefined behavior" --- .../Core/Common/wrapping/test/itkPointSetSerializationTest.py | 2 +- Modules/Core/Mesh/wrapping/test/itkMeshSerializationTest.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Core/Common/wrapping/test/itkPointSetSerializationTest.py b/Modules/Core/Common/wrapping/test/itkPointSetSerializationTest.py index b679a34cb78..3c2ab6ef1f8 100644 --- a/Modules/Core/Common/wrapping/test/itkPointSetSerializationTest.py +++ b/Modules/Core/Common/wrapping/test/itkPointSetSerializationTest.py @@ -52,7 +52,7 @@ arr = itk.array_view_from_vector_container(v_point) points_vc = itk.vector_container_from_array(arr.flatten()) -point_set.SetPoints(points_vc) +point_set.SetPointsByCoordinates(points_vc) # Check the serialization of mesh diff --git a/Modules/Core/Mesh/wrapping/test/itkMeshSerializationTest.py b/Modules/Core/Mesh/wrapping/test/itkMeshSerializationTest.py index 574938fba51..dd2fe7f6b84 100644 --- a/Modules/Core/Mesh/wrapping/test/itkMeshSerializationTest.py +++ b/Modules/Core/Mesh/wrapping/test/itkMeshSerializationTest.py @@ -50,7 +50,7 @@ arr = itk.array_view_from_vector_container(v_point) points_vc = itk.vector_container_from_array(arr.flatten()) -mesh.SetPoints(points_vc) +mesh.SetPointsByCoordinates(points_vc) # Set Cells in the Mesh as Triangle Cell @@ -171,7 +171,7 @@ # Create a new ITK Mesh using data from VTK Mesh itk_mesh = MeshType.New() - itk_mesh.SetPoints(itk.vector_container_from_array(points_numpy)) + itk_mesh.SetPointsByCoordinates(itk.vector_container_from_array(points_numpy)) itk_mesh.SetCellsArray(itk.vector_container_from_array(polys_numpy), itk.CommonEnums.CellGeometry_TRIANGLE_CELL) itk_mesh.SetPointData(itk.vector_container_from_array(point_data_numpy)) itk_mesh.SetCellData(itk.vector_container_from_array(cell_data_numpy))