shahrokh  
                
                  
                    September 17, 2018,  2:12pm
                   
                  1 
               
             
            
              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.
Model 1 (CenterlinesMRI):
Model 2 (CenterlinesCT):
Model 2 (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?
             
            
              
            
           
          
            
              
                pieper  
              
                  
                    September 17, 2018,  2:32pm
                   
                  2 
               
             
            
              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.
             
            
              
            
           
          
            
              
                shahrokh  
              
                  
                    September 18, 2018,  9:01am
                   
                  3 
               
             
            
              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,
             
            
              2 Likes