# 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:** 1\
**Showing post:** 3

<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

---

_[View the full topic](https://discourse.slicer.org/t/intersection-two-models-plane-and-centerlines-ct-mr/4130)._
