_renderWindow.AddRenderer(_renderer) _renderWindow.SetSize(640,480) _renderer.SetBackground(1,1,1) # load the vtk file _dataReader = vtk.vtkDataSetReader() #_dataReader.SetFileName("Flinders_ranges.vtk") _dataReader.SetFileName("t.vtk") # set up the data _dataMapper = vtk.vtkDataSetMapper() _dataMapper.SetInput(_dataReader.GetOutput()) _dataMapper.ScalarVisibilityOff() # what exactly does this do? # set up the actor for viewing it _dataActor = vtk.vtkActor() _dataActor.SetMapper(_dataMapper) _dataActor.GetProperty().SetColor(0.2,0.2,0.2) _dataActor.GetProperty().SetRepresentationToWireframe() # add the actor to the scene _renderer.AddActor(_dataActor) # now see what was produced, with interactive playing stuff _iRenderer = vtk.vtkRenderWindowInteractor() _iRenderer.SetRenderWindow(_renderWindow) _iRenderer.Initialize() _renderWindow.Render() _iRenderer.Start() raw_input("Press enter to continue")
_renderWindow.SetSize(1024,768) _renderer.SetBackground(0,0,0) # load the jpeg file _jpegReader = vtk.vtkJPEGReader() _jpegReader.SetFileName("Flinders_eval.jpg") # set the jpeg file to the texture _tex = vtk.vtkTexture() _tex.SetInput(_jpegReader.GetOutput()) # get the plane and add it to the "scene" _plane = vtk.vtkPlaneSource() _planeMapper = vtk.vtkPolyDataMapper() _planeMapper.SetInput(_plane.GetOutput()) _planeActor = vtk.vtkActor() _planeActor.SetMapper(_planeMapper) _planeActor.SetTexture(_tex) _renderer.AddActor(_planeActor) # set up a camera _camera = vtk.vtkCamera() _camera.SetFocalPoint(0,0,0) _camera.SetPosition(1,1,1) _camera.ComputeViewPlaneNormal() _camera.SetViewUp(1,0,0) _camera.OrthogonalizeViewUp() _renderer.SetActiveCamera(_camera) _renderer.ResetCamera()
# now make the clipper _clipper = vtk.vtkClipPolyData() _clipper.SetClipFunction(_planes) _clipper.SetInput(_stripper.GetOutput()) _clipper.InsideOutOff() # set up the mapper _mapper = vtk.vtkPolyDataMapper() _mapper.SetInput(_clipper.GetOutput()) _mapper.ScalarVisibilityOn() _mapper.ColorByArrayComponent("data", 2) _mapper.SetScalarRange(0, 1) # set up the actor _actor = vtk.vtkActor() _actor.SetMapper(_mapper) # text properties _font_size = 14 _textProp = vtk.vtkTextProperty() _textProp.SetFontSize(_font_size) _textProp.SetFontFamilyToArial() _textProp.BoldOff() _textProp.ItalicOff() _textProp.ShadowOff() # add a title _titleMapper = vtk.vtkTextMapper() _title = "Example ball plot, clipped by a box" _titleMapper.SetInput(_title)