Intersection two models (Plane and centerlines CT/MR)

Hi 3DSlicer users and developers

I’m sorry that I repeat my question in another way. I still have problem to find the points of collision.
As you can see, I have three models.

Model 1 (CenterlinesMRI):
centerlines

Model 2 (CenterlinesCT):
CenterlinesCT

Model 2 (Plane):
plane

Now I want to extract the points of collision between the centerlines (CenterlinesMRI and CenterlinesCT) and plane.

Two Models (CenterlinesCT+ Plane):

Two Models (CenterlinesMR+ Plane):

How can I do it using 3DSlicer modules or python programming?
Please guide me.
Thanks a lot.
Shahrokh

I guess you mean the intersection points between the lines and the plane? You can look at the vtkCutter class. You can get the vtkPolyData from Slicer’s model nodes as input and then create a plane as the implicit function for cutting.

Dear Steve

Thanks a lot for you guidance. I can extract these intersection points with the following commands:

import vtk
import os
filenameCLMergedMR = "centerlinesMergedMR.vtp";
readerCLMergedMR = vtk.vtkXMLPolyDataReader();
readerCLMergedMR.SetFileName(filenameCLMergedMR);
readerCLMergedMR.Update();
polydata = readerCLMergedMR.GetOutput();
points = polydata.GetPoints();
numPoints = readerCLMergedMR.GetNumberOfPoints();
lineCellArray = vtk.vtkCellArray();
lineCellArray.InsertNextCell(numPoints);
for i in range(0,numPoints):
 lineCellArray.InsertCellPoint(i)
linePolyData = vtk.vtkPolyData()
linePolyData.SetPoints(points)
linePolyData.SetLines(lineCellArray)

plane = vtk.vtkPlane()
plane.SetOrigin(0, 0, 0)
plane.SetNormal(0, 0, 1)

clipper = vtk.vtkClipPolyData()
clipper.SetInputConnection(readerCLMergedMR.GetOutputPort())
cutEdges = vtk.vtkCutter()
cutEdges.SetInputConnection(readerCLMergedMR.GetOutputPort())
cutEdges.SetCutFunction(plane)
cutEdges.GenerateCutScalarsOn()
cutStrips = vtk.vtkStripper()
cutStrips.SetInputConnection(cutEdges.GetOutputPort())
cutStrips.Update()
cutPoly = vtk.vtkPolyData()
cutPoly.SetPoints(cutStrips.GetOutput().GetPoints())

writer = vtk.vtkXMLPolyDataWriter()
writer.SetFileName("intersectionPoints.vtp")
writer.SetInputDataObject(cutStrips.GetOutput())
writer.Write()

Thanks a lot,
Shahrokh

2 Likes