Quantcast

TCL script to open several files...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

TCL script to open several files...

Renato N. Elias


Dear friends,

I'd like to write a VTK/TCL script to read several Ensight Case files, apply
the "append dataset" and "clean to grid" filters and export the result to an
unique VTK file, but my problem is: how can I read several files in a TCL
scrip without having to write a reader block for each case file? I'm trying
to do something like this:


...

# radical is used to build the file names
set radical [lindex $argv 0]      

# number of files to be read
set nprocs  [lindex $argv 1]
append radical "_"  

# example radical = foo, nprocs=2
# will produce the following filenames: foo_00.case and foo_01.case
# foo_00.case + foo_01.case = foo.vtk

for {set i 0} {$i < $nprocs} {incr i} {

    set casefile(i) $radical
    if {$i < 10} { append casefile(i) "0" }
    append casefile(i) $i
    append casefile(i) ".case"
    puts " Reading Ensight casefile $casefile(i)"

    vtkGenericEnSightReader reader
       reader SetCaseFileName $casefile(i)
       reader Update
...
...

}

as everybody can see, it'll never work....

I understood that the "reader" is an object and I should create one object
to each casefile, so, how could I do that?

I guess it's a very basic question, but I just started to learn TCL and VTK
and I have not found any similar example in the VTK books.

thanks a lot for any help


Renato N. Elias
===================================================
PhD Student
High Performance Computing Center - NACAD/COPPE
Federal University of Rio de Janeiro, RJ -Brazil
http://www.nacad.ufrj.br/~rnelias
 

_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TCL script to open several files...

Goodwin Lawlor
Hi Renato,

Create a reader for each Ensight file, so try this:


...

vtkAppendFilter app

for {set i 0} {$i < $nprocs} {incr i} {

     set casefile(i) $radical
     if {$i < 10} { append casefile(i) "0" }
     append casefile(i) $i
     append casefile(i) ".case"
     puts " Reading Ensight casefile $casefile(i)"

     vtkGenericEnSightReader reader$i
        reader$i SetCaseFileName $casefile(i)
        reader$i Update

     app AddInput [reader$i GetOutput]
     reader$i Delete
...
...

}

hth

Goodwin

Renato N. Elias wrote:

>
> Dear friends,
>
> I'd like to write a VTK/TCL script to read several Ensight Case files, apply
> the "append dataset" and "clean to grid" filters and export the result to an
> unique VTK file, but my problem is: how can I read several files in a TCL
> scrip without having to write a reader block for each case file? I'm trying
> to do something like this:
>
>
> ...
>
> # radical is used to build the file names
> set radical [lindex $argv 0]      
>
> # number of files to be read
> set nprocs  [lindex $argv 1]
> append radical "_"  
>
> # example radical = foo, nprocs=2
> # will produce the following filenames: foo_00.case and foo_01.case
> # foo_00.case + foo_01.case = foo.vtk
>
> for {set i 0} {$i < $nprocs} {incr i} {
>
>     set casefile(i) $radical
>     if {$i < 10} { append casefile(i) "0" }
>     append casefile(i) $i
>     append casefile(i) ".case"
>     puts " Reading Ensight casefile $casefile(i)"
>
>     vtkGenericEnSightReader reader
>        reader SetCaseFileName $casefile(i)
>        reader Update
> ...
> ...
>
> }
>
> as everybody can see, it'll never work....
>
> I understood that the "reader" is an object and I should create one object
> to each casefile, so, how could I do that?
>
> I guess it's a very basic question, but I just started to learn TCL and VTK
> and I have not found any similar example in the VTK books.
>
> thanks a lot for any help
>
>
> Renato N. Elias
> ===================================================
> PhD Student
> High Performance Computing Center - NACAD/COPPE
> Federal University of Rio de Janeiro, RJ -Brazil
> http://www.nacad.ufrj.br/~rnelias
>  
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>

_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Loading...