Changeset 4474 for branches/1.3/gui


Ignore:
Timestamp:
Jul 9, 2014 8:33:55 PM (10 years ago)
Author:
ldelgass
Message:

Merge mesh/field fixes from trunk, add mesh viewer

Location:
branches/1.3
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/gui/scripts/Makefile.in

    r3684 r4474  
    133133                $(srcdir)/vtkglyphviewer.tcl \
    134134                $(srcdir)/vtkisosurfaceviewer.tcl \
     135                $(srcdir)/vtkmeshviewer.tcl \
    135136                $(srcdir)/vtkstreamlinesviewer.tcl \
    136137                $(srcdir)/vtkvolumeviewer.tcl \
  • branches/1.3/gui/scripts/cloud.tcl

    r3571 r4474  
    2020    private variable _xmlobj "";        # ref to XML obj with device data
    2121    private variable _cloud "";         # lib obj representing this cloud
    22     private variable _units "m m m" ;   # system of units for x, y, z
     22    private variable _units "" ;        # system of units for x, y, z
     23    private variable _axis2label;       #
     24    private variable _axis2units;       #
    2325    private variable _limits;           # limits x, y, z
    2426    private common _xp2obj ;            # Used for fetch/release ref counting
     
    3840    public method points {}
    3941    public method mesh {}
     42    public method units { axis }
     43    public method label { axis }
    4044    public method vtkdata {}
    4145    public method size {}
     
    110114    set _cloud [$xmlobj element -as object $path]
    111115
    112     set u [$_cloud get units]
    113     if {"" != $u} {
    114         while {[llength $u] < 3} {
    115             lappend u [lindex $u end]
    116         }
    117         set _units $u
     116    set _units [$_cloud get units]
     117    set first [lindex $_units 0]
     118    set list {}
     119    foreach u $_units axis { x y z } {
     120        if { $u != "" } {
     121            set _axis2units($axis) $u
     122        } else {
     123            set _axis2units($axis) $first
     124        }
     125        lappend list $_axis2units($axis)
     126    }
     127    set _units $list
     128    foreach label [$_cloud get labels] axis { x y z } {
     129        if { $label != "" } {
     130            set _axis2label($axis) $label
     131        } else {
     132            set _axis2label($axis) [string toupper $axis]
     133        }
    118134    }
    119135
     
    125141        }
    126142
    127         set _dim [llength $line]
    128143        # make sure we have x,y,z
    129144        while {[llength $line] < 3} {
     
    135150        foreach axis {x y z} units $_units {
    136151            set value [Rappture::Units::convert [set $axis] \
    137                 -context $units -to $units -units off]
    138 
     152                        -context $units -to $units -units off]
    139153            set $axis $value;           # Set the (x/y/z) coordinate to
    140154                                        # converted value.
     
    162176        return
    163177    }
    164     # Check each axis to verify that data exists
     178    set _dim 0
    165179    foreach { xmin xmax } $_limits(x) break
    166     if { $xmin >= $xmax } {
    167         return
    168     }
    169     if { $_dim > 1 } {
    170         foreach { ymin ymax } $_limits(y) break
    171         if { $ymin >= $ymax } {
    172             return
    173         }
    174     }
    175     if { $_dim > 2 } {
    176         foreach { zmin zmax } $_limits(z) break
    177         if { $zmin >= $zmax } {
    178             return
    179         }
     180    if { $xmax > $xmin } {
     181        incr _dim
     182    }
     183    foreach { ymin ymax } $_limits(y) break
     184    if { $ymax > $ymin } {
     185        incr _dim
     186    }
     187    foreach { zmin zmax } $_limits(z) break
     188    if { $zmax > $zmin } {
     189        incr _dim
    180190    }
    181191    set _isValid 1
     
    236246    }
    237247    return $_limits($axis)
     248}
     249
     250#
     251# units --
     252#
     253#       Returns the units of the given axis.
     254#
     255itcl::body Rappture::Cloud::units { axis } {
     256    if { ![info exists _axis2units($axis)] } {
     257        return ""
     258    }
     259    return $_axis2units($axis)
     260}
     261
     262#
     263# label --
     264#
     265#       Returns the label of the given axis.
     266#
     267itcl::body Rappture::Cloud::label { axis } {
     268    if { ![info exists _axis2label($axis)] } {
     269        return ""
     270    }
     271    return $_axis2label($axis)
    238272}
    239273
  • branches/1.3/gui/scripts/field.tcl

    r4473 r4474  
    154154    protected method GetTypeAndSize { cname }
    155155    protected method ReadVtkDataSet { cname contents }
     156    private method InitHints {}
    156157
    157158    private method VerifyVtkDataSet { contents }
     
    201202    # build up vectors for various components of the field
    202203    Build
     204    InitHints
    203205}
    204206
     
    651653# ----------------------------------------------------------------------
    652654itcl::body Rappture::Field::hints {{keyword ""}} {
    653     if { ![info exists _hints] } {
    654         foreach {key path} {
    655             camera          camera.position
    656             color           about.color
    657             default         about.default
    658             group           about.group
    659             label           about.label
    660             scale           about.scale
    661             seeds           about.seeds
    662             style           about.style
    663             type            about.type
    664             xlabel          about.xaxis.label
    665             ylabel          about.yaxis.label
    666             zlabel          about.zaxis.label
    667             xunits          about.xaxis.units
    668             yunits          about.yaxis.units
    669             zunits          about.zaxis.units
    670             units           units
    671             updir           updir
    672             vectors         about.vectors
    673         } {
    674             set str [$_field get $path]
    675             if { "" != $str } {
    676                 set _hints($key) $str
    677             }
    678         }
    679         foreach {key path} {
    680             toolid          tool.id
    681             toolname        tool.name
    682             toolcommand     tool.execute
    683             tooltitle       tool.title
    684             toolrevision    tool.version.application.revision
    685         } {
    686             set str [$_xmlobj get $path]
    687             if { "" != $str } {
    688                 set _hints($key) $str
    689             }
    690         }
    691         # Set toolip and path hints
    692         set _hints(path) $_path
    693         if { [info exists _hints(group)] && [info exists _hints(label)] } {
    694             # pop-up help for each curve
    695             set _hints(tooltip) $_hints(label)
    696         }
    697     }
    698655    if { $keyword != "" } {
    699656        if {[info exists _hints($keyword)]} {
     
    703660    }
    704661    return [array get _hints]
     662}
     663
     664
     665# ----------------------------------------------------------------------
     666# USAGE: InitHints
     667#
     668# Returns a list of key/value pairs for various hints about plotting
     669# this field.  If a particular <keyword> is specified, then it returns
     670# the hint for that <keyword>, if it exists.
     671# ----------------------------------------------------------------------
     672itcl::body Rappture::Field::InitHints {} {
     673    foreach {key path} {
     674        camera          camera.position
     675        color           about.color
     676        default         about.default
     677        group           about.group
     678        label           about.label
     679        scale           about.scale
     680        seeds           about.seeds
     681        style           about.style
     682        type            about.type
     683        xlabel          about.xaxis.label
     684        ylabel          about.yaxis.label
     685        zlabel          about.zaxis.label
     686        xunits          about.xaxis.units
     687        yunits          about.yaxis.units
     688        zunits          about.zaxis.units
     689        units           units
     690        updir           updir
     691        vectors         about.vectors
     692    } {
     693        set str [$_field get $path]
     694        if { "" != $str } {
     695            set _hints($key) $str
     696        }
     697    }
     698    foreach cname [components] {
     699        if { ![info exists _comp2mesh($cname)] } {
     700            continue
     701        }
     702        set mesh [lindex $_comp2mesh($cname) 0]
     703        foreach axis {x y z} {
     704            if { ![info exists _hints(${axis}units)] } {
     705                set _hints(${axis}units) [$mesh units $axis]
     706            }
     707            if { ![info exists _hints(${axis}label)] } {
     708                set _hints(${axis}label) [$mesh label $axis]
     709            }
     710        }
     711    }
     712    foreach {key path} {
     713        toolid          tool.id
     714        toolname        tool.name
     715        toolcommand     tool.execute
     716        tooltitle       tool.title
     717        toolrevision    tool.version.application.revision
     718    } {
     719        set str [$_xmlobj get $path]
     720        if { "" != $str } {
     721            set _hints($key) $str
     722        }
     723    }
     724    # Set toolip and path hints
     725    set _hints(path) $_path
     726    if { [info exists _hints(group)] && [info exists _hints(label)] } {
     727        # pop-up help for each curve
     728        set _hints(tooltip) $_hints(label)
     729    }
    705730}
    706731
     
    14031428        set _values [$_field get $cname.values]
    14041429        set limits {}
    1405         foreach axis { x y } {
     1430        foreach axis { x y z } {
    14061431            lappend limits $axis [$_comp2unirect2d($cname) limits $axis]
    14071432        }
     
    15101535        incr _counter
    15111536        array unset _comp2limits $cname
    1512         lappend _comp2limits($cname) x [$mesh limits x]
    1513         lappend _comp2limits($cname) y [$mesh limits y]
     1537        foreach axis { x y z } {
     1538            lappend _comp2limits($cname) $axis [$mesh limits $axis]
     1539        }
    15141540        lappend _comp2limits($cname) $cname [$v limits]
    15151541        lappend _comp2limits($cname) v [$v limits]
     
    15511577        set _comp2style($cname) [$_field get $cname.style]
    15521578        incr _counter
    1553         lappend _comp2limits($cname) x [$mesh limits x]
    1554         lappend _comp2limits($cname) y [$mesh limits y]
    1555         lappend _comp2limits($cname) z [$mesh limits z]
     1579        foreach axis { x y z } {
     1580            lappend _comp2limits($cname) $axis [$mesh limits $axis]
     1581        }
    15561582        lappend _comp2limits($cname) $cname [$v limits]
    15571583        lappend _comp2limits($cname) v [$v limits]
  • branches/1.3/gui/scripts/mesh.tcl

    r4472 r4474  
    2727    private variable _dim       0;      # Dimension of mesh (1, 2, or 3)
    2828    private variable _type "";          # Indicates the type of mesh.
    29     private variable _units "m m m" ;   # System of units for x, y, z
     29    private variable _axis2units;       # System of units for x, y, z
     30    private variable _axis2labels;      #
     31    private variable _hints
    3032    private variable _limits        ;   # Array of mesh limits. Keys are
    3133                                        # xmin, xmax, ymin, ymax, ...
     
    4648    public method dimensions {}
    4749    public method limits {which}
     50    public method units { axis }
     51    public method label { axis }
    4852    public method hints {{key ""}}
    4953    public method isvalid {} {
     
    5256    public proc fetch {xmlobj path}
    5357    public proc release {obj}
    54     public method vtkdata {}
     58    public method vtkdata {{what -partial}}
    5559    public method type {} {
    5660        return $_type
     
    5963        return $_numPoints
    6064    }
    61 
     65    public method numcells {} {
     66        return $_numCells
     67    }
    6268
    6369    private common _xp2obj       ;      # used for fetch/release ref counting
     
    7379    private method GetDouble { path }
    7480    private method GetInt { path }
     81    private method InitHints {}
    7582    private method ReadGrid { path }
    7683    private method ReadUnstructuredGrid { path }
     
    149156        set _limits($axis) ""
    150157    }
    151     set u [$_mesh get units]
    152     if {"" != $u} {
    153         while {[llength $u] < 3} {
    154             lappend u [lindex $u end]
    155         }
    156         set _units $u
     158    set units [$_mesh get units]
     159    set first [lindex $units 0]
     160    foreach u $units axis { x y z } {
     161        if { $u != "" } {
     162            set _axis2units($axis) $u
     163        } else {
     164            set _axis2units($axis) $first
     165        }
     166    }
     167    foreach label [$_mesh get labels] axis { x y z } {
     168        if { $label != "" } {
     169            set _axis2labels($axis) $label
     170        } else {
     171            set _axis2labels($axis) [string toupper $axis]
     172        }
    157173    }
    158174
     
    200216    }
    201217    set _isValid $result
     218    InitHints
    202219}
    203220
     
    226243#       arrays before generating output to send to the remote render server.
    227244#
    228 itcl::body Rappture::Mesh::vtkdata {} {
    229     return $_vtkdata
     245itcl::body Rappture::Mesh::vtkdata {{what -partial}} {
     246    if {$what == "-full"} {
     247        append out "# vtk DataFile Version 3.0\n"
     248        append out "[hints label]\n"
     249        append out "ASCII\n"
     250        append out $_vtkdata
     251        return $out
     252    } else {
     253        return $_vtkdata
     254    }
    230255}
    231256
     
    237262itcl::body Rappture::Mesh::points {} {
    238263    return ""
     264}
     265
     266#
     267# units --
     268#
     269#       Returns the units of the given axis.
     270#
     271itcl::body Rappture::Mesh::units { axis } {
     272    if { ![info exists _axis2units($axis)] } {
     273        return ""
     274    }
     275    return $_axis2units($axis)
     276}
     277
     278#
     279# label --
     280#
     281#       Returns the label of the given axis.
     282#
     283itcl::body Rappture::Mesh::label { axis } {
     284    if { ![info exists _axis2labels($axis)] } {
     285        return ""
     286    }
     287    return $_axis2labels($axis)
    239288}
    240289
     
    344393# ----------------------------------------------------------------------
    345394itcl::body Rappture::Mesh::hints {{keyword ""}} {
    346     foreach key {label color units} {
    347         set str [$_mesh get $key]
     395    if {$keyword != ""} {
     396        if {[info exists _hints($keyword)]} {
     397            return $_hints($keyword)
     398        }
     399        return ""
     400    }
     401    return [array get _hints]
     402}
     403
     404# ----------------------------------------------------------------------
     405# USAGE: InitHints
     406#
     407# Returns a list of key/value pairs for various hints about plotting
     408# this mesh.  If a particular <keyword> is specified, then it returns
     409# the hint for that <keyword>, if it exists.
     410# ----------------------------------------------------------------------
     411itcl::body Rappture::Mesh::InitHints {} {
     412    foreach {key path} {
     413        camera       camera.position
     414        color        about.color
     415        label        about.label
     416        style        about.style
     417        units        units
     418    } {
     419        set str [$_mesh get $path]
    348420        if {"" != $str} {
    349             set hints($key) $str
    350         }
    351     }
    352 
    353     if {$keyword != ""} {
    354         if {[info exists hints($keyword)]} {
    355             return $hints($keyword)
    356         }
    357         return ""
    358     }
    359     return [array get hints]
     421            set _hints($key) $str
     422        }
     423    }
    360424}
    361425
     
    367431    }
    368432    if { [scan $string "%d" _dim] == 1 } {
    369         if { $_dim == 2 || $_dim == 3 } {
     433        if { $_dim == 1 || $_dim == 2 || $_dim == 3 } {
    370434            return 1
    371435        }
    372436    }
    373     puts stderr "WARNING: bad <dim> tag value \"$string\": should be 2 or 3."
     437    puts stderr "WARNING: bad <dim> tag value \"$string\": should be 1, 2 or 3."
    374438    return 0
    375439}
     
    471535            return 0
    472536        }
    473         if { $numCurvilinear < 2 } {
    474             puts stderr "WARNING: bad grid \"$path\": curvilinear grid must be 2D or 3D."
    475             return 0
    476         }
    477537        set points [$_xmlobj get $path.grid.points]
    478538        if { $points == "" } {
     
    480540            return 0
    481541        }
    482         if { ![info exists xNum] || ![info exists yNum] } {
    483             puts stderr "WARNING: bad grid \"$path\": invalid dimensions for curvilinear grid: missing <xdim> or <ydim> from grid description."
     542        if { ![info exists xNum] } {
     543            puts stderr "WARNING: bad grid \"$path\": invalid dimensions for curvilinear grid: missing <xdim> from grid description."
    484544            return 0
    485545        }
     
    493553            set _dim 3
    494554            set _numPoints [expr $xNum * $yNum * $zNum]
     555            set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)]
    495556            if { ($_numPoints*3) != $numCoords } {
    496                 puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim>"
     557                puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>"
    497558                return 0
    498559            }
     
    512573            append out "\n"
    513574            set _vtkdata $out
    514         } else {
     575        } elseif { [info exists yNum] } {
    515576            set _dim 2
    516577            set _numPoints [expr $xNum * $yNum]
     578            set _numCells [expr ($xNum - 1) * ($yNum - 1)]
    517579            if { ($_numPoints*2) != $numCoords } {
    518                 puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim> * <zdim>"
     580                puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>"
    519581                return 0
    520582            }
     
    527589                set _limits($axis) [$vector limits]
    528590            }
     591            set _limits(z) [list 0 0]
    529592            $zv seq 0 0 [$xv length]
    530593            $all merge $xv $yv $zv
     
    535598            append out "\n"
    536599            set _vtkdata $out
     600        } else {
     601            set _dim 1
     602            set _numPoints $xNum
     603            set _numCells [expr $xNum - 1]
     604            if { $_numPoints != $numCoords } {
     605                puts stderr "WARNING: bad grid \"$path\": \# of points does not match <xdim>"
     606                return 0
     607            }
     608            set _limits(x) [$xv limits]
     609            set _limits(y) [list 0 0]
     610            set _limits(z) [list 0 0]
     611            $yv seq 0 0 [$xv length]
     612            $zv seq 0 0 [$xv length]
     613            $all merge $xv $yv $zv
     614            append out "DATASET STRUCTURED_GRID\n"
     615            append out "DIMENSIONS $xNum 1 1\n"
     616            append out "POINTS $_numPoints double\n"
     617            append out [$all range 0 end]
     618            append out "\n"
     619            set _vtkdata $out
    537620        }
    538621        blt::vector destroy $all $xv $yv $zv
     
    541624    if { $numRectilinear == 0 && $numUniform > 0} {
    542625        # This is the special case where all axes 2D/3D are uniform. 
    543         # This results in a STRUCTURE_POINTS
    544         if { $_dim == 2 } {
     626        # This results in a STRUCTURED_POINTS
     627        if { $_dim == 1 } {
     628            set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
     629            set _numPoints $xNum
     630            set _numCells [expr $xNum - 1]
     631            append out "DATASET STRUCTURED_POINTS\n"
     632            append out "DIMENSIONS $xNum 1 1\n"
     633            append out "ORIGIN $xMin 0 0\n"
     634            append out "SPACING $xSpace 0 0\n"
     635            set _vtkdata $out
     636            set _limits(x) [list $xMin $xMax]
     637            set _limits(y) [list 0 0]
     638            set _limits(z) [list 0 0]
     639        } elseif { $_dim == 2 } {
    545640            set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
    546641            set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
    547642            set _numPoints [expr $xNum * $yNum]
     643            set _numCells [expr ($xNum - 1) * ($yNum - 1)]
    548644            append out "DATASET STRUCTURED_POINTS\n"
    549645            append out "DIMENSIONS $xNum $yNum 1\n"
     
    554650                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
    555651            }
     652            set _limits(z) [list 0 0]
    556653        } elseif { $_dim == 3 } {
    557654            set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
     
    559656            set zSpace [expr ($zMax - $zMin) / double($zNum - 1)]
    560657            set _numPoints [expr $xNum * $yNum * $zNum]
     658            set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)]
    561659            append out "DATASET STRUCTURED_POINTS\n"
    562660            append out "DIMENSIONS $xNum $yNum $zNum\n"
     
    584682    }
    585683    set yv [blt::vector create \#auto]
    586     if { [info exists yMin] } {
    587         $yv seq $yMin $yMax $yNum
     684    if { $_dim > 1 } {
     685        if { [info exists yMin] } {
     686            $yv seq $yMin $yMax $yNum
     687        } else {
     688            $yv set [$_xmlobj get $path.grid.ycoords]
     689            set yMin [$yv min]
     690            set yMax [$yv max]
     691            set yNum [$yv length]
     692        }
    588693    } else {
    589         $yv set [$_xmlobj get $path.grid.ycoords]
    590         set yMin [$yv min]
    591         set yMax [$yv max]
    592         set yNum [$yv length]
     694        set yNum 1
    593695    }
    594696    set zv [blt::vector create \#auto]
     
    607709    if { $_dim == 3 } {
    608710        set _numPoints [expr $xNum * $yNum * $zNum]
     711        set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)]
    609712        append out "DATASET RECTILINEAR_GRID\n"
    610713        append out "DIMENSIONS $xNum $yNum $zNum\n"
     
    626729    } elseif { $_dim == 2 } {
    627730        set _numPoints [expr $xNum * $yNum]
     731        set _numCells [expr ($xNum - 1) * ($yNum - 1)]
    628732        append out "DATASET RECTILINEAR_GRID\n"
    629733        append out "DIMENSIONS $xNum $yNum 1\n"
     
    641745            }
    642746        }
     747        set _limits(z) [list 0 0]
     748        set _vtkdata $out
     749    } elseif { $_dim == 1 } {
     750        set _numPoints $xNum
     751        set _numCells [expr $xNum - 1]
     752        append out "DATASET RECTILINEAR_GRID\n"
     753        append out "DIMENSIONS $xNum 1 1\n"
     754        append out "X_COORDINATES $xNum double\n"
     755        append out [$xv range 0 end]
     756        append out "\n"
     757        append out "Y_COORDINATES 1 double\n"
     758        append out "0\n"
     759        append out "Z_COORDINATES 1 double\n"
     760        append out "0\n"
     761        if { [info exists xMin] } {
     762            set _limits(x) [list $xMin $xMax]
     763        }
     764        set _limits(y) [list 0 0]
     765        set _limits(z) [list 0 0]
    643766        set _vtkdata $out
    644767    } else {
     
    660783    set _vtkdata $out
    661784    set _limits(x) [$xv limits]
    662     set _limits(y) [$yv limits]
     785    if { $_dim > 1 } {
     786        set _limits(y) [$yv limits]
     787    } else {
     788        set _limits(y) [list 0 0]
     789    }
    663790    if { $_dim == 3 } {
    664791        set _limits(z) [$zv limits]
     792    } else {
     793        set _limits(z) [list 0 0]
    665794    }
    666795    return 1
     
    692821    if { $_dim == 3 } {
    693822        set _limits(z) [$zv limits]
     823    } else {
     824        set _limits(z) [list 0 0]
    694825    }
    695826    set _vtkdata $out
     
    722853    if { $_dim == 3 } {
    723854        set _limits(z) [$zv limits]
     855    } else {
     856        set _limits(z) [list 0 0]
    724857    }
    725858    set _vtkdata $out
     
    750883    set _limits(x) [$xv limits]
    751884    set _limits(y) [$yv limits]
    752     if { $_dim == 3 } {
    753         set _limits(z) [$zv limits]
    754     }
     885    set _limits(z) [$zv limits]
     886
    755887    set _vtkdata $out
    756888    return 1
     
    780912    set _limits(x) [$xv limits]
    781913    set _limits(y) [$yv limits]
    782     if { $_dim == 3 } {
    783         set _limits(z) [$zv limits]
    784     }
     914    set _limits(z) [$zv limits]
     915
    785916    set _vtkdata $out
    786917    return 1
     
    810941    set _limits(x) [$xv limits]
    811942    set _limits(y) [$yv limits]
    812     if { $_dim == 3 } {
    813         set _limits(z) [$zv limits]
    814     }
     943    set _limits(z) [$zv limits]
     944
    815945    set _vtkdata $out
    816946    return 1
     
    840970    set _limits(x) [$xv limits]
    841971    set _limits(y) [$yv limits]
    842     if { $_dim == 3 } {
    843         set _limits(z) [$zv limits]
    844     }
     972    set _limits(z) [$zv limits]
     973
    845974    set _vtkdata $out
    846975    return 1
     
    854983        set celltype [GetCellType $celltypes]
    855984    }
    856     if { $_dim == 2 } {
    857         set _numPoints [$xv length]
    858         set data {}
    859         set count 0
    860         set _numCells 0
    861         set celltypes {}
    862         foreach line $lines {
    863             set length [llength $line]
    864             if { $length == 0 } {
    865                 continue
    866             }
    867             if { $numCellTypes > 1 } {
    868                 set cellType [GetCellType [lindex $cellTypes $_numCells]]
    869             }
    870             set numIndices [GetNumIndices $celltype]
    871             if { $numIndices > 0 && $numIndices != $length } {
    872                 puts stderr "WARNING: bad unstructured grid \"$path\": wrong \# of indices specified for celltype $celltype on line \"$line\""
    873                 return 0
    874             }
    875             append data " $numIndices $line\n"
    876             lappend celltypes $celltype
    877             incr count $length;         # Include the indices
    878             incr count;                 # and the number of indices
    879             incr _numCells
    880         }
    881         append out "DATASET UNSTRUCTURED_GRID\n"
    882         append out "POINTS $_numPoints double\n"
    883         set all [blt::vector create \#auto]
    884         $all merge $xv $yv $zv
    885         append out [$all range 0 end]
    886         blt::vector destroy $all
    887         append out "CELLS $_numCells $count\n"
    888         append out $data
    889         append out "CELL_TYPES $_numCells\n"
    890         append out $celltypes
    891         set _limits(x) [$xv limits]
    892         set _limits(y) [$yv limits]
     985
     986    set _numPoints [$xv length]
     987    set data {}
     988    set count 0
     989    set _numCells 0
     990    set celltypes {}
     991    foreach line $lines {
     992        set length [llength $line]
     993        if { $length == 0 } {
     994            continue
     995        }
     996        if { $numCellTypes > 1 } {
     997            set cellType [GetCellType [lindex $cellTypes $_numCells]]
     998        }
     999        set numIndices [GetNumIndices $celltype]
     1000        if { $numIndices > 0 && $numIndices != $length } {
     1001            puts stderr "WARNING: bad unstructured grid \"$path\": wrong \# of indices specified for celltype $celltype on line \"$line\""
     1002            return 0
     1003        } else {
     1004            set numIndices $length
     1005        }
     1006        append data " $numIndices $line\n"
     1007        lappend celltypes $celltype
     1008        incr count $length;         # Include the indices
     1009        incr count;                 # and the number of indices
     1010        incr _numCells
     1011    }
     1012    append out "DATASET UNSTRUCTURED_GRID\n"
     1013    append out "POINTS $_numPoints double\n"
     1014    set all [blt::vector create \#auto]
     1015    $all merge $xv $yv $zv
     1016    append out [$all range 0 end]
     1017    blt::vector destroy $all
     1018    append out "CELLS $_numCells $count\n"
     1019    append out $data
     1020    append out "CELL_TYPES $_numCells\n"
     1021    append out $celltypes
     1022    set _limits(x) [$xv limits]
     1023    set _limits(y) [$yv limits]
     1024    if { $_dim < 3 } {
     1025        set _limits(z) [list 0 0]
    8931026    } else {
    894         set _numPoints [$xv length]
    895 
    896         set data {}
    897         set count 0
    898         set _numCells 0
    899         foreach line $lines {
    900             set length [llength $line]
    901             if { $length == 0 } {
    902                 continue
    903             }
    904             if { $numCellTypes > 1 } {
    905                 set cellType [GetCellType [lindex $cellTypes $_numCells]]
    906             }
    907             set numIndices [GetNumIndices $celltype]
    908             if { $numIndices > 0 && $numIndices != $length } {
    909                 puts stderr "WARNING: bad unstructured grid \"$path\": wrong \# of indices specified for celltype $celltype on line \"$line\""
    910                 return 0
    911             }
    912             append data " $length $line\n"
    913             incr count $length
    914             incr count
    915             incr _numCells
    916         }
    917         append out "DATASET UNSTRUCTURED_GRID\n"
    918         append out "POINTS $_numPoints double\n"
    919         set all [blt::vector create \#auto]
    920         $all merge $xv $yv $zv
    921         append out [$all range 0 end]
    922         blt::vector destroy $all
    923         append out "\n"
    924         append out "CELLS $_numCells $count\n"
    925         append out $data
    926         append out "CELL_TYPES $_numCells\n"
    927         append out $celltypes
    928         set _limits(x) [$xv limits]
    929         set _limits(y) [$yv limits]
    930         set _limits(z) [$zv limits]
    931     }
     1027        set _limits(z) [$zv limits]
     1028    }
     1029
    9321030    set _vtkdata $out
    9331031    return 1
     
    9691067    #         <xcoords>, <ycoords>, <zcoords>.  Split and convert into
    9701068    #         3 vectors, one for each coordinate.
    971     if { $_dim == 2 } {
     1069    if { $_dim == 1 } {
     1070        set xcoords [$_xmlobj get $path.unstructured.xcoords]
     1071        set ycoords [$_xmlobj get $path.unstructured.ycoords]
     1072        set zcoords [$_xmlobj get $path.unstructured.zcoords]
     1073        set data    [$_xmlobj get $path.unstructured.points]
     1074        if { $ycoords != "" } {
     1075            put stderr "can't specify <ycoords> with a 1D mesh"
     1076            return 0
     1077        }
     1078        if { $zcoords != "" } {
     1079            put stderr "can't specify <zcoords> with a 1D mesh"
     1080            return 0
     1081        }
     1082        if { $xcoords != "" } {
     1083            set xv [blt::vector create \#auto]
     1084            $xv set $xcoords
     1085        } elseif { $data != "" } {
     1086            Rappture::ReadPoints $data dim points
     1087            if { $points == "" } {
     1088                puts stderr "WARNING: bad unstructured grid \"$path\": no <points> found."
     1089                return 0
     1090            }
     1091            if { $dim != 1 } {
     1092                puts stderr "WARNING: bad unstructured grid \"$path\": \# of coordinates per point is \"$dim\": does not agree with dimension specified for mesh \"$_dim\""
     1093                return 0
     1094            }
     1095            set xv [blt::vector create \#auto]
     1096            $xv set $points
     1097        } else {
     1098            puts stderr "WARNING: bad unstructured grid \"$path\": no points specified."
     1099            return 0
     1100        }
     1101        set yv [blt::vector create \#auto]
     1102        set zv [blt::vector create \#auto]
     1103        $yv seq 0 0 [$xv length];       # Make an all zeroes vector.
     1104        $zv seq 0 0 [$xv length];       # Make an all zeroes vector.
     1105    } elseif { $_dim == 2 } {
    9721106        set xcoords [$_xmlobj get $path.unstructured.xcoords]
    9731107        set ycoords [$_xmlobj get $path.unstructured.ycoords]
     
    10721206# ----------------------------------------------------------------------
    10731207itcl::body Rappture::Mesh::ReadNodesElements {path} {
    1074     set type "nodeselements"
     1208    set _type "nodeselements"
    10751209    set count 0
    10761210
     
    10911225        set _limits(x) [$xv limits]
    10921226        set _limits(y) [$yv limits]
     1227        set _limits(z) [list 0 0]
    10931228        # 2D Dataset. All Z coordinates are 0
    10941229        $zv seq 0.0 0.0 $_numPoints
  • branches/1.3/gui/scripts/resultviewer.tcl

    r4254 r4474  
    346346                return;                 # Ignore invalid mesh objects.
    347347            }
    348             switch -- [$dataobj dimensions] {
    349                 2 {
    350                     set mode "mesh"
    351                     if {![info exists _mode2widget($mode)]} {
    352                         set w $itk_interior.mesh
    353                         Rappture::MeshResult $w
    354                         set _mode2widget($mode) $w
    355                     }
    356                 }
    357                 default {
    358                     error "can't handle [$dataobj dimensions]D field"
    359                 }
     348            set mode "vtkmeshviewer"
     349            if {![info exists _mode2widget($mode)]} {
     350                set servers [Rappture::VisViewer::GetServerList "vtkvis"]
     351                set w $itk_interior.$mode
     352                Rappture::VtkMeshViewer $w $servers
     353                set _mode2widget($mode) $w
    360354            }
    361355        }
  • branches/1.3/gui/scripts/unirect2d.tcl

    r3571 r4474  
    3535    private variable _isValid 0;        # Indicates if the data is valid.
    3636
     37    private method GetString { obj path varName }
     38    private method GetValue  { obj path varName }
     39    private method GetSize   { obj path varName }
     40
    3741    constructor {xmlobj path} {
    3842        # defined below
     
    4448    public proc release {obj}
    4549    public method limits {axis}
     50    public method units { axis }
     51    public method label { axis }
    4652    public method blob {}
    4753    public method hints {{keyword ""}}
     
    5965        return $_vtkdata
    6066    }
    61 
    62     private method GetString { obj path varName }
    63     private method GetValue { obj path varName }
    64     private method GetSize { obj path varName }
    65    
    6667}
    6768
     
    8889
    8990# ----------------------------------------------------------------------
    90 # USAGE: Rappture::Mesh::release <obj>
     91# USAGE: Rappture::Unirect2d::release <obj>
    9192#
    9293# Clients call this when they're no longer using a Mesh fetched
     
    210211            set min $_xMin
    211212            set max $_xMax
    212             set axis "xaxis"
    213213        }
    214214        y - ylin - ylog {
    215215            set min $_yMin
    216216            set max $_yMax
    217             set axis "yaxis"
     217        }
     218        z - zlin - zlog {
     219            set min 0
     220            set max 0
    218221        }
    219222        default {
     
    224227}
    225228
     229#
     230# units --
     231#
     232#       Returns the units of the given axis.
     233#
     234itcl::body Rappture::Unirect2d::units { axis } {
     235    if { [info exists _hints(${axis}units)] } {
     236        return $_hints(${axis}units)
     237    }
     238    return ""
     239}
     240
     241#
     242# label --
     243#
     244#       Returns the label of the given axis.
     245#
     246itcl::body Rappture::Unirect2d::label { axis } {
     247    if { [info exists _hints(${axis}label)] } {
     248        return $_hints(${axis}label)
     249    }
     250    return ""
     251}
    226252
    227253# ----------------------------------------------------------------------
     
    241267        set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))"
    242268    }
    243    
    244269    if {[info exists _hints(group)] && [info exists _hints(label)]} {
    245270        # pop-up help for each curve
     
    254279    return [array get _hints]
    255280}
    256 
    257281
    258282itcl::body Rappture::Unirect2d::GetSize { obj path varName } {
  • branches/1.3/gui/scripts/unirect3d.tcl

    r3330 r4474  
    2727    public method mesh {}
    2828    public method values {}
     29    public method units { axis }
     30    public method label { axis }
    2931    public method hints {{keyword ""}}
    3032    public method order {} {
     
    187189            set min $_xMin
    188190            set max $_xMax
    189             set axis "xaxis"
    190191        }
    191192        y - ylin - ylog {
    192193            set min $_yMin
    193194            set max $_yMax
    194             set axis "yaxis"
    195195        }
    196196        z - zlin - zlog {
    197197            set min $_zMin
    198198            set max $_zMax
    199             set axis "zaxis"
    200199        }
    201200        v - vlin - vlog {
     
    207206                set max 1.0
    208207            }
    209             set axis "vaxis"
    210208        }
    211209        default {
     
    216214}
    217215
     216#
     217# units --
     218#
     219#       Returns the units of the given axis.
     220#
     221itcl::body Rappture::Unirect3d::units { axis } {
     222    if { [info exists _hints({$axis}units)] } {
     223        return $_hints(${axis}units)
     224    }
     225    return ""
     226}
     227
     228#
     229# label --
     230#
     231#       Returns the label of the given axis.
     232#
     233itcl::body Rappture::Unirect3d::label { axis } {
     234    if { [info exists _hints({$axis}label)] } {
     235        return $_hints(${axis}label)
     236    }
     237    return ""
     238}
    218239
    219240# ----------------------------------------------------------------------
  • branches/1.3/gui/scripts/vtkvolumeviewer.tcl

    r4455 r4474  
    16551655        "static_triad"    "static" \
    16561656        "closest_triad"   "closest" \
    1657         "furthest_triad"  "furthest" \
     1657        "furthest_triad"  "farthest" \
    16581658        "outer_edges"     "outer"         
    16591659    $itk_component(axismode) value "static"
Note: See TracChangeset for help on using the changeset viewer.