1package require vtk 2package require vtkinteraction 3package require vtktesting 4 5# This example demonstrates how to use the vtkPlaneWidget to probe 6# a dataset and then generate contours on the probed data. 7 8# Create a mace out of filters. 9# 10vtkSphereSource sphere 11vtkConeSource cone 12vtkGlyph3D glyph 13 glyph SetInputConnection [sphere GetOutputPort] 14 glyph SetSourceConnection [cone GetOutputPort] 15 glyph SetVectorModeToUseNormal 16 glyph SetScaleModeToScaleByVector 17 glyph SetScaleFactor 0.25 18 19# The sphere and spikes are appended into a single polydata. 20# This just makes things simpler to manage. 21vtkAppendPolyData apd 22 apd AddInputConnection [glyph GetOutputPort] 23 apd AddInputConnection [sphere GetOutputPort] 24 25vtkPolyDataMapper maceMapper 26maceMapper SetInputConnection [apd GetOutputPort] 27 28vtkLODActor maceActor 29 maceActor SetMapper maceMapper 30 maceActor VisibilityOn 31 32# This portion of the code clips the mace with the vtkPlanes 33# implicit function. The clipped region is colored green. 34vtkPlane plane 35vtkClipPolyData clipper 36 clipper SetInputConnection [apd GetOutputPort] 37 clipper SetClipFunction plane 38 clipper InsideOutOn 39 40vtkPolyDataMapper selectMapper 41 selectMapper SetInputConnection [clipper GetOutputPort] 42 43vtkLODActor selectActor 44 selectActor SetMapper selectMapper 45 [selectActor GetProperty] SetColor 0 1 0 46 selectActor VisibilityOff 47 selectActor SetScale 1.01 1.01 1.01 48 49# Create the RenderWindow, Renderer and both Actors 50# 51vtkRenderer ren1 52vtkRenderWindow renWin 53 renWin AddRenderer ren1 54vtkRenderWindowInteractor iren 55 iren SetRenderWindow renWin 56 57# Associate the line widget with the interactor 58vtkImplicitPlaneWidget planeWidget 59 planeWidget SetInteractor iren 60 planeWidget SetPlaceFactor 1.25 61 planeWidget SetInputConnection [glyph GetOutputPort] 62 planeWidget PlaceWidget 63 planeWidget AddObserver InteractionEvent myCallback 64 65ren1 AddActor maceActor 66ren1 AddActor selectActor 67 68# Add the actors to the renderer, set the background and size 69# 70ren1 SetBackground 1 1 1 71renWin SetSize 300 300 72ren1 SetBackground 0.1 0.2 0.4 73 74# render the image 75# 76iren AddObserver UserEvent {wm deiconify .vtkInteract} 77renWin Render 78 79# Prevent the tk window from showing up then start the event loop. 80wm withdraw . 81 82proc myCallback {} { 83 planeWidget GetPlane plane 84 selectActor VisibilityOn 85} 86 87iren Start