Skip to content

Commit

Permalink
BUG: Replace SetPoints with SetPointsByCoordinates in wrapping tests
Browse files Browse the repository at this point in the history
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 InsightSoftwareConsortium#4848
"`PointSet::SetPoints(PointsVectorContainer *)` overload leads to undefined behavior"
  • Loading branch information
N-Dekker committed Oct 21, 2024
1 parent d36dfc6 commit 051df5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Mesh/wrapping/test/itkMeshSerializationTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 051df5f

Please sign in to comment.