Converting ras to ijk coordinates for model, segmentation

Operating system: Ubuntu 20.04
Slicer version: 4.11.20210226

I understand how to convert ras to ijk coordinates using volumeNode.GetRASToIJKMatrix(mat).
However, I am placing fiducials on a surface (i use model, segmentation but not volume). I don’t have an input volume to apply volumeNode. How do I then convert the RAS coordinates obtained from fiducial points to ijk coordinates?
I want to obtain IJK coordinates as I need them for vmtk.

IJK coordinates are voxel indices. If you don’t have a volume, only models then there are no voxels, and there are no IJK coordinates.

A segmentation can store various representations. If it contains labelmap representation then you can retrieve its geometry using this code snippet:

segmentationNode = getNode('Segmentation')
commonGeometryString = segmentationNode.GetSegmentation().DetermineCommonLabelmapGeometry(slicer.vtkSegmentation.EXTENT_UNION_OF_SEGMENTS, None)
commonGeometryImage = slicer.vtkOrientedImageData()
slicer.vtkSegmentationConverter.DeserializeImageGeometry(commonGeometryString, commonGeometryImage, False) 
ijkToRas = vtk.vtkMatrix4x4()

This is so complex because it the geometry of the internal binary labelmap representations of a segmentation is an internal implementation details that generally you should generally not rely on. For example, if you import a model and “Crop to reference image geometry” representation conversion option is disabled then internal labelmap’s geometry may change.

Instead, if you want to manipulate labelmap representation in segments, it is simpler and more clear if you export the internal labelmap representation of segments to labelmap volume node(s).