catch {load vtktcl} # source /site/misc/src/vtk20/examplesTcl/vtkInt.tcl # Create the RenderWindow, Renderer vtkRenderer ren1 vtkRenderWindow renWin renWin AddRenderer ren1 vtkRenderWindowInteractor iren iren SetRenderWindow renWin set file [open "out.dat"] # j: keeps track of how many moves # pointIndex: keeps track of how many points per move set j 0 set jtemp 0 set pointIndex 0 # creating the initial points and cell array vtkFloatPoints points_$j vtkCellArray order_$j set line [gets $file] while {! [eof $file]} { # this will allow creation of new points and arrays on the fly if {$jtemp < $j} { vtkFloatPoints points_$j vtkCellArray order_$j order_$jtemp InsertNextCell $pointIndex for {set i 0} {$i < $pointIndex} {incr i} { order_$jtemp InsertCellPoint $i } set pointIndex 0 set jtemp $j } else { # skipping the moves if {[string index $line 0] == "&"} { incr j set line [gets $file] } else { if {[llength $line] != "0"} { set x [lindex $line 0] set y [lindex $line 1] # testing if there is a 3D input, otherwise set z to 0 if {[llength $line] == "3"} { set z [lindex $line 2] } else { set z 0 } points_$j InsertPoint $pointIndex $x $y $z incr pointIndex set line [gets $file] } else { set line [gets $file] } } } } # since the while loop won't create the final points and arrays order_$jtemp InsertNextCell $pointIndex for {set i 0} {$i < $pointIndex} {incr i} { order_$jtemp InsertCellPoint $i } # simple for loop that creates setup for the j moves for {set i 0} {$i <= $j} {incr i} { vtkPolyData profile_$i profile_$i SetPoints points_$i profile_$i SetLines order_$i vtkPolyDataMapper map_$i map_$i SetInput profile_$i vtkActor actor_$i actor_$i SetMapper map_$i [actor_$i GetProperty] SetColor 0 0 0 ren1 AddActor actor_$i } # # iren SetUserMethod {wm deiconify .vtkInteract} # set cam1 [ren1 GetActiveCamera] # $cam1 ParallelProjectionOn # $cam1 SetParallelScale 1 # $cam1 Zoom 1.0 # # iren Initialize # Render ren1 SetBackground 1 1 1 renWin SetSize 500 500 renWin Render #-------------------------------- # # Small user interface added # #-------------------------------- proc savePPM {} { renWin SetFileName "display.ppm" renWin SaveImageAsPPM } button .ppm -text "Save as PPM" -command savePPM button .exit -text "Exit" -command exit pack .ppm .exit -side top -fill both -expand t wm geometry . +510+0 wm title . "VTK Display V1.3"