These are the key parts from this example:
using FilterType = itk::TriangleMeshToBinaryImageFilter<MeshType, OutputImageType>;
auto filter = FilterType::New();
filter->SetInput(meshReader->GetOutput());
filter->SetInfoImage(cast->GetOutput());
filter->SetInsideValue(itk::NumericTraits<OutputPixelType>::max());
filter->Update();
This is attempt at translating it into python:
UCType = itk.image[itk.UC, 3]
ConverterType = itk.TriangleMeshToBinaryImageFilter[MeshType, UCType]
filter = ConverterType.New()
filter.SetInput(mesh) # mesh is read from file
# referenceImage is read from file or constructed by setting size, origin, and spacing
filter.SetInfoImage(referenceImage)
filter.SetInput(255)
filter.Update()
itk.imwrite(filter.GetOutput(), "mask.nrrd")