Dwight98
(Dwight98)
December 11, 2022, 1:20pm
1
I have a long OBJ model of a mine pipeline, but its direction is not regular in any of the x, y, or z axial directions,I used to use the bounding box to determine the direction of Plane’s cutting for him, but the cut out is still diagonal, do you have any good methods?
supplement:The language I use is python, the method I use is vtkBooleanOperationPolyDataFilter(), and the polydata used for cutting is vtkplane。
mau_igna_06
(Mauro Dominguez)
December 11, 2022, 5:56pm
2
I guess you can use SVD to get the cylinder (i.e. tube) axis… or this code to find the anatomical centerline of a long bone may help also:
def centerFibulaLine(self):
parameterNode = self.getParameterNode()
fibulaLine = parameterNode.GetNodeReference("fibulaLine")
fibulaModelNode = parameterNode.GetNodeReference("fibulaModelNode")
shNode = slicer.mrmlScene.GetSubjectHierarchyNode()
intersectionsFolder = shNode.CreateFolderItem(self.getParentFolderItemID(),"Intersections")
lineStartPos = np.zeros(3)
lineEndPos = np.zeros(3)
fibulaLine.GetNthControlPointPositionWorld(0, lineStartPos)
fibulaLine.GetNthControlPointPositionWorld(1, lineEndPos)
numberOfRepetitionsOfPositioningAlgorithm = 5
for i in range(numberOfRepetitionsOfPositioningAlgorithm):
fibulaLineNorm = np.linalg.norm(lineEndPos-lineStartPos)
fibulaLineDirection = (lineEndPos-lineStartPos)/fibulaLineNorm
fibulaStartIntersectionModel = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelNode','FibulaStartIntersection %d' % i)
fibulaEndIntersectionModel = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelNode','FibulaEndIntersection %d' % i)
This file has been truncated. show original
For cutting I would use the Slicer’s Dynamic Modeler tool called Plane Cut. Please see the video here .
If after testing it you find it’s just what you need you would only have to dig the vtk code out from the Slicer or Dynamic Modeler repositories
Hope it helps
Dwight98
(Dwight98)
December 12, 2022, 6:39am
3
First of all, sincerely thank you for your reply, I will consider the help you provided, I will reply later, thank you again!