Ignore:
Timestamp:
Mar 20, 2013 3:15:43 PM (11 years ago)
Author:
gah
Message:

start of fix for multiple fields in isosurfaces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/field.tcl

    r3508 r3546  
    8080    private variable _hints
    8181    private variable _viewer "";        # Hints which viewer to use
     82    private variable _xv "";            # For 1D meshes only.  Holds the points
    8283    constructor {xmlobj path} {
    8384        # defined below
     
    278279    if { [info exists _comp2vtk($cname)] } {
    279280        # FIXME: extract mesh from VTK file data.
     281        if { $_comp2dims($cname) == "1D" } {
     282            return $_xv
     283        }
    280284        error "method \"mesh\" is not implemented for VTK file data"
    281285    }
     
    314318    if { [info exists _comp2vtk($cname)] } {
    315319        # FIXME: extract the values from the VTK file data
     320        if { $_comp2dims($cname) == "1D" } {
     321            return $_values
     322        }
    316323        error "method \"values\" is not implemented for vtk file data"
    317324    }
     
    731738                set type "dx"
    732739            }
     740        } elseif {[$_fldObj element $cname.ucd] != ""} {
     741            set type "ucd"
    733742        }
    734743        set _comp2style($cname) ""
     
    843852            }
    844853            incr _counter
    845         } elseif {[$_fldObj element $cname.ucd] != ""} {
    846             set _viewer "isosurface"
    847             set _comp2dims($cname) "3D"
     854        } elseif { $type == "ucd"} {
    848855            set contents [$_fldObj get $cname.ucd]
    849856            set vtkdata [AvsToVtk $cname $contents]
     
    11441151    }
    11451152    set _comp2dims($cname) ${_dim}D
     1153    if { $_dim < 2 } {
     1154        set points [$dataset GetPoints]
     1155        set numPoints [$points GetNumberOfPoints]
     1156        puts stderr "\#points are $numPoints"
     1157        set xv [blt::vector create \#auto]
     1158        for { set i 0 } { $i < $numPoints } { incr i } {
     1159            set point [$points GetPoint 0]
     1160            $xv append [lindex $point 0]
     1161        }
     1162        set yv [blt::vector create \#auto]
     1163        $yv seq 0 1 [$xv length]
     1164        set _comp2xy($cname) [list $xv $yv]
     1165    }
    11461166    lappend limits x [list $xmin $xmax]
    11471167    lappend limits y [list $ymin $ymax]
    11481168    lappend limits z [list $zmin $zmax]
    11491169    set dataAttrs [$dataset GetPointData]
     1170    if { $_dim == 1 } {
     1171        set numArrays [$dataAttrs GetNumberOfArrays]
     1172        puts stderr "\#arrays are $numArrays"
     1173    }
    11501174    if { $dataAttrs == ""} {
    11511175        puts stderr "No point data"
     
    13781402}
    13791403
    1380 itcl::body Rappture::Field::AvsToVtk { comp contents } {
     1404itcl::body Rappture::Field::AvsToVtk { cname contents } {
    13811405    package require vtk
    13821406
     1407    puts stderr "AVSToVTK"
    13831408    set reader $this-datasetreader
    13841409    vtkAVSucdReader $reader
    13851410
    13861411    # Write the contents to a file just in case it's binary.
    1387     set tmpfile file[pid].vtk
     1412    set tmpfile $cname[pid].ucd
    13881413    set f [open "$tmpfile" "w"]
    13891414    fconfigure $f -translation binary -encoding binary
     
    14011426        lappend _scalars $name $name "???"
    14021427    }
     1428    set tmpfile $cname[pid].vtk
    14031429    set writer $this-datasetwriter
    14041430    vtkDataSetWriter $writer
     
    14081434    rename $reader ""
    14091435    rename $writer ""
     1436
    14101437    set f [open "$tmpfile" "r"]
    14111438    fconfigure $f -translation binary -encoding binary
    14121439    set vtkdata [read $f]
    14131440    close $f
    1414     file delete $tmpfile
     1441    puts stderr "wrote $tmpfile"
     1442    #file delete $tmpfile
    14151443    return $vtkdata
    14161444}
Note: See TracChangeset for help on using the changeset viewer.