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 76 77 78 79
|
package require vtk
package require vtkinteraction
vtkRenderer ren1
vtkRenderWindow renWin
renWin SetMultiSamples 0
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
# read data
vtkPLOT3DReader reader
reader SetXYZFileName "$VTK_DATA_ROOT/Data/combxyz.bin"
reader SetQFileName "$VTK_DATA_ROOT/Data/combq.bin"
reader SetScalarFunctionNumber 110
reader Update
# create outline
vtkStructuredGridOutlineFilter outlineF
outlineF SetInputConnection [reader GetOutputPort]
vtkPolyDataMapper outlineMapper
outlineMapper SetInputConnection [outlineF GetOutputPort]
vtkActor outline
outline SetMapper outlineMapper
[outline GetProperty] SetColor 0 0 0
# create cursor
vtkCursor3D cursor
eval cursor SetModelBounds [[reader GetOutput] GetBounds]
eval cursor SetFocalPoint [[reader GetOutput] GetCenter]
cursor AllOff
cursor AxesOn
cursor OutlineOn
cursor XShadowsOn
cursor YShadowsOn
cursor ZShadowsOn
vtkPolyDataMapper cursorMapper
cursorMapper SetInputConnection [cursor GetOutputPort]
vtkActor cursorActor
cursorActor SetMapper cursorMapper
[cursorActor GetProperty] SetColor 1 0 0
# create probe
vtkProbeFilter probe
probe SetInput [cursor GetFocus]
probe SetSource [reader GetOutput]
# create a cone geometry for glyph
vtkConeSource cone
cone SetResolution 16
cone SetRadius 0.25
# create glyph
vtkGlyph3D glyph
glyph SetInputConnection [probe GetOutputPort]
glyph SetSource [cone GetOutput]
glyph SetVectorModeToUseVector
glyph SetScaleModeToScaleByScalar
glyph SetScaleFactor .0002
vtkPolyDataMapper glyphMapper
glyphMapper SetInputConnection [glyph GetOutputPort]
vtkActor glyphActor
glyphActor SetMapper glyphMapper
ren1 AddActor outline
ren1 AddActor cursorActor
ren1 AddActor glyphActor
ren1 SetBackground 1.0 1.0 1.0
renWin SetSize 200 200
ren1 ResetCamera
[ren1 GetActiveCamera] Elevation 60
ren1 ResetCameraClippingRange
renWin Render
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize
# prevent the tk window from showing up then start the event loop
wm withdraw .
|