<div dir="ltr">Hello,<div><br></div><div>I'm new to VTK and am trying to find the intersection of a plane and tube, using Python 3.5 and VTK 7.1, by following the "IntersectionPolyDataFilter" example.  My goal for this exercise is to obtain where the tube centerline intersects the plane though ultimately would like to determine where the tube intersects with an imported STL file (or where multiple STL files intersect).</div><div><br></div><div>My Python code is located below.  I don't get any errors when I run the script; however, the filter does not report any intersecting points or lines.  I also don't see an intersection line in the rendering window (just the plane and tube/cylinder).  I'm likely missing something obvious here.  Can anyone help me out?</div><div><br></div><div>import vtk</div><div>from vtk.util.colors import *</div><div><br></div><div>#create a plane source</div><div>planeSource = vtk.vtkPlaneSource()</div><div>planeSource.SetOrigin((-1,-1,-1))</div><div>planeSource.SetPoint1((1,-1,-1))</div><div>planeSource.SetPoint2((-1,1,-1))</div><div>planeSource.Update()</div><div>polygonMapper = vtk.vtkPolyDataMapper()</div><div>polygonMapper.SetInputConnection(planeSource.GetOutputPort())</div><div>polygonMapper.Update()</div><div>actor = vtk.vtkActor()</div><div>actor.SetMapper(polygonMapper)</div><div>actor.GetProperty().SetColor(white)</div><div>actor.GetProperty().SetOpacity(.5)</div><div><br></div><div>#create a tube using two points.  Simplified example of what trying to do.</div><div>centerlinePoints = []</div><div>centerlinePoints.append((0,0,-5))</div><div>centerlinePoints.append((0,0,5))</div><div>points = vtk.vtkPoints()</div><div>for i in range(0,len(centerlinePoints)):     </div><div>    p = centerlinePoints[i]</div><div>    points.InsertPoint(i, p[0], p[1], p[2])</div><div>spline = vtk.vtkParametricSpline()</div><div>spline.SetPoints(points)</div><div>functionSource = vtk.vtkParametricFunctionSource()</div><div>functionSource.SetParametricFunction(spline)</div><div>functionSource.SetUResolution(20)</div><div>functionSource.Update()</div><div>#tubePolyData = functionSource.GetOutput()</div><div># Create the tubes</div><div>tuber = vtk.vtkTubeFilter()</div><div>tuber.SetInputConnection(functionSource.GetOutputPort())</div><div>tuber.SetNumberOfSides(20)</div><div>tuber.SetVaryRadiusToVaryRadiusOff()</div><div>tuber.SetRadius(.5)</div><div>tuber.CappingOn()</div><div>tuber.Update()</div><div><br></div><div>tubeMapper = vtk.vtkPolyDataMapper()</div><div>tubeMapper.SetInputConnection(tuber.GetOutputPort())</div><div>tubeMapper.Update()</div><div>tubeActor = vtk.vtkActor()</div><div>tubeActor.SetMapper(tubeMapper)</div><div>tubeActor.GetProperty().SetColor(blue)</div><div>tubeActor.GetProperty().SetOpacity(.5)</div><div><br></div><div>isect = vtk.vtkIntersectionPolyDataFilter()</div><div>isect.ComputeIntersectionPointArrayOn()</div><div>isect.SetInputConnection(0,tuber.GetOutputPort())</div><div>isect.SetInputConnection(1,planeSource.GetOutputPort())</div><div>isect.Update()</div><div>print(isect.GetNumberOfIntersectionPoints())</div><div>print(isect.GetNumberOfIntersectionLines())</div><div><br></div><div>intersectMapper = vtk.vtkPolyDataMapper()</div><div>intersectMapper.SetInputConnection(isect.GetOutputPort())</div><div>intersectMapper.ScalarVisibilityOn()</div><div>intersectActor = vtk.vtkActor()</div><div>intersectActor.GetProperty().SetColor(red)</div><div>intersectActor.GetProperty().SetOpacity(1)</div><div>intersectActor.SetMapper(intersectMapper)</div><div><br></div><div><br></div><div><br></div><div>renderer = vtk.vtkRenderer()</div><div>renWin = vtk.vtkRenderWindow()</div><div>renWin.AddRenderer(renderer)</div><div>#renderer.AddActor(tubeActor)</div><div>#renderer.AddActor(actor)</div><div>#renderer.AddActor(intersectActor)</div><div>renderer.AddViewProp(tubeActor)</div><div>renderer.AddViewProp(actor)</div><div>renderer.AddViewProp(intersectActor)</div><div><br></div><div># Create a renderwindowinteractor</div><div>iren = vtk.vtkRenderWindowInteractor()</div><div>iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())</div><div>iren.SetRenderWindow(renWin)           </div><div># Enable user interface interactor</div><div>iren.Initialize()</div><div><br></div><div>renWin.Render()</div><div>iren.Start()  </div></div>