vtkLinearCellExtrusionFilter not giving output

Dear VTK community!

I want to make use of the vtkLinearCellExtrusionFilter to extrude Polydata to 3D unstructured grid data, which the filter is supposed to do. However, it seems that I cannot retrieve the filter’s output nor evaluate whether it’s done the correct operation (no error message upon filter application).

Please consider the following MWE, where I just create a single triangle which I want to extrude to a prism:

#!/usr/bin/env python3

import vtk
from vtk.util.numpy_support import vtk_to_numpy, numpy_to_vtk, numpy_to_vtkIdTypeArray
import numpy as np

nodes = np.zeros((3,3))
# create three points
nodes[0][0], nodes[0][1], nodes[0][2] = 0.0, 0.0, 0.0
nodes[1][0], nodes[1][1], nodes[1][2] = 1.0, 0.0, 0.0
nodes[2][0], nodes[2][1], nodes[2][2] = 0.0, 1.0, 0.0

# create element
topo = np.zeros((1,4), dtype=int) # fist number is no. of nodes per element
topo[0][0] = 3
topo[0][1], topo[0][2], topo[0][3] = 0, 1, 2

# create vtk data types
nodes_vtk = numpy_to_vtk(nodes)
topo_vtk = numpy_to_vtkIdTypeArray(topo)

# set points and topology
points = vtk.vtkPoints()
points.SetData(nodes_vtk)
polys = vtk.vtkCellArray()
polys.SetCells(vtk.VTK_TRIANGLE, topo_vtk)

# actually create the PolyData
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)
polydata.SetPolys(polys)

## write PolyData (for checking...)
#wrt = vtk.vtkPolyDataWriter()
#wrt.SetFileName('tmp.vtk')
#wrt.SetInputData(polydata)
#wrt.Update()
#wrt.Write()

# extrusion
extr = vtk.vtkLinearCellExtrusionFilter()
extr.SetInputData(polydata)
extr.SetScaleFactor(1.)
extr.MergeDuplicatePointsOn()
extr.Update()

# now print output - should be unstructured grid, but is None here. Why?
ugrid = extr.GetOutput()
print(ugrid)

# write extruded mesh
ugrdwrt = vtk.vtkUnstructuredGridWriter()
ugrdwrt.SetFileName('tmp_extr.vtk')
ugrdwrt.SetInputData(ugrid)
ugrdwrt.Update()
ugrdwrt.Write()

The print in l. 49 indicates that the filter’s output is None, while it should be unstructured grid data. Similarly, the last block of code trying to write the grid of course fails. But otherwise, I do not get error messages.

VTK version is 9.3.0 release, dating from Nov 14, 2023.

I would appreciate any help! Maybe I’ve overseen something substantial how to use this filter.

Thanks!

Best,
Marc