[vtkusers] Re: Translating Ensight to VTK transient data...

Goodwin Lawlor goodwin.lawlor at ucd.ie
Tue Sep 26 18:58:57 EDT 2006


Renato N. Elias wrote:
> Hi everybody,
> 
> here it's me again struggling with my Ensight files ;o)
> 
> I'm still trying to write a script to load an Ensight case file and export
> the corresponding VTK file for each time step. My problem is that I can't
> realize how to sweep the time steps loaded from the casefile. I found the
> SetTimeValue method but I don't know how to select the next time step yet.
> Does anybody more experienced with VTK+TCL could give me a hand? The script
> is the following:
> 
<snip>

Hi Renato,

Try this:


package require vtk

# loading command line arguments
set arch  [lindex $argv 0]

# building the filename
set    casefile $arch.case
puts " Reading Ensight casefile $casefile"

# defining the Ensight's reader and VTK writer
vtkGenericEnSightReader reader
    reader SetCaseFileName $casefile
    reader Update

# define the vtk file object
vtkXMLUnstructuredGridWriter vtkfile
    vtkfile SetInput [ reader GetOutput ]

# find the time steps
set tSets [reader GetTimeSets]
$tSets InitTraversal
set timeSteps [$tSets GetNextItem]
set numTimeSteps [$timeSteps GetNumberOfItems]

# loop over time steps
for {set nfile 0} {$nfile < $numTimeSteps} {incr nfile} {

       # building the vtk filename
       set vtkfilename [format "%02d$arch.vtk" $nfile]

       # set the time step
       set timeStep [$timeSteps GetTuple1 $nfile]
       reader SetTimeStep $timeStep

       # write out the vtk file
       vtkfile SetFileName $vtkfilename
       vtkfile Write
       puts " Writing VTK file $vtkfilename for time step $timeStep"
}


reader  Delete
vtkfile Delete
wm withdraw .
exit

#--------------------------------------------------------------------------





More information about the vtkusers mailing list