# Intersection two models (Plane and centerlines CT/MR)

**URL:** <https://discourse.slicer.org/t/intersection-two-models-plane-and-centerlines-ct-mr/4130>\
**Category:** Support\
**Created:** [September 17, 2018, 2:12pm UTC](https://discourse.slicer.org/t/intersection-two-models-plane-and-centerlines-ct-mr/4130 "2018-09-17T14:12:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahrokh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shahrokh/32/1499_2.png) [@shahrokh](https://discourse.slicer.org/u/shahrokh)\
**Post date:** [September 17, 2018, 2:12pm UTC](https://discourse.slicer.org/t/intersection-two-models-plane-and-centerlines-ct-mr/4130/1 "2018-09-17T14:12:22Z")

</div>

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](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/5/2535e1ece62741b0065f4334a0737027d4cec42f.png)

Model 2 (CenterlinesCT):

 ![CenterlinesCT](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/e/0e0cced812fde36fcb0391ca6095fdda9742ef4e.png)

Model 2 (Plane):

 ![plane](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/6/e6e1044fea957ccda27d99e649e09736ab4c936c.png)

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

Two Models (CenterlinesCT+ Plane):

 ![planeANDcenterlinesCT](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/6/469615cbb8e7c9b9652e0c98ba9b250dd7f01380.png)

Two Models (CenterlinesMR+ Plane):

 ![planeANDcenterlines](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/9/f9795e0caedc407d18656a35037b02d8cd1dfbe2.png)

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

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 17, 2018, 2:32pm UTC](https://discourse.slicer.org/t/intersection-two-models-plane-and-centerlines-ct-mr/4130/2 "2018-09-17T14:32:08Z")

</div>

I guess you mean the intersection points between the lines and the plane? You can look at the [vtkCutter](https://www.vtk.org/doc/nightly/html/classvtkCutter.html#details) class. You can get the vtkPolyData from Slicer’s model nodes as input and then create a [plane](https://www.vtk.org/doc/nightly/html/classvtkPlane.html#details) as the implicit function for cutting.

---

<div class="post-metadata">

**Author:** ![shahrokh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shahrokh/32/1499_2.png) [@shahrokh](https://discourse.slicer.org/u/shahrokh)\
**Post date:** [September 18, 2018, 9:01am UTC](https://discourse.slicer.org/t/intersection-two-models-plane-and-centerlines-ct-mr/4130/3 "2018-09-18T09:01:32Z")

</div>

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
