I would like to Set Orientation/Direction to a vtkCylinderSource that I create in Slicer in python.
From vtk documentation I realized that I have to set the orientation through vtkActor, but how can I display it on Slicer?
Here is a piece of code:
cyl = vtk.vtkCylinderSource()
mapper = vtk.vtkPolyDataMapper()
actor = vtk.vtkActor()
node = cyl.GetOutput()
n = slicer.mrmlScene.AddNewNodeByClass(‘vtkMRMLModelNode’, ‘Cylinder’)
If you need to dynamically set its position/rotation then you set a parent transform to it. If you need a fixed pose then to cylinder source output you can apply a vtkTransformPolyDataFilter on set the output of that into the model node.
yes, I was wondering whether there is another option for dynamically setting the transformation except from SetMatrixTransformToParent. Thanks
In your module you can keep a reference to vtkTransformPolyDataFilter and update it whenever you need. However, in general it is more useful if you don’t keep transforms private but store in MRML nodes so that other nodes and modules can use it. For example, if you just store a transform privately then you cannot easily modify or inspect current values using GUI, use it to reslice a volume, combine with other transforms, save/load with the scene, etc.