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

Goodwin Lawlor goodwin.lawlor at ucd.ie
Wed Sep 27 04:24:06 EDT 2006



Renato N. Elias wrote:
> Hi Goodwin,
>
> thanks a lot for your help. 
>
> In fact, I firstly tried to extract the number of time steps as you did
> since it would be easier to perform a loop over the time steps instead of
> the time values. My problem was that vtk returned me an error in
> GetNumberOfItems method. With your script I got the same error message:
>
> Object named: vtkTemp2, could not find requested method: GetNumberOfItems or
> the method was called with incorrect arguments.
>
> while executing
> "$timeSteps GetNumberOfItems"
>    invoked from within
> "set numTimeSteps [$timeSteps GetNumberOfItems]"
> (file "ens2vtk.tcl" line 24)
>
> do you know how to work out it?!
>
> Regards
>
> Renato
>   
Hi Renato,

It should be "GetNumberOfTuples"... There's another typo "SetTimeValue". 
Here's the full script that runs (I didn't have time to check it last 
night!). FYI, time support has been checked into VTK recently...

http://www.vtk.org/Wiki/VTK/Time_Support


package require vtk
wm withdraw .

# 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 GetNumberOfTuples]

# 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 SetTimeValue $timeStep

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


reader  Delete
vtkfile Delete
exit



More information about the vtkusers mailing list