<s> import vtk <EOL> from vtk . util . misc import vtkGetDataRoot <EOL> from vtk . util . colors import peacock , tomato <EOL> VTK_DATA_ROOT = vtkGetDataRoot ( ) <EOL> cow = vtk . vtkBYUReader ( ) <EOL> cow . SetGeometryFileName ( VTK_DATA_ROOT + "<STR_LIT>" ) <EOL> cowNormals = vtk . vtkPolyDataNormals ( ) <EOL> cowNormals . SetInputConnection ( cow . GetOutputPort ( ) ) <EOL> plane = vtk . vtkPlane ( ) <EOL> plane . SetOrigin ( <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> plane . SetNormal ( - <NUM_LIT:1> , - <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> clipper = vtk . vtkClipPolyData ( ) <EOL> clipper . SetInputConnection ( cowNormals . GetOutputPort ( ) ) <EOL> clipper . SetClipFunction ( plane ) <EOL> clipper . GenerateClipScalarsOn ( ) <EOL> clipper . GenerateClippedOutputOn ( ) <EOL> clipper . SetValue ( <NUM_LIT:0.5> ) <EOL> clipMapper = vtk . vtkPolyDataMapper ( ) <EOL> clipMapper . SetInputConnection ( clipper . GetOutputPort ( ) ) <EOL> clipMapper . ScalarVisibilityOff ( ) <EOL> backProp = vtk . vtkProperty ( ) <EOL> backProp . SetDiffuseColor ( tomato ) <EOL> clipActor = vtk . vtkActor ( ) <EOL> clipActor . SetMapper ( clipMapper ) <EOL> clipActor . GetProperty ( ) . SetColor ( peacock ) <EOL> clipActor . SetBackfaceProperty ( backProp ) <EOL> cutEdges = vtk . vtkCutter ( ) <EOL> cutEdges . SetInputConnection ( cowNormals . GetOutputPort ( ) ) <EOL> cutEdges . SetCutFunction ( plane ) <EOL> cutEdges . GenerateCutScalarsOn ( ) <EOL> cutEdges . SetValue ( <NUM_LIT:0> , <NUM_LIT:0.5> ) <EOL> cutStrips = vtk . vtkStripper ( ) <EOL> cutStrips . SetInputConnection ( cutEdges . GetOutputPort ( ) ) <EOL> cutStrips . Update ( ) <EOL> cutPoly = vtk . vtkPolyData ( ) <EOL> cutPoly . SetPoints ( cutStrips . GetOutput ( ) . GetPoints ( ) ) <EOL> cutPoly . SetPolys ( cutStrips . GetOutput ( ) . GetLines ( ) ) <EOL> cutTriangles = vtk . vtkTriangleFilter ( ) <EOL> cutTriangles . SetInput ( cutPoly ) <EOL> cutMapper = vtk . vtkPolyDataMapper ( ) <EOL> cutMapper . SetInput ( cutPoly ) <EOL> cutMapper . SetInputConnection ( cutTriangles . GetOutputPort ( ) ) <EOL> cutActor = vtk . vtkActor ( ) <EOL> cutActor . SetMapper ( cutMapper ) <EOL> cutActor . GetProperty ( ) . SetColor ( peacock ) <EOL> restMapper = vtk . vtkPolyDataMapper ( ) <EOL> restMapper . SetInput ( clipper . GetClippedOutput ( ) ) <EOL> restMapper . ScalarVisibilityOff ( ) <EOL> restActor = vtk . vtkActor ( ) <EOL> restActor . SetMapper ( restMapper ) <EOL> restActor . GetProperty ( ) . SetRepresentationToWireframe ( ) <EOL> ren = vtk . vtkRenderer ( ) <EOL> renWin = vtk . vtkRenderWindow ( ) <EOL> renWin . AddRenderer ( ren ) <EOL> iren = vtk . vtkRenderWindowInteractor ( ) <EOL> iren . SetRenderWindow ( renWin ) <EOL> ren . AddActor ( clipActor ) <EOL> ren . AddActor ( cutActor ) <EOL> ren . AddActor ( restActor ) <EOL> ren . SetBackground ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> ren . ResetCamera ( ) <EOL> ren . GetActiveCamera ( ) . Azimuth ( <NUM_LIT:30> ) <EOL> ren . GetActiveCamera ( ) . Elevation ( <NUM_LIT:30> ) <EOL> ren . GetActiveCamera ( ) . Dolly ( <NUM_LIT> ) <EOL> ren . ResetCameraClippingRange ( ) <EOL> renWin . SetSize ( <NUM_LIT> , <NUM_LIT> ) <EOL> iren . Initialize ( ) <EOL> def Cut ( v ) : <EOL> clipper . SetValue ( v ) <EOL> cutEdges . SetValue ( <NUM_LIT:0> , v ) <EOL> cutStrips . Update ( ) <EOL> cutPoly . SetPoints ( cutStrips . GetOutput ( ) . GetPoints ( ) ) <EOL> cutPoly . SetPolys ( cutStrips . GetOutput ( ) . GetLines ( ) ) <EOL> cutMapper . Update ( ) <EOL> renWin . Render ( ) <EOL> renWin . Render ( ) <EOL> iren . Start ( ) </s>
