import vtk
colors = vtk.vtkNamedColors()
sphereSource = vtk.vtkSphereSource()
sphereSource.SetPhiResolution(10)
sphereSource.SetThetaResolution(10)
sphereSource.Update()
selectionPoints = vtk.vtkPoints()
selectionPoints.InsertPoint(0, 0, 0, 0)
selectionPoints.InsertPoint(1, 0.25, 0, 0)
selectionPoints.InsertPoint(2, 0.25, 0.25, 0)
selectionPoints.InsertPoint(3, 0, 0.25, 0)
selectionPoints.InsertPoint(4, 0.125, 0.125, 0)
loop = vtk.vtkImplicitSelectionLoop()
loop.SetLoop(selectionPoints)
clip = vtk.vtkClipPolyData()
clip.SetInputConnection(sphereSource.GetOutputPort());
clip.SetClipFunction(loop);
clip.SetValue(0.0);
clipMapper = vtk.vtkPolyDataMapper()
clipMapper.SetInputConnection(clip.GetOutputPort())
clipMapper.ScalarVisibilityOff()
backProp = vtk.vtkProperty()
backProp.SetColor(colors.GetColor3d("Tomato"))
clipActor = vtk.vtkLODActor()
clipActor.SetMapper(clipMapper);
clipActor.SetBackfaceProperty(backProp);
clipActor.GetProperty().SetColor(colors.GetColor3d("Banana"));
renderer = vtk.vtkRenderer()
renderWindow= vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
interactor=vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow);
renderer.AddActor(clipActor);
renderer.SetBackground(colors.GetColor3d("SlateGray"));
renderWindow.SetSize(500, 500);
renderWindow.SetWindowName("ImplicitSelectionLoop");
renderWindow.Render();
interactor.Start();