1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
package require vtk
package require vtkinteraction
# get the interactor ui
## Graphics stuff
# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
vtkImageGaussianSource gs1
gs1 SetWholeExtent 0 31 0 31 0 31
gs1 SetCenter 10 16 16
gs1 SetMaximum 1000
gs1 SetStandardDeviation 7
vtkImageGaussianSource gs2
gs2 SetWholeExtent 0 31 0 31 0 31
gs2 SetCenter 22 16 16
gs2 SetMaximum 1000
gs2 SetStandardDeviation 7
vtkImageAppendComponents iac
iac AddInput [gs1 GetOutput]
iac AddInput [gs2 GetOutput]
vtkContourFilter cf1
cf1 SetInputConnection [iac GetOutputPort]
cf1 SetValue 0 500
cf1 SetArrayComponent 0
vtkContourFilter cf2
cf2 SetInputConnection [iac GetOutputPort]
cf2 SetValue 0 500
cf2 SetArrayComponent 1
vtkPolyDataMapper mapper1
mapper1 SetInputConnection [cf1 GetOutputPort]
mapper1 SetImmediateModeRendering 1
mapper1 SetScalarRange 0 1
mapper1 SetScalarVisibility 0
mapper1 Update
vtkPolyDataMapper mapper2
mapper2 SetInputConnection [cf2 GetOutputPort]
mapper2 SetImmediateModeRendering 1
mapper2 SetScalarRange 0 1
mapper2 SetScalarVisibility 0
vtkActor actor1
actor1 SetMapper mapper1
[actor1 GetProperty] SetColor 1 1 1
ren1 AddActor actor1
vtkActor actor2
actor2 SetMapper mapper2
[actor2 GetProperty] SetColor 1 0 0
ren1 AddActor actor2
# Add the actors to the renderer, set the background and size
#
ren1 SetBackground .3 .3 .3
renWin SetSize 400 400
# enable user interface interactor
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize
# prevent the tk window from showing up then start the event loop
wm withdraw .
|