Non-zero exit code when calling vtkWindowToImageFilter.Update
Short Description
When rendering two cubes in a particular setup and trying to save them to .png
file I get non zero exit code.
Code to Reproduce the Issue
import vtk
pointCoordinates = [
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[1.0, 1.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
[1.0, 0.0, 1.0],
[1.0, 1.0, 1.0],
[0.0, 1.0, 1.0],
]
points = vtk.vtkPoints()
hexahedron = vtk.vtkHexahedron()
for i, coord in enumerate(pointCoordinates):
points.InsertNextPoint(coord)
hexahedron.GetPointIds().SetId(i, i)
camera = vtk.vtkCamera()
mapper = vtk.vtkDataSetMapper()
renderer = vtk.vtkRenderer()
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
uGrid = vtk.vtkUnstructuredGrid()
uGrid.SetPoints(points)
uGrid.InsertNextCell(hexahedron.GetCellType(), hexahedron.GetPointIds())
mapper.SetInputData(uGrid)
camera.SetFocalPoint((100, 100, 0))
renderer.SetActiveCamera(camera)
actor_1 = vtk.vtkActor()
actor_1.SetMapper(mapper)
actor_1.SetScale([100, 100, 100])
actor_1.SetPosition([0, 0, 0])
renderer.AddActor(actor_1)
actor_2 = vtk.vtkActor()
actor_2.SetMapper(mapper)
actor_2.SetScale([100, 100, 100])
actor_2.SetPosition([0, 0, 120])
actor_2.GetProperty().EdgeVisibilityOn()
renderer.AddActor(actor_2)
renderer.ResetCamera()
render_window.Render()
w2if = vtk.vtkWindowToImageFilter()
w2if.SetInput(render_window)
w2if.Update()
writer = vtk.vtkPNGWriter()
writer.SetFileName("test.png")
writer.SetInputConnection(w2if.GetOutputPort())
writer.Write()
Expected Behavior
When I run python <name-of-the-example-file>.py
then a file called test.png
is created with rendering of two cubes.
Observed Behavior
No file is created and I get exit code -1073741819
When I delete almost arbitrary line (e.g. actor_2.GetProperty().EdgeVisibilityOn()
) or set the position / scale of the actors to some other coordinates, then it works.
System Info
Host Name: ATWE7548
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.19045 N/A Build 19045
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Workstation
OS Build Type: Multiprocessor Free
Python Info
I am using conda environment with Python 3.11.9 and the following dependencies
contourpy==1.2.1
cycler==0.12.1
fonttools==4.53.0
kiwisolver==1.4.5
matplotlib==3.9.0
numpy==1.26.4
packaging==24.1
pillow==10.3.0
pybullet==3.2.6
pyparsing==3.1.2
python-dateutil==2.9.0.post0
six==1.16.0
vtk==9.3.0
Edited by Josef Ondrej