Creating 3D objects and slice them to obtain 2D numpy array

You can convert between vtkPolyData and vtkImageData using VTK. It is not a single command, because you need to specify the desired resolution, extents, axis directions when converting to image, and you need to make the mesh smooth when converting to mesh.

We have not enabled loading of .vti files in Slicer using GUI (but you can use the Python API - see here), because we did not want to encourage users to use it, as vti could not store image axis directions, it is only supported by a few VTK-based software, it is not particularly simple or efficient, and it is very limited compared to any other widely used research file formats, such as nrrd or nifti.

Both pyvista and Slicer wrap VTK and offers higher-level API, making the Python code a little shorter and simpler. Slicer also provides GUI, but you don’t have to use it. The deciding factor for choosing between Slicer and pyvista is what else you need to do.