How can I use the module of “Markups to Model” in command line?
I noticed that I can create a tube model around of centerline using the module of “Markups to Model” . At now, I want create this tube using this module in the command line. How can I do it?
Is it another module to create the tube around centerline?
There is no public function in the module yet to do this, but I can add one. In the meantime you can use vtk.vtkTubeFilter (https://www.vtk.org/doc/nightly/html/classvtkTubeFilter.html) to create tube poly data around the points. Something like this (note I haven’t personally tried running this so you may need to tweak it):
numPoints = pointsToConnect.GetNumberOfPoints()
lineCellArray = vtk.vtkCellArray()
lineCellArray.InsertNextCell( numPoints )
for i in xrange(0,numPoints)
{
lineCellArray.InsertCellPoint( i )
}
linePolyData = vtk.vtkPolyData()
linePolyData.SetPoints( pointsToConnect )
linePolyData.SetLines( lineCellArray )
tubeSegmentFilter = vtk.vtkTubeFilter()
tubeSegmentFilter.SetInputData( linePolyData )
tubeSegmentFilter.SetRadius( tubeRadius ) #INSERT VALUE
tubeSegmentFilter.SetNumberOfSides( tubeNumberOfSides ) #INSERT VALUE
tubeSegmentFilter.CappingOn()
tubeSegmentFilter.Update()
# Access poly data by calling tubeSegmentFilter.GetOutput()
If you want to assign it to a vtkMRMLModelNode you’ll need to do:
Thanks a lot for your guidance. At now, I want to create tube poly data around the points in my vtp centerline file according with your commands.
I have some problems to do it.
I enter the following commands in python interactor of Slicer.
import vtk
filename = “~/centerlineRodCT001.vtp”
reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName(filename)
reader.Update()
numPoints = reader.GetNumberOfPoints()
lineCellArray = vtk.vtkCellArray()
lineCellArray.InsertNextCell(numPoints)
for i in range(0,numPoints):
lineCellArray.InsertCellPoint( i )
linePolyData = vtk.vtkPolyData()
linePolyData.SetPoints(reader)
At this moment, I get the following error.
Traceback (most recent call last):
File “”, line 1, in
TypeError: SetPoints argument 1: method requires a vtkPoints, a vtkXMLPolyDataReader was provided.
Please guide me. How can I get vtkPoints argument?
Best regards,
Shahrokh
Excuse me. Unfortunately I can not find any python code example about reading centelines vtp file and applying vtktubefilter to it. Please let me know where I wrong it.
Thanks a lot.
Shahrokh