Changeset 5638 for branches


Ignore:
Timestamp:
May 29, 2015, 8:00:56 PM (9 years ago)
Author:
ldelgass
Message:

Merge r5610:5636 from trunk

Location:
branches/1.3
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/examples/zoo/mesh/mesh.tcl

    r5629 r5638  
    2121$xv seq 0 1 50
    2222
     23set hide no
     24
    2325switch -- $meshtype {
    2426    "cloud" {
    25         set mesh output.mesh
    26 
    27         $driver put $mesh.about.label "cloud in unstructured mesh"
    28         $driver put $mesh.dim  2
    29         $driver put $mesh.units "m"
    30         $driver put $mesh.hide "yes"
    31 
    32         set points {}
    33         foreach y [$xv range 0 end] {
    34             foreach x [$xv range 0 end] {
    35                 append points "$x $y\n"
    36             }
    37         }
    38         $driver put $mesh.unstructured.points $points
    39         $driver put $mesh.unstructured.celltypes ""
     27        set mesh output.mesh
     28
     29        $driver put $mesh.about.label "Mesh"
     30        $driver put $mesh.about.description "cloud in unstructured mesh"
     31        $driver put $mesh.dim  2
     32        $driver put $mesh.units "m"
     33        $driver put $mesh.hide $hide
     34
     35        set points {}
     36        foreach y [$xv range 0 end] {
     37            foreach x [$xv range 0 end] {
     38                append points "$x $y\n"
     39            }
     40        }
     41        $driver put $mesh.unstructured.points $points
     42        $driver put $mesh.unstructured.celltypes ""
    4043    }
    4144    "regular" {
    42         set mesh output.mesh
    43 
    44         $driver put $mesh.about.label "uniform grid mesh"
    45         $driver put $mesh.dim  2
    46         $driver put $mesh.units "m"
    47         $driver put $mesh.hide "yes"
    48 
    49         $driver put $mesh.grid.xaxis.min 0.0
    50         $driver put $mesh.grid.xaxis.max 1.0
    51         $driver put $mesh.grid.xaxis.numpoints 50
    52         $driver put $mesh.grid.yaxis.min 0.0
    53         $driver put $mesh.grid.yaxis.max 1.0
    54         $driver put $mesh.grid.yaxis.numpoints 50
     45        set mesh output.mesh
     46
     47        $driver put $mesh.about.label "Mesh"
     48        $driver put $mesh.about.description "uniform grid mesh"
     49        $driver put $mesh.dim  2
     50        $driver put $mesh.units "m"
     51        $driver put $mesh.hide $hide
     52
     53        $driver put $mesh.grid.xaxis.min 0.0
     54        $driver put $mesh.grid.xaxis.max 1.0
     55        $driver put $mesh.grid.xaxis.numpoints 50
     56        $driver put $mesh.grid.yaxis.min 0.0
     57        $driver put $mesh.grid.yaxis.max 1.0
     58        $driver put $mesh.grid.yaxis.numpoints 50
    5559    }
    5660    "irregular" {
    57         set mesh output.mesh
    58 
    59         $driver put $mesh.about.label "irregular grid mesh"
    60         $driver put $mesh.dim  2
    61         $driver put $mesh.units "m"
    62         $driver put $mesh.hide "yes"
    63 
    64         $driver put $mesh.grid.xcoords [$xv range 0 end]
    65         $driver put $mesh.grid.ycoords [$xv range 0 end]
     61        set mesh output.mesh
     62
     63        $driver put $mesh.about.label "Mesh"
     64        $driver put $mesh.about.description "irregular rectilinear grid mesh"
     65        $driver put $mesh.dim  2
     66        $driver put $mesh.units "m"
     67        $driver put $mesh.hide $hide
     68
     69        $driver put $mesh.grid.xcoords [$xv range 0 end]
     70        $driver put $mesh.grid.ycoords [$xv range 0 end]
    6671    }
    6772    "hybrid" {
    68         set mesh output.mesh
    69 
    70         $driver put $mesh.about.label "hybrid regular and irregular grid mesh"
    71         $driver put $mesh.dim  2
    72         $driver put $mesh.units "m"
    73         $driver put $mesh.hide "yes"
    74 
    75         $driver put $mesh.units "m"
    76         $driver put $mesh.grid.xcoords [$xv range 0 end]
    77         $driver put $mesh.grid.yaxis.min 0.0
    78         $driver put $mesh.grid.yaxis.max 1.0
    79         $driver put $mesh.grid.yaxis.numpoints 50
     73        set mesh output.mesh
     74
     75        $driver put $mesh.about.label "Mesh"
     76        $driver put $mesh.about.description "hybrid regular and irregular rectilinear grid mesh"
     77        $driver put $mesh.dim  2
     78        $driver put $mesh.units "m"
     79        $driver put $mesh.hide $hide
     80
     81        $driver put $mesh.grid.xcoords [$xv range 0 end]
     82        $driver put $mesh.grid.yaxis.min 0.0
     83        $driver put $mesh.grid.yaxis.max 1.0
     84        $driver put $mesh.grid.yaxis.numpoints 50
     85    }
     86    "structured" {
     87        set mesh output.mesh
     88
     89        $driver put $mesh.about.label "Mesh"
     90        $driver put $mesh.about.description "Structured (Curvilinear) Grid"
     91        $driver put $mesh.dim  2
     92        $driver put $mesh.units "m"
     93        $driver put $mesh.hide $hide
     94
     95        $driver put $mesh.grid.xdim 50
     96        $driver put $mesh.grid.ydim 50
     97        set points {}
     98        foreach y [$xv range 0 end] {
     99            foreach x [$xv range 0 end] {
     100                append points "$x $y\n"
     101            }
     102        }
     103        $driver put $mesh.grid.points $points
    80104    }
    81105    "triangular" {
    82         set mesh output.mesh
    83 
    84         $driver put $mesh.about.label "triangles in unstructured mesh"
    85         $driver put $mesh.dim  2
    86         $driver put $mesh.units "m"
    87         $driver put $mesh.hide "yes"
    88        
    89         $driver put -type file -compress no $mesh.unstructured.points \
    90             points.txt
    91         $driver put -type file -compress no $mesh.unstructured.triangles \
    92             triangles.txt
     106        set mesh output.mesh
     107
     108        $driver put $mesh.about.label "Mesh"
     109        $driver put $mesh.about.description "triangles in unstructured mesh"
     110        $driver put $mesh.dim  2
     111        $driver put $mesh.units "m"
     112        $driver put $mesh.hide $hide
     113       
     114        $driver put -type file -compress no $mesh.unstructured.points \
     115            points.txt
     116        $driver put -type file -compress no $mesh.unstructured.triangles \
     117            triangles.txt
    93118    }
    94119    "generic" {
    95         set mesh output.mesh
    96 
    97         $driver put $mesh.about.label "nodes and elements mesh"
    98         $driver put $mesh.dim  2
    99         $driver put $mesh.units "m"
    100         $driver put $mesh.hide "yes"
    101 
    102         set count 0
    103         set f [open "points.txt" "r"]
    104         set points [read $f]
    105         close $f
    106         foreach { x y } $points {
    107             $driver put $mesh.node($count) "$x $y"
    108             incr count
    109         }
    110         set count 0
    111         set f [open "triangles.txt" "r"]
    112         set triangles [read $f]
    113         close $f
    114         foreach { a b c } $triangles {
    115             $driver put $mesh.element($count).nodes "$a $b $c"
    116             incr count
    117         }
     120        set mesh output.mesh
     121
     122        $driver put $mesh.about.label "Mesh"
     123        $driver put $mesh.about.description "nodes and elements mesh"
     124        $driver put $mesh.dim  2
     125        $driver put $mesh.units "m"
     126        $driver put $mesh.hide $hide
     127
     128        set count 0
     129        set f [open "points.txt" "r"]
     130        set points [read $f]
     131        close $f
     132        foreach { x y } $points {
     133            $driver put $mesh.node($count) "$x $y"
     134            incr count
     135        }
     136        set count 0
     137        set f [open "triangles.txt" "r"]
     138        set triangles [read $f]
     139        close $f
     140        foreach { a b c } $triangles {
     141            $driver put $mesh.element($count).nodes "$a $b $c"
     142            incr count
     143        }
    118144    }
    119145    "unstructured" {
    120         set mesh output.mesh
    121 
    122         $driver put $mesh.about.label "Unstructured Grid"
    123         $driver put $mesh.dim  2
    124         $driver put $mesh.units "m"
    125         $driver put $mesh.hide "yes"
    126 
    127         $driver put -type file -compress no $mesh.unstructured.points points.txt
    128         set cells {}
    129         set f [open "triangles.txt" "r"]
    130         set triangles [read $f]
    131         close $f
    132         foreach { a b c } $triangles {
    133             append cells "$a $b $c\n"
    134         }
    135         $driver put $mesh.unstructured.cells $cells
    136         $driver put $mesh.unstructured.celltypes "triangle"
     146        set mesh output.mesh
     147
     148        $driver put $mesh.about.label "Mesh"
     149        $driver put $mesh.about.description "Unstructured Grid"
     150        $driver put $mesh.dim  2
     151        $driver put $mesh.units "m"
     152        $driver put $mesh.hide $hide
     153
     154        $driver put -type file -compress no $mesh.unstructured.points points.txt
     155        set cells {}
     156        set f [open "triangles.txt" "r"]
     157        set triangles [read $f]
     158        close $f
     159        foreach { a b c } $triangles {
     160            append cells "$a $b $c\n"
     161        }
     162        $driver put $mesh.unstructured.cells $cells
     163        $driver put $mesh.unstructured.celltypes "triangle"
    137164    }
    138165    "cells" {
    139         set mesh output.mesh
    140 
    141         $driver put $mesh.about.label \
    142             "Unstructured Grid with Heterogeneous Cells"
    143         $driver put $mesh.dim  2
    144         $driver put $mesh.units "m"
    145         $driver put $mesh.hide "yes"
    146 
    147         set celltypes {}
    148         set f [open "triangles.txt" "r"]
    149         set triangles [read $f]
    150         close $f
    151         foreach { a b c } $triangles {
    152             append cells "$a $b $c\n"
    153             append celltypes "triangle\n"
    154         }
    155         $driver put -type file -compress no $mesh.unstructured.points points.txt
    156         $driver put $mesh.unstructured.celltypes $celltypes
    157         $driver put $mesh.unstructured.cells $cells
     166        set mesh output.mesh
     167
     168        $driver put $mesh.about.label "Mesh"
     169        $driver put $mesh.about.description \
     170            "Unstructured Grid with Heterogeneous Cells"
     171        $driver put $mesh.dim  2
     172        $driver put $mesh.units "m"
     173        $driver put $mesh.hide $hide
     174
     175        set celltypes {}
     176        set f [open "triangles.txt" "r"]
     177        set triangles [read $f]
     178        close $f
     179        foreach { a b c } $triangles {
     180            append cells "$a $b $c\n"
     181            append celltypes "triangle\n"
     182        }
     183        $driver put -type file -compress no $mesh.unstructured.points points.txt
     184        $driver put $mesh.unstructured.celltypes $celltypes
     185        $driver put $mesh.unstructured.cells $cells
    158186    }
    159187    "vtkmesh" {
    160         set mesh output.mesh
    161 
    162         $driver put $mesh.about.label "vtk mesh"
    163         $driver put $mesh.dim  2
    164         $driver put $mesh.units "m"
    165         $driver put $mesh.hide "yes"
    166         $driver put -type file -compress no $mesh.vtk mesh.vtk
     188        set mesh output.mesh
     189
     190        $driver put $mesh.about.label "Mesh"
     191        $driver put $mesh.about.description "vtk mesh"
     192        $driver put $mesh.dim  2
     193        $driver put $mesh.units "m"
     194        $driver put $mesh.hide $hide
     195        $driver put -type file -compress no $mesh.vtk mesh.vtk
    167196    }
    168197    "vtkfield" {
    169198
    170         $driver put output.field(substrate).about.label "Substrate Surface"
    171         $driver put -type file -compress no \
    172             output.field(substrate).component.vtk file.vtk
     199        $driver put output.field(substrate).about.label "Substrate Surface"
     200        $driver put -type file -compress no \
     201            output.field(substrate).component.vtk file.vtk
    173202        $driver put output.string.current ""
    174         Rappture::result $driver
    175         exit 0
     203        Rappture::result $driver
     204        exit 0
    176205    }
    177206    default {
    178         error "unknown mesh type \"$meshtype\""
     207        error "unknown mesh type \"$meshtype\""
    179208    }
    180209}
  • branches/1.3/examples/zoo/mesh/tool.xml

    • Property svn:mime-type changed from application/xml to text/xml
    r3752 r5638  
    5151    <option>
    5252     <about>
     53      <label>mesh as a structured (curvilinear) grid</label>
     54      <description>Structured 2D grid.</description>
     55     </about>
     56     <value>structured</value>
     57    </option>
     58    <option>
     59     <about>
    5360      <label>mesh as unstructured grid</label>
    5461      <description>Unstructured 2D grid.</description>
  • branches/1.3/gui/scripts/cloud.tcl

    r5615 r5638  
    2525    }
    2626    public method points {}
    27     public method mesh {}
    2827    public method units { axis }
    2928    public method label { axis }
     
    216215
    217216# ----------------------------------------------------------------------
    218 # USAGE: mesh
    219 #
    220 # Returns the vtk object representing the mesh.
    221 # ----------------------------------------------------------------------
    222 itcl::body Rappture::Cloud::mesh {} {
    223     return $_points
    224 }
    225 
    226 # ----------------------------------------------------------------------
    227217# USAGE: dimensions
    228218#
  • branches/1.3/gui/scripts/field.tcl

    r5615 r5638  
    152152    private variable _comp2vtk;         # cname => vtk file data
    153153    private variable _comp2dx;          # cname => OpenDX data
    154     private variable _comp2unirect2d;   # cname => unirect2d obj
    155     private variable _comp2unirect3d;   # cname => unirect3d obj
    156154    private variable _comp2style;       # cname => style settings
    157155    private variable _comp2cntls;       # cname => x,y control points (1D only)
     
    160158    private variable _comp2mesh;        # list: mesh obj, BLT vector of values
    161159                                        # valid for cloud,mesh,unirect2d
    162     private variable _values "";        # Only for unirect2d - list of values
    163 
    164160    private common _alwaysConvertDX 0;  # If set, convert DX and store as VTK,
    165161                                        # even if viewer is nanovis/flowvis
     
    221217    foreach name [array names _comp2xy] {
    222218        eval blt::vector destroy $_comp2xy($name)
    223     }
    224     foreach name [array names _comp2unirect2d] {
    225         itcl::delete object $_comp2unirect2d($name)
    226     }
    227     foreach name [array names _comp2unirect3d] {
    228         itcl::delete object $_comp2unirect3d($name)
    229219    }
    230220    foreach name [array names _comp2flowhints] {
     
    306296#
    307297# For 1D data (curve), returns a BLT vector of x values for the field
    308 # component <name>.  Otherwise, this method is unused
     298# component <name>.  Otherwise, this method is unused.
    309299# ----------------------------------------------------------------------
    310300itcl::body Rappture::Field::mesh {{cname -overall}} {
     
    316306    }
    317307    if {[info exists _comp2vtk($cname)]} {
    318         # FIXME: extract mesh from VTK file data.
    319308        error "method \"mesh\" is not implemented for VTK file data"
    320309    }
     
    323312    }
    324313    if {[info exists _comp2mesh($cname)]} {
    325         # FIXME: This only works for cloud
    326         set mesh [lindex $_comp2mesh($cname) 0]
    327         return [$mesh points]
    328     }
    329     if {[info exists _comp2unirect2d($cname)]} {
    330         # FIXME: unirect2d mesh is a list: xMin xMax xNum yMin yMax yNum
    331         return [$_comp2unirect2d($cname) mesh]
    332     }
    333     if {[info exists _comp2unirect3d($cname)]} {
    334         # This returns a list of x,y,z points
    335         return [$_comp2unirect3d($cname) mesh]
     314        error "method \"mesh\" is not implemented for Rappture::Mesh"
    336315    }
    337316    error "can't get field mesh: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
     
    342321#
    343322# For 1D data (curve), returns a BLT vector of field values (y coords)
    344 # for the field component <name>.  Otherwise, this method is unused
     323# for the field component <name>.  Otherwise, this method is unused.
     324# The number of elements in the vector should be a multiple of the
     325# return value of [numComponents]
    345326# ----------------------------------------------------------------------
    346327itcl::body Rappture::Field::values {cname} {
     
    351332        return [lindex $_comp2xy($cname) 1]  ;# return yv
    352333    }
    353     if { [info exists _comp2vtk($cname)] } {
    354         # FIXME: extract the values from the VTK file data
     334    if {[info exists _comp2vtk($cname)]} {
    355335        error "method \"values\" is not implemented for VTK file data"
    356336    }
     
    358338        error "method \"values\" is not implemented for DX file data"
    359339    }
    360     if { [info exists _comp2mesh($cname)] } {
    361         set vector [lindex $_comp2mesh($cname) 1]
    362         return [$vector range 0 end]
    363     }
    364     if {[info exists _comp2unirect2d($cname)]} {
    365         return $_values
    366     }
    367     if {[info exists _comp2unirect3d($cname)]} {
    368         return [$_comp2unirect3d($cname) values]
     340    if {[info exists _comp2mesh($cname)]} {
     341        return [lindex $_comp2mesh($cname) 1] ;# return vector
    369342    }
    370343    error "can't get field values. Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
     
    383356        return $_comp2dx($cname)  ;# return gzipped, base64-encoded DX data
    384357    }
    385     if {[info exists _comp2unirect2d($cname)]} {
    386         set blob [$_comp2unirect2d($cname) blob]
    387         lappend blob "values" $_values
    388         return $blob
    389     }
    390     if {[info exists _comp2unirect3d($cname)]} {
    391         return [$_comp2unirect3d($cname) blob]
    392     }
    393     if { [info exists _comp2vtk($cname)] } {
    394         error "blob not implemented for VTK file data"
     358    if {[info exists _comp2mesh($cname)]} {
     359        error "method \"blob\" not implemented for Rappture::Mesh"
     360    }
     361    if {[info exists _comp2vtk($cname)]} {
     362        error "method \"blob\" not implemented for VTK file data"
    395363    }
    396364    if {[info exists _comp2xy($cname)]} {
    397         error "blob not implemented for XY data"
     365        error "method \"blob\" not implemented for XY data"
    398366    }
    399367    error "can't get field blob: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
     
    752720    }
    753721    array unset _comp2vtk
    754     foreach name [array names _comp2unirect2d] {
    755         eval itcl::delete object $_comp2unirect2d($name)
    756     }
    757     foreach name [array names _comp2unirect3d] {
    758         eval itcl::delete object $_comp2unirect3d($name)
    759     }
    760722    catch {unset _comp2xy}
    761723    catch {unset _comp2dx}
    762724    catch {unset _comp2dims}
    763725    catch {unset _comp2style}
    764     array unset _comp2unirect2d
    765     array unset _comp2unirect3d
    766726    array unset _dataobj2type
    767727    #
     
    11221082# Returns the data storage type of the field.
    11231083#
    1124 # FIXME: What are the valid types?
     1084# Types:
     1085#   1D,cloud,dicom,dx,mesh,ucd,unirect2d,unirect3d,vtk
    11251086#
    11261087itcl::body Rappture::Field::type {} {
     
    13221283        set data [Rappture::encoding::decode -as zb64 $data]
    13231284        return [Rappture::DxToVtk $data]
    1324     }
    1325     # unirect2d (deprecated)
    1326     # This can be removed when the nanovis server with support for loading VTK
    1327     # vector data is released
    1328     if {[info exists _comp2unirect2d($cname)]} {
    1329         set label $cname
    1330         regsub -all { } $label {_} label
    1331         set elemSize [numComponents $cname]
    1332         set numValues [$_comp2unirect2d($cname) numpoints]
    1333         append out "# vtk DataFile Version 3.0\n"
    1334         append out "[hints label]\n"
    1335         append out "ASCII\n"
    1336         append out [$_comp2unirect2d($cname) vtkdata]
    1337         append out "POINT_DATA $numValues\n"
    1338         if {$elemSize == 3} {
    1339             append out "VECTORS $label double\n"
    1340         } else {
    1341             append out "SCALARS $label double $elemSize\n"
    1342             append out "LOOKUP_TABLE default\n"
    1343         }
    1344         # values for VTK are x-fastest
    1345         append out $_values
    1346         append out "\n"
    1347         return $out
    1348     }
    1349     # unirect3d (deprecated)
    1350     if {[info exists _comp2unirect3d($cname)]} {
    1351         set vector [$_comp2unirect3d($cname) values]
    1352         set label $cname
    1353         regsub -all { } $label {_} label
    1354         set elemSize [numComponents $cname]
    1355         set numValues [expr [$vector length] / $elemSize]
    1356         append out "# vtk DataFile Version 3.0\n"
    1357         append out "[hints label]\n"
    1358         append out "ASCII\n"
    1359         append out [$_comp2unirect3d($cname) vtkdata]
    1360         append out "POINT_DATA $numValues\n"
    1361         if {$elemSize == 3} {
    1362             append out "VECTORS $label double\n"
    1363         } else {
    1364             append out "SCALARS $label double $elemSize\n"
    1365             append out "LOOKUP_TABLE default\n"
    1366         }
    1367         # values for VTK are x-fastest
    1368         append out [$vector range 0 end]
    1369         append out "\n"
    1370         return $out
    13711285    }
    13721286    # Points on mesh:  Construct VTK file output.
     
    14601374    lappend _comp2fldName($cname) $name
    14611375
    1462     # Handle bizarre cases that are due to be removed.
    1463     if { $element == "unirect3d" } {
    1464         # Special case: unirect3d (deprecated) + flow.
    1465         set vectorsize [numComponents $cname]
    1466         set _type unirect3d
    1467         set _dim 3
    1468         if { $_viewer == "" } {
    1469             set _viewer flowvis
    1470         }
    1471         set _comp2dims($cname) "3D"
    1472         set _comp2unirect3d($cname) \
    1473             [Rappture::Unirect3d \#auto $_xmlobj $_field $cname $vectorsize]
    1474         set _comp2style($cname) [$_field get $cname.style]
    1475         set limits {}
    1476         foreach axis { x y z } {
    1477             lappend limits $axis [$_comp2unirect3d($cname) limits $axis]
    1478         }
    1479         # Get the data limits
    1480         set vector [$_comp2unirect3d($cname) values]
    1481         set minmax [VectorLimits $vector $vectorsize]
    1482         lappend limits $cname $minmax
    1483         lappend limits v      $minmax
    1484         set _comp2limits($cname) $limits
    1485         if {[$_field element $cname.flow] != ""} {
    1486             set _comp2flowhints($cname) \
    1487                 [Rappture::FlowHints ::\#auto $_field $cname $_units]
    1488         }
    1489         incr _counter
    1490         return 1
    1491     }
    1492     if { $element == "unirect2d" && [$_field element $cname.flow] != "" } {
    1493         # Special case: unirect2d (deprecated) + flow.
    1494         set vectorsize [numComponents $cname]
    1495         set _type unirect2d
    1496         set _dim 2
    1497         if { $_viewer == "" } {
    1498             set _viewer "flowvis"
    1499         }
    1500         set _comp2dims($cname) "2D"
    1501         set _comp2unirect2d($cname) \
    1502             [Rappture::Unirect2d \#auto $_xmlobj $path]
    1503         set _comp2style($cname) [$_field get $cname.style]
    1504         set _comp2flowhints($cname) \
    1505             [Rappture::FlowHints ::\#auto $_field $cname $_units]
    1506         set _values [$_field get $cname.values]
    1507         set limits {}
    1508         foreach axis { x y z } {
    1509             lappend limits $axis [$_comp2unirect2d($cname) limits $axis]
    1510         }
    1511         set xv [blt::vector create \#auto]
    1512         $xv set $_values
    1513         set minmax [VectorLimits $xv $vectorsize]
    1514         lappend limits $cname $minmax
    1515         lappend limits v $minmax
    1516         blt::vector destroy $xv
    1517         set _comp2limits($cname) $limits
    1518         incr _counter
    1519         return 1
    1520     }
    15211376    switch -- $element {
    15221377        "cloud" {
     
    15341389            set mesh [Rappture::Unirect2d::fetch $_xmlobj $path]
    15351390            set _type unirect2d
     1391        }
     1392        "unirect3d" {
     1393            set mesh [Rappture::Unirect3d::fetch $_xmlobj $path]
     1394            set _type unirect3d
    15361395        }
    15371396    }
  • branches/1.3/gui/scripts/flowvisviewer.tcl

    r5600 r5638  
    11371137        foreach cname [$dataobj components] {
    11381138            set tag $dataobj-$cname
    1139             set isvtk 0
    1140             # FIXME: Would like to use the type method of the dataobj
    1141             # but the returned value isn't well defined now
    1142             if {[catch {
    1143                 # Send the data as one huge base64-encoded mess -- yuck!
     1139            if {[$dataobj type] == "dx"} {
    11441140                set data [$dataobj blob $cname]
    1145             }]} {
     1141            } else {
    11461142                set data [$dataobj vtkdata $cname]
    1147                 set isvtk 1
    11481143            }
    11491144            set nbytes [string length $data]
  • branches/1.3/gui/scripts/mesh.tcl

    r5629 r5638  
    2323
    2424itcl::class Rappture::Mesh {
    25     private variable _xmlobj ""  ;      # Ref to XML obj with device data
    26     private variable _mesh ""    ;      # Lib obj representing this mesh
    27     private variable _dim        0;     # Dimension of mesh (1, 2, or 3)
    28     private variable _type "";          # Indicates the type of mesh.
    29     private variable _axis2units;       # System of units for x, y, z
    30     private variable _axis2labels;      #
    31     private variable _hints
    32     private variable _limits        ;   # Array of mesh limits. Keys are
    33                                         # xmin, xmax, ymin, ymax, ...
    34     private variable _numPoints 0   ;   # # of points in mesh
    35     private variable _numCells 0   ;    # # of cells in mesh
    36     private variable _vtkdata "";       # Mesh in vtk file format.
    37     private variable _isValid 0;        # Indicates if the mesh is valid.
    3825    constructor {xmlobj path} {
    3926        # defined below
     
    6552        return $_numCells
    6653    }
    67 
    68     private common _xp2obj       ;        # used for fetch/release ref counting
    69     private common _obj2ref      ;        # used for fetch/release ref counting
    7054
    7155    private method ReadNodesElements {path}
     
    9175    private method GetCellType { name }
    9276    private method GetNumIndices { type }
     77
     78    private variable _xmlobj "";        # Ref to XML obj with device data
     79    private variable _mesh "";          # Lib obj representing this mesh
     80    private variable _dim 0;            # Dimension of mesh (1, 2, or 3)
     81    private variable _type "";          # Indicates the type of mesh.
     82    private variable _axis2units;       # System of units for x, y, z
     83    private variable _axis2labels;      #
     84    private variable _hints
     85    private variable _limits;           # Array of mesh limits. Keys are
     86                                        # xmin, xmax, ymin, ymax, ...
     87    private variable _numPoints 0;      # Number of points in mesh
     88    private variable _numCells 0;       # Number of cells in mesh
     89    private variable _vtkdata "";       # Mesh in vtk file format.
     90    private variable _isValid 0;        # Indicates if the mesh is valid.
     91
     92    private common _xp2obj;             # used for fetch/release ref counting
     93    private common _obj2ref;            # used for fetch/release ref counting
    9394}
    9495
     
    539540        set numCoords [$all length]
    540541        if { [info exists zNum] } {
     542            if { ![info exists yNum] || ![info exists xNum] } {
     543                puts stderr "WARNING: bad grid \"$path\": missing grid dimension"
     544                blt::vector destroy $all $xv $yv $zv
     545                return 0
     546            }
    541547            set _dim 3
    542548            set _numPoints [expr $xNum * $yNum * $zNum]
     
    544550            if { ($_numPoints*3) != $numCoords } {
    545551                puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>"
     552                blt::vector destroy $all $xv $yv $zv
    546553                return 0
    547554            }
    548555            if { ($numCoords % 3) != 0 } {
    549556                puts stderr "WARNING: bad grid \"$path\": wrong \# of coordinates for 3D grid"
     557                blt::vector destroy $all $xv $yv $zv
    550558                return 0
    551559            }
     
    558566            append out "DIMENSIONS $xNum $yNum $zNum\n"
    559567            append out "POINTS $_numPoints double\n"
    560             append out [$all range 0 end]
    561             append out "\n"
     568            foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     569                append out "$x $y $z\n"
     570            }
    562571            set _vtkdata $out
    563572        } elseif { [info exists yNum] } {
     573            if { ![info exists xNum] } {
     574                puts stderr "WARNING: bad grid \"$path\": missing grid dimension"
     575                blt::vector destroy $all $xv $yv $zv
     576                return 0
     577            }
    564578            set _dim 2
    565579            set _numPoints [expr $xNum * $yNum]
     
    567581            if { ($_numPoints*2) != $numCoords } {
    568582                puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>"
     583                blt::vector destroy $all $xv $yv $zv
    569584                return 0
    570585            }
    571586            if { ($numCoords % 2) != 0 } {
    572587                puts stderr "WARNING: bad grid \"$path\": wrong \# of coordinates for 2D grid"
     588                blt::vector destroy $all $xv $yv $zv
    573589                return 0
    574590            }
     591            $all split $xv $yv
    575592            foreach axis {x y} {
    576593                set vector [set ${axis}v]
     
    583600            append out "DIMENSIONS $xNum $yNum 1\n"
    584601            append out "POINTS $_numPoints double\n"
    585             append out [$all range 0 end]
    586             append out "\n"
     602            foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     603                append out "$x $y $z\n"
     604            }
    587605            set _vtkdata $out
    588606        } else {
     
    592610            if { $_numPoints != $numCoords } {
    593611                puts stderr "WARNING: bad grid \"$path\": \# of points does not match <xdim>"
     612                blt::vector destroy $all $xv $yv $zv
    594613                return 0
    595614            }
     615            $all dup $xv
    596616            set _limits(x) [$xv limits]
    597617            set _limits(y) [list 0 0]
     
    603623            append out "DIMENSIONS $xNum 1 1\n"
    604624            append out "POINTS $_numPoints double\n"
    605             append out [$all range 0 end]
    606             append out "\n"
     625            foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     626                append out "$x $y $z\n"
     627            }
    607628            set _vtkdata $out
    608629        }
     
    815836    set celltypes {}
    816837    foreach { a b c } $triangles {
    817         append data " 3 $a $b $c\n"
     838        append data "3 $a $b $c\n"
    818839        append celltypes "5\n"
    819840        incr _numCells
     
    822843    append out "POINTS $_numPoints double\n"
    823844    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    824         append out " $x $y $z\n"
     845        append out "$x $y $z\n"
    825846    }
    826847    set count [expr $_numCells * 4]
     
    847868    set celltypes {}
    848869    foreach { a b c d } $quads {
    849         append data " 4 $a $b $c $d\n"
     870        append data "4 $a $b $c $d\n"
    850871        append celltypes "9\n"
    851872        incr _numCells
     
    854875    append out "POINTS $_numPoints double\n"
    855876    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    856         append out " $x $y $z\n"
     877        append out "$x $y $z\n"
    857878    }
    858879    set count [expr $_numCells * 5]
     
    884905            continue
    885906        }
    886         append data " $numIndices $line\n"
     907        append data "$numIndices $line\n"
    887908        incr _numCells
    888909        set count [expr $count + $numIndices + 1]
     
    891912    append out "POINTS $_numPoints double\n"
    892913    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    893         append out " $x $y $z\n"
     914        append out "$x $y $z\n"
    894915    }
    895916    append out "VERTICES $_numCells $count\n"
     
    918939            continue
    919940        }
    920         append data " $numIndices $line\n"
     941        append data "$numIndices $line\n"
    921942        incr _numCells
    922943        set count [expr $count + $numIndices + 1]
     
    925946    append out "POINTS $_numPoints double\n"
    926947    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    927         append out " $x $y $z\n"
     948        append out "$x $y $z\n"
    928949    }
    929950    append out "LINES $_numCells $count\n"
     
    952973            continue
    953974        }
    954         append data " $numIndices $line\n"
     975        append data "$numIndices $line\n"
    955976        incr _numCells
    956977        set count [expr $count + $numIndices + 1]
     
    959980    append out "POINTS $_numPoints double\n"
    960981    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    961         append out " $x $y $z\n"
     982        append out "$x $y $z\n"
    962983    }
    963984    append out "POLYGONS $_numCells $count\n"
     
    9861007            continue
    9871008        }
    988         append data " $numIndices $line\n"
     1009        append data "$numIndices $line\n"
    9891010        incr _numCells
    9901011        set count [expr $count + $numIndices + 1]
     
    9931014    append out "POINTS $_numPoints double\n"
    9941015    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    995         append out " $x $y $z\n"
     1016        append out "$x $y $z\n"
    9961017    }
    9971018    append out "TRIANGLE_STRIPS $_numCells $count\n"
     
    10151036    set celltypes {}
    10161037    foreach { a b c d } $tetras {
    1017         append data " 4 $a $b $c $d\n"
     1038        append data "4 $a $b $c $d\n"
    10181039        append celltypes "10\n"
    10191040        incr _numCells
     
    10221043    append out "POINTS $_numPoints double\n"
    10231044    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    1024         append out " $x $y $z\n"
     1045        append out "$x $y $z\n"
    10251046    }
    10261047    set count [expr $_numCells * 5]
     
    10441065    set celltypes {}
    10451066    foreach { a b c d e f g h } $hexas {
    1046         append data " 8 $a $b $c $d $e $f $g $h\n"
     1067        append data "8 $a $b $c $d $e $f $g $h\n"
    10471068        append celltypes "12\n"
    10481069        incr _numCells
     
    10511072    append out "POINTS $_numPoints double\n"
    10521073    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    1053         append out " $x $y $z\n"
     1074        append out "$x $y $z\n"
    10541075    }
    10551076    set count [expr $_numCells * 9]
     
    10731094    set celltypes {}
    10741095    foreach { a b c d e f } $wedges {
    1075         append data " 6 $a $b $c $d $e $f\n"
     1096        append data "6 $a $b $c $d $e $f\n"
    10761097        append celltypes "13\n"
    10771098        incr _numCells
     
    10801101    append out "POINTS $_numPoints double\n"
    10811102    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    1082         append out " $x $y $z\n"
     1103        append out "$x $y $z\n"
    10831104    }
    10841105    set count [expr $_numCells * 7]
     
    11021123    set celltypes {}
    11031124    foreach { a b c d e } $pyramids {
    1104         append data " 5 $a $b $c $d $e\n"
     1125        append data "5 $a $b $c $d $e\n"
    11051126        append celltypes "14\n"
    11061127        incr _numCells
     
    11091130    append out "POINTS $_numPoints double\n"
    11101131    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    1111         append out " $x $y $z\n"
     1132        append out "$x $y $z\n"
    11121133    }
    11131134    set count [expr $_numCells * 6]
     
    11521173            set numIndices $length
    11531174        }
    1154         append data " $numIndices $line\n"
    1155         lappend celltypesout $celltype
     1175        append data "$numIndices $line\n"
     1176        append celltypesout "$celltype\n"
    11561177        incr count $length;         # Include the indices
    11571178        incr count;                 # and the number of indices
     
    11601181    append out "DATASET UNSTRUCTURED_GRID\n"
    11611182    append out "POINTS $_numPoints double\n"
    1162     set all [blt::vector create \#auto]
    1163     $all merge $xv $yv $zv
    1164     append out [$all range 0 end]
    1165     blt::vector destroy $all
     1183    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     1184        append out "$x $y $z\n"
     1185    }
    11661186    append out "CELLS $_numCells $count\n"
    11671187    append out $data
     
    14371457        }
    14381458        set celltype $node2celltype($numNodes)
    1439         append celltypes "  $celltype\n"
     1459        append celltypes "$celltype\n"
    14401460        if { $celltype == 12 } {
    14411461            # Formerly used voxels instead of hexahedrons. We're converting
     
    14481468            set nodeList $newList
    14491469        }
    1450         append data "  $numNodes $nodeList\n"
     1470        append data "$numNodes $nodeList\n"
    14511471        incr _numCells
    14521472        incr count $numNodes
     
    14621482    append out "CELL_TYPES $_numCells\n"
    14631483    append out $celltypes
    1464     append out "\n"
    14651484    set _vtkdata $out
    14661485    set _isValid 1
  • branches/1.3/gui/scripts/unirect2d.tcl

    r5596 r5638  
    2929    public proc release {obj}
    3030
    31     public method blob {}
    3231    public method dimensions {} {
    3332        return 2
     
    3938    public method label { axis }
    4039    public method limits {axis}
    41     public method mesh {}
    4240    public method numpoints {} {
    4341        return $_numPoints
     
    5048    private method GetSize { obj path varName }
    5149
    52     private variable _axisOrder  "x y"
    5350    private variable _xMax       0
    5451    private variable _xMin       0
     
    126123    GetSize $m "yaxis.numpoints" _yNum
    127124    foreach {key path} {
    128         group   about.group
    129125        label   about.label
    130126        color   about.color
    131127        style   about.style
    132         type    about.type
    133128        xlabel  xaxis.label
    134129        xdesc   xaxis.description
     
    183178
    184179# ----------------------------------------------------------------------
    185 # method blob
    186 #       Returns a Tcl list that represents the Tcl command and data to
    187 #       recreate the uniform rectangular grid on the nanovis server.
    188 # ----------------------------------------------------------------------
    189 itcl::body Rappture::Unirect2d::blob {} {
    190     set data "unirect2d"
    191     lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum
    192     lappend data "ymin" $_yMin "ymax" $_yMax "ynum" $_yNum
    193     return $data
    194 }
    195 
    196 # ----------------------------------------------------------------------
    197 # method mesh
    198 #       Returns a Tcl list that represents the mesh limits and dims.
    199 # ----------------------------------------------------------------------
    200 itcl::body Rappture::Unirect2d::mesh {} {
    201     lappend out $_xMin $_xMax $_xNum $_yMin $_yMax $_yNum
    202     return $out
    203 }
    204 
    205 # ----------------------------------------------------------------------
    206180# method limits <axis>
    207181#       Returns a list {min max} representing the limits for the
  • branches/1.3/gui/scripts/unirect3d.tcl

    r5596 r5638  
    22
    33# ----------------------------------------------------------------------
    4 #  COMPONENT: unirect3d - represents a uniform rectangular 2-D mesh.
     4#  COMPONENT: unirect3d - represents a uniform rectangular 3-D mesh.
    55#
    66#  This object represents one field in an XML description of a device.
     
    2020
    2121itcl::class Rappture::Unirect3d {
    22     constructor {xmlobj field cname {numComponents 1}} {
     22    constructor {xmlobj path} {
    2323        # defined below
    2424    }
     
    2626        # defined below
    2727    }
    28 
    29     public method blob {}
     28    public proc fetch {xmlobj path}
     29    public proc release {obj}
     30
    3031    public method dimensions {} {
    3132        return 3
     
    3738    public method label { axis }
    3839    public method limits {axis}
    39     public method mesh {}
    4040    public method numpoints {} {
    4141        return $_numPoints
    4242    }
    43     public method order {} {
    44         return _axisOrder;
    45     }
    4643    public method units { axis }
    47     public method values {}
    4844    public method vtkdata {{what -partial}} {}
    4945
     
    5248    private method GetSize { obj path varName }
    5349
    54     private variable _axisOrder  "x y z"
    5550    private variable _xMax       0
    5651    private variable _xMin       0
     
    6257    private variable _zMin       0
    6358    private variable _zNum       0;     # Number of points along z-axis
    64     private variable _compNum    1;     # Number of components in values
    65     private variable _values     "";    # BLT vector containing the values
    6659    private variable _hints
    6760    private variable _vtkdata    ""
    6861    private variable _numPoints  0
    6962    private variable _isValid    0;     # Indicates if the data is valid.
     63
     64    private common _xp2obj       ;      # used for fetch/release ref counting
     65    private common _obj2ref      ;      # used for fetch/release ref counting
     66}
     67
     68#
     69# fetch <xmlobj> <path>
     70#
     71#    Clients use this instead of a constructor to fetch the Mesh for a
     72#    particular <path> in the <xmlobj>.  When the client is done with the mesh,
     73#    he calls "release" to decrement the reference count.  When the mesh is no
     74#    longer needed, it is cleaned up automatically.
     75#
     76itcl::body Rappture::Unirect3d::fetch {xmlobj path} {
     77    set handle "$xmlobj|$path"
     78    if {[info exists _xp2obj($handle)]} {
     79        set obj $_xp2obj($handle)
     80        incr _obj2ref($obj)
     81        return $obj
     82    }
     83    set obj [Rappture::Unirect3d ::#auto $xmlobj $path]
     84    set _xp2obj($handle) $obj
     85    set _obj2ref($obj) 1
     86    return $obj
     87}
     88
     89# ----------------------------------------------------------------------
     90# USAGE: Rappture::Unirect3d::release <obj>
     91#
     92# Clients call this when they're no longer using a Mesh fetched
     93# previously by the "fetch" proc.  This decrements the reference
     94# count for the mesh and destroys the object when it is no longer
     95# in use.
     96# ----------------------------------------------------------------------
     97itcl::body Rappture::Unirect3d::release { obj } {
     98    if { ![info exists _obj2ref($obj)] } {
     99        error "can't find reference count for $obj"
     100    }
     101    incr _obj2ref($obj) -1
     102    if {$_obj2ref($obj) <= 0} {
     103        unset _obj2ref($obj)
     104        foreach handle [array names _xp2obj] {
     105            if {$_xp2obj($handle) == $obj} {
     106                unset _xp2obj($handle)
     107            }
     108        }
     109        itcl::delete object $obj
     110    }
    70111}
    71112
     
    73114# Constructor
    74115# ----------------------------------------------------------------------
    75 itcl::body Rappture::Unirect3d::constructor {xmlobj field cname {numComponents 1}} {
     116itcl::body Rappture::Unirect3d::constructor {xmlobj path} {
    76117    if {![Rappture::library isvalid $xmlobj]} {
    77118        error "bad value \"$xmlobj\": should be Rappture::library"
    78119    }
    79     set path [$field get $cname.mesh]
    80120    set m [$xmlobj element -as object $path]
    81121    GetValue $m "xaxis.min" _xMin
     
    88128    GetSize $m "yaxis.numpoints" _yNum
    89129    GetSize $m "zaxis.numpoints" _zNum
    90     set _compNum $numComponents
    91130    foreach {key path} {
    92         group   about.group
    93131        label   about.label
    94132        color   about.color
    95133        style   about.style
    96         type    about.type
    97134        xlabel  xaxis.label
    98135        xdesc   xaxis.description
     
    113150        zmin    zaxis.min
    114151        zmax    zaxis.max
    115         order   about.axisorder
    116152    } {
    117153        set str [$m get $path]
    118         if {"" != $str} {
    119             set _hints($key) $str
    120         }
    121     }
    122     foreach {key} { axisorder } {
    123         set str [$field get $cname.$key]
    124154        if {"" != $str} {
    125155            set _hints($key) $str
     
    131161        set _vtkdata ""
    132162        return
    133     }
    134     set _values [blt::vector create #auto]
    135     $_values set [$field get "$cname.values"]
    136     set n [expr $_numPoints * $_compNum]
    137     if { [$_values length] != $n } {
    138         error "wrong \# of values in \"$cname.values\": expected $n values, got [$_values length]"
    139163    }
    140164    append out "DATASET STRUCTURED_POINTS\n"
     
    166190# ----------------------------------------------------------------------
    167191itcl::body Rappture::Unirect3d::destructor {} {
    168     if { $_values != "" } {
    169         blt::vector destroy $_values
    170     }
    171 }
    172 
    173 # ----------------------------------------------------------------------
    174 # method blob
    175 #       Returns a Tcl list that represents the Tcl command and data to
    176 #       recreate the uniform rectangular grid on the nanovis server.
    177 # ----------------------------------------------------------------------
    178 itcl::body Rappture::Unirect3d::blob {} {
    179     set data "unirect3d"
    180     lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum
    181     lappend data "ymin" $_yMin "ymax" $_yMax "ynum" $_yNum
    182     lappend data "zmin" $_zMin "zmax" $_zMax "znum" $_zNum
    183     lappend data "axisorder" $_axisOrder
    184     if { [$_values length] > 0 } {
    185         lappend data "values" [$_values range 0 end]
    186     }
    187     return $data
    188 }
    189 
    190 # ----------------------------------------------------------------------
    191 # method mesh
    192 #       Returns a Tcl list that represents the points of the uniform
    193 #       grid.  Each point has x,y and z values in the list.
    194 # ----------------------------------------------------------------------
    195 itcl::body Rappture::Unirect3d::mesh {} {
    196     set dx [expr {($_xMax - $_xMin) / double($_xNum - 1)}]
    197     set dy [expr {($_yMax - $_yMin) / double($_yNum - 1)}]
    198     set dz [expr {($_zMax - $_zMin) / double($_zNum - 1)}]
    199     foreach {a b c} $_axisOrder break
    200     for { set i 0 } { $i < [set _${a}Num] } { incr i } {
    201         set v1 [expr {[set _${a}Min] + (double($i) * [set d${a}])}]
    202         for { set j 0 } { $j < [set _${b}Num] } { incr j } {
    203             set v2 [expr {[set _${b}Min] + (double($i) * [set d${b}])}]
    204             for { set k 0 } { $k < [set _${c}Num] } { incr k } {
    205                 set v3 [expr {[set _${c}Min] + (double($i) * [set d${c}])}]
    206                 lappend data $v1 $v2 $v3
    207             }
    208         }
    209     }
    210     return $data
    211 }
    212 
    213 # ----------------------------------------------------------------------
    214 # method values
    215 #       Returns a BLT vector that represents the field values
    216 # ----------------------------------------------------------------------
    217 itcl::body Rappture::Unirect3d::values {} {
    218     return $_values
     192    # empty
    219193}
    220194
     
    241215            set max $_zMax
    242216        }
    243         v - vlin - vlog {
    244             if { [$_values length] > 0 } {
    245                set min [blt::vector expr min($_values)]
    246                set max [blt::vector expr max($_values)]
    247             } else {
    248                 set min 0.0
    249                 set max 1.0
    250             }
    251         }
    252217        default {
    253218            error "unknown axis description \"$which\""
     
    301266        set _hints(ylabel) "$_hints(zlabel) ($_hints(zunits))"
    302267    }
    303 
    304268    if {[info exists _hints(group)] && [info exists _hints(label)]} {
    305269        # pop-up help for each curve
Note: See TracChangeset for help on using the changeset viewer.