Ignore:
Timestamp:
Jun 9, 2015 1:55:08 PM (9 years ago)
Author:
ldelgass
Message:

Full merge 1.3 branch to uq branch to sync. Fixed partial subdirectory merge
by removing mergeinfo from lang/python/Rappture directory.

Location:
branches/uq
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/uq

  • branches/uq/gui/scripts/field.tcl

    r5121 r5679  
    2121# Possible field dataset types:
    2222#
     23# 1D Datasets
     24#       1D              A field contained in a structure
    2325# 2D Datasets
    24 #       vtk             (range of z-axis is zero).
    25 #       unirect2d       (deprecated)
    26 #       cloud           (x,y point coordinates) (deprecated)
    27 #       mesh
     26#       vtk             (range of z-axis is zero).
     27#       unirect2d       (deprecated)
     28#       cloud           (x,y point coordinates) (deprecated)
     29#       mesh
    2830# 3D Datasets
    29 #       vtk
    30 #       unirect3d       (deprecated)
    31 #       cloud           (x,y,z coordinates) (deprecated)
    32 #       mesh
    33 #       dx              (FIXME: make dx-to-vtk converter work)
    34 #       ucd avs
     31#       vtk
     32#       unirect3d       (deprecated)
     33#       cloud           (x,y,z coordinates) (deprecated)
     34#       mesh
     35#       dx              (FIXME: make dx-to-vtk converter work)
     36#       ucd             (AVS ucd format)
    3537#
    3638# Viewers:
    37 #       Format     Dim  Description                     Viewer          Server
    38 #       vtk         2   vtk file data.                  contour         vtkvis
    39 #       vtk         3   vtk file data.                  isosurface      vtkvis
    40 #       mesh        2   points-on-mesh                  heightmap       vtkvis
    41 #       mesh        3   points-on-mesh                  isosurface      vtkvis
    42 #       dx          3   DX                              volume          nanovis
    43 #       unirect2d   2   unirect2d + extents > 1 flow    flow            nanovis
    44 #       unirect3d   3   unirect3d + extents > 1 flow    flow            nanovis
     39#       Format     Dim  Description                   Viewer          Server
     40#       1D          1   structure field               DeviceViewer1D  N/A
     41#       vtk         2   vtk file data.                contour         vtkvis
     42#       vtk         3   vtk file data.                isosurface      vtkvis
     43#       mesh        2   points-on-mesh                heightmap       vtkvis
     44#       mesh        3   points-on-mesh                isosurface      vtkvis
     45#       dx          3   DX                            volume          nanovis
     46#       unirect2d   2   unirect2d + extents > 1 flow  flow            nanovis
     47#       unirect3d   3   unirect3d + extents > 1 flow  flow            nanovis
    4548#
    4649# With <views>, can specify which viewer for specific datasets.  So it's OK
     
    6467
    6568itcl::class Rappture::Field {
    66     protected variable _dim 0;          # Dimension of the mesh
    67     private variable _xmlobj "";        # ref to XML obj with field data
    68     private variable _limits;           # maps axis name => {z0 z1} limits
    69     private variable _field ""
    70     private variable _comp2fldName ;    # cname => field names.
    71     private variable _comp2type ;       # cname => type (e.g. "vectors")
    72     private variable _comp2size ;       # cname => # of components in element
    73     private variable _comp2assoc;       # cname => association (e.g. pointdata)
    74     private variable _fld2Components;   # field name => number of components
    75     private variable _fld2Label;        # field name => label
    76     private variable _fld2Units;        # field name => units
    77     private variable _hints
    78     private variable _viewer "";        # Hints which viewer to use
    79     private variable _xv "";            # For 1D meshes only.  Holds the points
    80     private variable _isValid 0;        # Indicates if the field contains
    81                                         # valid data.
    82     private variable _isValidComponent; #  Array of valid components found
    83     private variable _alwaysConvertDX 0;
    84 
    8569    constructor {xmlobj path} {
    8670        # defined below
     
    9276    public method components {args}
    9377    public method controls {option args}
    94     public method extents {{cname -overall}}
    95     public method numComponents {cname}
    96     public method fieldlimits {}
    97     public method valueLimits { cname }
    98     public method flowhints { cname }
    99     public method hints {{key ""}}
    100     public method isunirect2d {}
    101     public method isunirect3d {}
    102     public method limits {axis}
    103     public method mesh {{cname -overall}}
    104     public method style { cname }
    105     public method type {}
    106     public method values { cname }
    107     public method vtkdata {cname}
    108     public method xErrorValues { cname } {
    109     }
    110     public method yErrorValues { cname } {
    111     }
    112 
    113     public method fieldnames { cname } {
    114         if { ![info exists _comp2fldName($cname)] } {
    115             return ""
    116         }
    117         return $_comp2fldName($cname)
    118     }
    11978    public method fieldinfo { fname } {
    12079        lappend out $_fld2Label($fname)
     
    12382        return $out
    12483    }
     84    public method fieldlimits {}
     85    public method fieldnames { cname } {
     86        if { ![info exists _comp2fldName($cname)] } {
     87            return ""
     88        }
     89        return $_comp2fldName($cname)
     90    }
     91    public method flowhints { cname }
     92    public method hints {{key ""}}
    12593    public method isvalid {} {
    12694        return $_isValid
    12795    }
     96    public method limits {axis}
     97    public method mesh {{cname -overall}}
     98    public method numComponents {cname}
     99    public method style { cname }
     100    public method type {}
     101    public method valueLimits { cname }
     102    public method values { cname }
    128103    public method viewer {} {
    129104        return $_viewer
    130105    }
     106    public method vtkdata {cname}
     107    public method xErrorValues { cname } {
     108    }
     109    public method yErrorValues { cname } {
     110    }
     111
    131112    protected method Build {}
    132113    protected method _getValue {expr}
    133 
    134     private variable _path "";          # Path of this object in the XML
    135     private variable _units ""   ;      # system of units for this field
    136     private variable _zmax 0     ;# length of the device
    137 
    138     private variable _comp2dims  ;# maps component name => dimensionality
    139     private variable _comp2xy    ;# maps component name => x,y vectors
    140     private variable _comp2vtk   ;# maps component name => vtk file data
    141     private variable _comp2dx    ;# maps component name => OpenDX data
    142     private variable _comp2unirect2d ;# maps component name => unirect2d obj
    143     private variable _comp2unirect3d ;# maps component name => unirect3d obj
    144     private variable _comp2style ;# maps component name => style settings
    145     private variable _comp2cntls ;# maps component name => x,y control points
    146     private variable _comp2extents
    147     private variable _comp2limits;        #  Array of limits per component
    148     private variable _type ""
    149     private variable _comp2flowhints
    150     private variable _comp2mesh
    151     private common _counter 0    ;# counter for unique vector names
     114    protected method GetAssociation { cname }
     115    protected method GetTypeAndSize { cname }
     116    protected method ReadVtkDataSet { cname contents }
    152117
    153118    private method AvsToVtk { cname contents }
    154119    private method DicomToVtk { cname contents }
    155120    private method BuildPointsOnMesh { cname }
    156     protected method GetAssociation { cname }
    157     protected method GetTypeAndSize { cname }
    158     protected method ReadVtkDataSet { cname contents }
    159121    private method InitHints {}
    160 
    161122    private method VerifyVtkDataSet { contents }
    162123    private method VectorLimits { vector vectorsize {comp -1} }
    163     private variable _values ""
     124    private method VtkDataSetToXy { dataset }
     125
     126    protected variable _dim 0;          # Dimension of the mesh
     127
     128    private variable _xmlobj "";        # ref to XML obj with field data
     129    private variable _path "";          # Path of this object in the XML
     130    private variable _field "";         # This field element as XML obj
     131
     132    private variable _type "";          # Field type: e.g. file type
     133    private variable _hints;            # Hints array
     134    private variable _limits;           # maps axis name => {z0 z1} limits
     135    private variable _units "";         # system of units for this field
     136    private variable _viewer "";        # Hints which viewer to use
     137    private variable _isValid 0;        # Indicates if the field contains
     138                                        # valid data.
     139    private variable _isValidComponent; # Array of valid components found
     140    private variable _zmax 0;           # length of the device (1D only)
     141
     142    private variable _fld2Components;   # field name => number of components
     143    private variable _fld2Label;        # field name => label
     144    private variable _fld2Units;        # field name => units
     145
     146    private variable _comp2fldName;     # cname => field names.
     147    private variable _comp2type;        # cname => type (e.g. "vectors")
     148    private variable _comp2size;        # cname => # of components in element
     149    private variable _comp2assoc;       # cname => association (e.g. pointdata)
     150    private variable _comp2dims;        # cname => dimensionality
     151    private variable _comp2xy;          # cname => x,y vectors
     152    private variable _comp2vtk;         # cname => vtk file data
     153    private variable _comp2dx;          # cname => OpenDX data
     154    private variable _comp2style;       # cname => style settings
     155    private variable _comp2cntls;       # cname => x,y control points (1D only)
     156    private variable _comp2limits;      # cname => List of axis, min/max list
     157    private variable _comp2flowhints;   # cname => Rappture::FlowHints obj
     158    private variable _comp2mesh;        # list: mesh obj, BLT vector of values
     159                                        # valid for cloud,mesh,unirect2d
     160    private common _alwaysConvertDX 0;  # If set, convert DX and store as VTK,
     161                                        # even if viewer is nanovis/flowvis
     162    private common _counter 0;          # counter for unique vector names
    164163}
    165164
     
    218217    foreach name [array names _comp2xy] {
    219218        eval blt::vector destroy $_comp2xy($name)
    220     }
    221     foreach name [array names _comp2unirect2d] {
    222         itcl::delete object $_comp2unirect2d($name)
    223     }
    224     foreach name [array names _comp2unirect3d] {
    225         itcl::delete object $_comp2unirect3d($name)
    226219    }
    227220    foreach name [array names _comp2flowhints] {
     
    302295# USAGE: mesh ?<name>?
    303296#
    304 # Returns a list {xvec yvec} for the specified field component <name>.
    305 # If the name is not specified, then it returns the vectors for the
    306 # overall field (sum of all components).
     297# For 1D data (curve), returns a BLT vector of x values for the field
     298# component <name>.  Otherwise, this method is unused.
    307299# ----------------------------------------------------------------------
    308300itcl::body Rappture::Field::mesh {{cname -overall}} {
     
    313305        return [lindex $_comp2xy($cname) 0]  ;# return xv
    314306    }
    315     if { [info exists _comp2vtk($cname)] } {
    316         # FIXME: extract mesh from VTK file data.
    317         if { $_comp2dims($cname) == "1D" } {
    318             return $_xv
    319         }
     307    if {[info exists _comp2vtk($cname)]} {
    320308        error "method \"mesh\" is not implemented for VTK file data"
    321309    }
    322310    if {[info exists _comp2dx($cname)]} {
    323         return ""  ;# no mesh -- it's embedded in the blob data
     311        error "method \"mesh\" is not implemented for DX file data"
    324312    }
    325313    if {[info exists _comp2mesh($cname)]} {
    326         return ""  ;# no mesh -- it's embedded in the value data
    327     }
    328     if {[info exists _comp2unirect2d($cname)]} {
    329         set mobj [lindex $_comp2unirect2d($cname) 0]
    330         return [$mobj mesh]
    331     }
    332     if {[info exists _comp2unirect3d($cname)]} {
    333         set mobj [lindex $_comp2unirect3d($cname) 0]
    334         return [$mobj mesh]
     314        error "method \"mesh\" is not implemented for Rappture::Mesh"
    335315    }
    336316    error "can't get field mesh: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
     
    340320# USAGE: values ?<name>?
    341321#
    342 # Returns a list {xvec yvec} for the specified field component <name>.
    343 # If the name is not specified, then it returns the vectors for the
    344 # overall field (sum of all components).
     322# For 1D data (curve), returns a BLT vector of field values (y coords)
     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     # VTK file data
    354     if { [info exists _comp2vtk($cname)] } {
    355         # FIXME: extract the values from the VTK file data
    356         if { $_comp2dims($cname) == "1D" } {
    357             return $_values
    358         }
    359         error "method \"values\" is not implemented for vtk file data"
    360     }
    361     # Points-on-mesh
    362     if { [info exists _comp2mesh($cname)] } {
    363         set vector [lindex $_comp2mesh($cname) 1]
    364         return [$vector range 0 end]
     334    if {[info exists _comp2vtk($cname)]} {
     335        error "method \"values\" is not implemented for VTK file data"
    365336    }
    366337    if {[info exists _comp2dx($cname)]} {
    367         error "method \"values\" is not implemented for dx file data"
    368     }
    369     if {[info exists _comp2unirect2d($cname)]} {
    370         return $_values
    371     }
    372     if {[info exists _comp2unirect3d($cname)]} {
    373         return [$_comp2unirect3d($cname) blob]
    374     }
    375     error "can't get field values. Unknown component \"$cname\": should be [join [lsort [array names _comp2dims]] {, }]"
     338        error "method \"values\" is not implemented for DX file data"
     339    }
     340    if {[info exists _comp2mesh($cname)]} {
     341        return [lindex $_comp2mesh($cname) 1] ;# return vector
     342    }
     343    error "can't get field values. Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
    376344}
    377345
     
    385353        set cname "component"
    386354    }
    387     if {[info exists _comp2xy($cname)]} {
    388         return ""
    389     }
    390     if { [info exists _comp2vtk($cname)] } {
    391         error "blob not implemented for VTK file data"
    392     }
    393355    if {[info exists _comp2dx($cname)]} {
    394356        return $_comp2dx($cname)  ;# return gzipped, base64-encoded DX data
    395357    }
    396     if {[info exists _comp2unirect2d($cname)]} {
    397         set blob [$_comp2unirect2d($cname) blob]
    398         lappend blob "values" $_values
    399         return $blob
    400     }
    401     if {[info exists _comp2unirect3d($cname)]} {
    402         return [$_comp2unirect3d($cname) blob]
     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"
     363    }
     364    if {[info exists _comp2xy($cname)]} {
     365        error "method \"blob\" not implemented for XY data"
    403366    }
    404367    error "can't get field blob: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
     
    422385#
    423386# Returns a list {min max} representing the limits for the specified
    424 # axis.
     387# axis over all components.
    425388# ----------------------------------------------------------------------
    426389itcl::body Rappture::Field::limits {which} {
     
    540503# USAGE: fieldlimits
    541504#
    542 # Returns a list {min max} representing the limits for the specified
    543 # axis.
     505# This method is for use with VTK components that have multiple fields.
     506# It really makes no sense to have multiple fields in a field, but this
     507# is here until we add a proper dataset object to hold multiple fields.
     508#
     509# Returns an array mapping fieldname => list {min max} representing the
     510# limits over all components for the given fieldname.  This assumes that
     511# all components have the same set of fields.
    544512# ----------------------------------------------------------------------
    545513itcl::body Rappture::Field::fieldlimits {} {
     
    757725    }
    758726    array unset _comp2vtk
    759     foreach name [array names _comp2unirect2d] {
    760         eval itcl::delete object $_comp2unirect2d($name)
    761     }
    762     foreach name [array names _comp2unirect3d] {
    763         eval itcl::delete object $_comp2unirect3d($name)
    764     }
    765727    catch {unset _comp2xy}
    766728    catch {unset _comp2dx}
    767729    catch {unset _comp2dims}
    768730    catch {unset _comp2style}
    769     array unset _comp2unirect2d
    770     array unset _comp2unirect3d
    771     array unset _comp2extents
    772731    array unset _dataobj2type
    773732    #
     
    787746        } elseif { [$_field element $cname.vtk] != ""} {
    788747            set type "vtk"
    789             set viewer [$_field get "about.view"]
    790             if { $viewer != "" } {
    791                 set _viewer $viewer
    792             }
    793748        } elseif {[$_field element $cname.opendx] != ""} {
    794             global env
    795             if { [info exists env(VTKVOLUME)] } {
    796                 set _viewer "vtkvolume"
    797             }
    798749            set type "opendx"
    799750        } elseif {[$_field element $cname.dx] != ""} {
    800             global env
    801             if { [info exists env(VTKVOLUME)] } {
    802                 set _viewer "vtkvolume"
    803             }
    804751            set type "dx"
    805752        } elseif {[$_field element $cname.ucd] != ""} {
     
    813760            continue
    814761        }
    815         # Save the extents of the component
    816         if { [$_field element $cname.extents] != "" } {
    817             set extents [$_field get $cname.extents]
    818         } else {
    819             set extents 1
    820         }
    821         set _comp2extents($cname) $extents
    822762        set _type $type
    823763
    824764        GetTypeAndSize $cname
    825765        GetAssociation $cname
    826         if { $_comp2size($cname) > 1 } {
    827             set viewer [$_field get "about.view"]
    828             if { $viewer == "" } {
     766
     767        if { $_comp2size($cname) < 1 ||
     768             $_comp2size($cname) > 9 } {
     769            puts stderr "ERROR: Invalid <elemsize>: $_comp2size($cname)"
     770            continue
     771        }
     772        # Some types have restrictions on number of components
     773        if { $_comp2type($cname) == "vectors" &&
     774             $_comp2size($cname) != 3 } {
     775            puts stderr "ERROR: vectors <elemtype> must have <elemsize> of 3"
     776            continue
     777        }
     778        if { $_comp2type($cname) == "normals" &&
     779             $_comp2size($cname) != 3 } {
     780            puts stderr "ERROR: normals <elemtype> must have <elemsize> of 3"
     781            continue
     782        }
     783        if { $_comp2type($cname) == "tcoords" &&
     784             $_comp2size($cname) > 3 } {
     785            puts stderr "ERROR: tcoords <elemtype> must have <elemsize> <= 3"
     786            continue
     787        }
     788        if { $_comp2type($cname) == "scalars" &&
     789             $_comp2size($cname) > 4 } {
     790            puts stderr "ERROR: scalars <elemtype> must have <elemsize> <= 4"
     791            continue
     792        }
     793        if { $_comp2type($cname) == "colorscalars" &&
     794             $_comp2size($cname) > 4 } {
     795            puts stderr "ERROR: colorscalars <elemtype> must have <elemsize> <= 4"
     796            continue
     797        }
     798        if { $_comp2type($cname) == "tensors" &&
     799             $_comp2size($cname) != 9 } {
     800            puts stderr "ERROR: tensors <elemtype> must have <elemsize> of 9"
     801            continue
     802        }
     803
     804        if { [$_field element $cname.flow] != "" } {
     805            set haveFlow 1
     806        } else {
     807            set haveFlow 0
     808        }
     809        set viewer [$_field get "about.view"]
     810        if { $viewer != "" } {
     811            set _viewer $viewer
     812        }
     813        if { $_viewer == "" } {
     814            if { $_comp2size($cname) > 1 && ! $haveFlow } {
    829815                set _viewer "glyphs"
    830             }
    831         }
     816            } elseif { $_comp2size($cname) > 1 && $haveFlow } {
     817                set _viewer "flowvis"
     818            }
     819        }
     820
    832821        if {$type == "1D"} {
    833822            #
     
    895884        } elseif {$type == "dx" || $type == "opendx" } {
    896885            #
    897             # HACK ALERT!  Extract gzipped, base64-encoded OpenDX
    898             # data.  Assume that it's 3D.  Pass it straight
    899             # off to the NanoVis visualizer.
     886            # Extract gzipped, base64-encoded OpenDX data
    900887            #
    901             set viewer [$_field get "about.view"]
    902             if { $viewer != "" } {
    903                 set _viewer $viewer
    904             }
    905888            if { $_viewer == "" } {
    906                 if {[$_field element $cname.flow] != ""} {
     889                if {$haveFlow} {
    907890                    set _viewer "flowvis"
    908891                } else {
     892                    global env
     893                    if { [info exists env(VTKVOLUME)] } {
     894                        set _viewer "vtkvolume"
     895                    }
    909896                    set _viewer "nanovis"
    910897                }
    911898            }
    912             set _dim 3
    913             set _comp2dims($cname) "3D"
    914899            set data [$_field get -decode no $cname.$type]
    915900            set contents [Rappture::encoding::decode -as zb64 $data]
     
    923908                close $f
    924909            }
     910            # Convert to VTK
    925911            if { [catch { Rappture::DxToVtk $contents } vtkdata] == 0 } {
     912                unset contents
     913                # Read back VTK: this will set the field limits and the mesh
     914                # dimensions based on the bounds (sets _dim).  We rely on this
     915                # conversion for limits even if we send DX data to nanovis.
    926916                ReadVtkDataSet $cname $vtkdata
    927917                if 0 {
     
    931921                }
    932922            } else {
    933                 puts stderr "Can't parse dx data: $vtkdata"
     923                unset contents
     924                # vtkdata variable holds error message
     925                puts stderr "Can't parse DX data\n$vtkdata"
     926                continue;               # Ignore this component
    934927            }
    935928            if { $_alwaysConvertDX ||
     
    941934                set _comp2dx($cname) $data
    942935            }
     936            unset data
     937            unset vtkdata
    943938            set _comp2style($cname) [$_field get $cname.style]
    944             if {[$_field element $cname.flow] != ""} {
     939            if {$haveFlow} {
    945940                set _comp2flowhints($cname) \
    946941                    [Rappture::FlowHints ::\#auto $_field $cname $_units]
     
    951946            if { $contents == "" } {
    952947                continue;               # Ignore this component
    953             }
    954             set viewer [$_field get "about.view"]
    955             if { $viewer != "" } {
    956                 set _viewer $viewer
    957948            }
    958949            set vtkdata [DicomToVtk $cname $contents]
     
    10681059
    10691060#
    1070 # isunirect2d  --
    1071 #
    1072 # Returns if the field is a unirect2d object.
    1073 #
    1074 itcl::body Rappture::Field::isunirect2d { } {
    1075     return [expr [array size _comp2unirect2d] > 0]
    1076 }
    1077 
    1078 #
    1079 # isunirect3d  --
    1080 #
    1081 # Returns if the field is a unirect3d object.
    1082 #
    1083 itcl::body Rappture::Field::isunirect3d { } {
    1084     return [expr [array size _comp2unirect3d] > 0]
    1085 }
    1086 
    1087 #
    10881061# flowhints  --
    10891062#
     
    11141087# Returns the data storage type of the field.
    11151088#
    1116 # FIXME: What are the valid types?
     1089# Types:
     1090#   1D,cloud,dicom,dx,mesh,ucd,unirect2d,unirect3d,vtk
    11171091#
    11181092itcl::body Rappture::Field::type {} {
     
    11321106    }
    11331107    return 1;                           # Default to scalar.
    1134 }
    1135 
    1136 #
    1137 # extents --
    1138 #
    1139 # Returns if the field is a unirect2d object.
    1140 #
    1141 itcl::body Rappture::Field::extents {{cname -overall}} {
    1142     if {$cname == "-overall" } {
    1143         set max 0
    1144         foreach cname [$_field children -type component] {
    1145             if { ![info exists _comp2unirect3d($cname)] &&
    1146                  ![info exists _comp2extents($cname)] } {
    1147                 continue
    1148             }
    1149             set value $_comp2extents($cname)
    1150             if { $max < $value } {
    1151                 set max $value
    1152             }
    1153         }
    1154         return $max
    1155     }
    1156     if { $cname == "component0"} {
    1157         set cname [lindex [components -name] 0]
    1158     }
    1159     return $_comp2extents($cname)
    11601108}
    11611109
     
    12401188    }
    12411189    set _comp2dims($cname) ${_dim}D
    1242     if { $_dim < 2 } {
    1243         set numPoints [$dataset GetNumberOfPoints]
    1244         set xv [blt::vector create \#auto]
    1245         for { set i 0 } { $i < $numPoints } { incr i } {
    1246             set point [$dataset GetPoint $i]
    1247             $xv append [lindex $point 0]
    1248         }
    1249         set yv [blt::vector create \#auto]
    1250         set dataAttrs [$dataset GetPointData]
    1251         if { $dataAttrs == ""} {
    1252             puts stderr "WARNING: No point data found in \"$_path\""
    1253             rename $reader ""
    1254             return 0
    1255         }
    1256         set array [$dataAttrs GetScalars]
    1257         if { $array == ""} {
    1258             puts stderr "WARNING: No scalar point data found in \"$_path\""
    1259             rename $reader ""
    1260             return 0
    1261         }
    1262         set numTuples [$array GetNumberOfTuples]
    1263         for { set i 0 } { $i < $numTuples } { incr i } {
    1264             $yv append [$array GetComponent $i 0]
    1265         }
    1266         $xv sort $yv
    1267         set _comp2xy($cname) [list $xv $yv]
    1268     }
    12691190    lappend limits x [list $xmin $xmax]
    12701191    lappend limits y [list $ymin $ymax]
     
    13041225
    13051226#
     1227# VtkDataSetToXy --
     1228#
     1229#        Attempt to convert 0 or 1 dimensional VTK DataSet to XY data (curve).
     1230#
     1231itcl::body Rappture::Field::VtkDataSetToXy { dataset } {
     1232    foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break
     1233    # Only X can have non-zero range.  X can have zero range if there is
     1234    # only one point
     1235    if { $ymax > $ymin } {
     1236        return 0
     1237    }
     1238    if { $zmax > $zmin } {
     1239        return 0
     1240    }
     1241    set numPoints [$dataset GetNumberOfPoints]
     1242    set dataAttrs [$dataset GetPointData]
     1243    if { $dataAttrs == ""} {
     1244        puts stderr "WARNING: No point data found"
     1245        return 0
     1246    }
     1247    set array [$dataAttrs GetScalars]
     1248    if { $array == ""} {
     1249        puts stderr "WARNING: No scalar point data found"
     1250        return 0
     1251    }
     1252    # Multi-component scalars (e.g. color scalars) are not supported
     1253    if { [$array GetNumberOfComponents] != 1 } {
     1254        return 0
     1255    }
     1256    set numTuples [$array GetNumberOfTuples]
     1257    set xv [blt::vector create \#auto]
     1258    for { set i 0 } { $i < $numPoints } { incr i } {
     1259        set point [$dataset GetPoint $i]
     1260        $xv append [lindex $point 0]
     1261    }
     1262    set yv [blt::vector create \#auto]
     1263    for { set i 0 } { $i < $numTuples } { incr i } {
     1264        $yv append [$array GetComponent $i 0]
     1265    }
     1266    $xv sort $yv
     1267    set _comp2xy($cname) [list $xv $yv]
     1268    return 1
     1269}
     1270
     1271#
    13061272# vtkdata --
    13071273#
     
    13131279        set cname "component"
    13141280    }
     1281    # VTK file data:
     1282    if { [info exists _comp2vtk($cname)] } {
     1283        return $_comp2vtk($cname)
     1284    }
    13151285    # DX: Convert DX to VTK
    13161286    if {[info exists _comp2dx($cname)]} {
    13171287        set data $_comp2dx($cname)
    1318         set data [Rappture::encoding::decode $data]
     1288        set data [Rappture::encoding::decode -as zb64 $data]
    13191289        return [Rappture::DxToVtk $data]
    1320     }
    1321     # Unirect3d: isosurface
    1322     if {[info exists _comp2unirect3d($cname)]} {
    1323         return [$_comp2unirect3d($cname) vtkdata]
    1324     }
    1325     # VTK file data:
    1326     if { [info exists _comp2vtk($cname)] } {
    1327         return $_comp2vtk($cname)
    13281290    }
    13291291    # Points on mesh:  Construct VTK file output.
     
    13841346        return $out
    13851347    }
    1386     error "can't find vtkdata for $cname. This method should only be called by the vtkheightmap widget"
     1348    error "can't find vtkdata for $cname"
    13871349}
    13881350
     
    14021364    if {[$_xmlobj element $path] == ""} {
    14031365        # Unknown mesh designated.
     1366        puts stderr "ERROR: Unknown mesh \"$path\""
    14041367        return 0
    1405     }
    1406     set viewer [$_field get "about.view"]
    1407     if { $viewer != "" } {
    1408         set _viewer $viewer
    14091368    }
    14101369    set element [$_xmlobj element -as type $path]
     
    14201379    lappend _comp2fldName($cname) $name
    14211380
    1422     # Handle bizarre cases that hopefully will be deprecated.
    1423     if { $element == "unirect3d" } {
    1424         # Special case: unirect3d (should be deprecated) + flow.
    1425         if { [$_field element $cname.extents] != "" } {
    1426             set vectorsize [$_field get $cname.extents]
    1427         } else {
    1428             set vectorsize 1
    1429         }
    1430         set _type unirect3d
    1431         set _dim 3
    1432         if { $_viewer == "" } {
    1433             set _viewer flowvis
    1434         }
    1435         set _comp2dims($cname) "3D"
    1436         set _comp2unirect3d($cname) \
    1437             [Rappture::Unirect3d \#auto $_xmlobj $_field $cname $vectorsize]
    1438         set _comp2style($cname) [$_field get $cname.style]
    1439         set limits {}
    1440         foreach axis { x y z } {
    1441             lappend limits $axis [$_comp2unirect3d($cname) limits $axis]
    1442         }
    1443         # Get the data limits
    1444         set vector [$_comp2unirect3d($cname) valuesObj]
    1445         set minmax [VectorLimits $vector $vectorsize]
    1446         lappend limits $cname $minmax
    1447         lappend limits v      $minmax
    1448         set _comp2limits($cname) $limits
    1449         if {[$_field element $cname.flow] != ""} {
    1450             set _comp2flowhints($cname) \
    1451                 [Rappture::FlowHints ::\#auto $_field $cname $_units]
    1452         }
    1453         incr _counter
    1454         return 1
    1455     }
    1456     if { $element == "unirect2d" && [$_field element $cname.flow] != "" } {
    1457         # Special case: unirect2d (normally deprecated) + flow.
    1458         if { [$_field element $cname.extents] != "" } {
    1459             set vectorsize [$_field get $cname.extents]
    1460         } else {
    1461             set vectorsize 1
    1462         }
    1463         set _type unirect2d
    1464         set _dim 2
    1465         if { $_viewer == "" } {
    1466             set _viewer "flowvis"
    1467         }
    1468         set _comp2dims($cname) "2D"
    1469         set _comp2unirect2d($cname) \
    1470             [Rappture::Unirect2d \#auto $_xmlobj $path]
    1471         set _comp2style($cname) [$_field get $cname.style]
    1472         set _comp2flowhints($cname) \
    1473             [Rappture::FlowHints ::\#auto $_field $cname $_units]
    1474         set _values [$_field get $cname.values]
    1475         set limits {}
    1476         foreach axis { x y z } {
    1477             lappend limits $axis [$_comp2unirect2d($cname) limits $axis]
    1478         }
    1479         set xv [blt::vector create \#auto]
    1480         $xv set $_values
    1481         set minmax [VectorLimits $xv $vectorsize]
    1482         lappend limits $cname $minmax
    1483         lappend limits v $minmax
    1484         blt::vector destroy $xv
    1485         set _comp2limits($cname) $limits
    1486         incr _counter
    1487         return 1
    1488     }
    14891381    switch -- $element {
    14901382        "cloud" {
     
    15021394            set mesh [Rappture::Unirect2d::fetch $_xmlobj $path]
    15031395            set _type unirect2d
     1396        }
     1397        "unirect3d" {
     1398            set mesh [Rappture::Unirect3d::fetch $_xmlobj $path]
     1399            set _type unirect3d
    15041400        }
    15051401    }
     
    15341430        # higher dimensions?  If there isn't, let's kill this in favor
    15351431        # or explicitly using a <curve> instead.  Otherwise, the features
    1536         # (methods such as xmarkers) or the <curve> need to be added
     1432        # (methods such as xmarkers) of the <curve> need to be added
    15371433        # to the <field>.
    15381434        #
     
    16041500        $v set [$_field get $cname.values]
    16051501        if { [$v length] == 0 } {
     1502            puts stderr "ERROR: No field values"
    16061503            return 0
    16071504        }
     
    16661563    $writer SetInputConnection [$reader GetOutputPort]
    16671564    $writer SetFileName $tmpfile
     1565    $writer SetFileTypeToBinary
    16681566    $writer Write
    16691567    rename $reader ""
     
    17171615    }
    17181616
    1719     # Save viewer choice
    1720     set viewer $_viewer
    17211617    ReadVtkDataSet $cname $data(vtkdata)
    1722     # Restore viewer choice (ReadVtkDataSet wants to set it to contour/isosurface)
    1723     set _viewer $viewer
    17241618    return $data(vtkdata)
    17251619}
     
    17351629    }
    17361630    set type [$_field get $cname.elemtype]
     1631    # <extents> is a deprecated synonym for <elemsize>
     1632    set extents  [$_field get $cname.extents]
    17371633    if { $type == "" } {
    1738         set type "scalars"
     1634        if { $extents != "" && $extents > 1 } {
     1635            set type "vectors"
     1636        } else {
     1637            set type "scalars"
     1638        }
    17391639    }
    17401640    if { ![info exists type2components($type)] } {
     
    17431643    set size [$_field get $cname.elemsize]
    17441644    if { $size == "" } {
    1745         set size $type2components($type)
     1645        if { $extents != "" } {
     1646            set size $extents
     1647        } else {
     1648            set size $type2components($type)
     1649        }
    17461650    }
    17471651    set _comp2type($cname) $type
Note: See TracChangeset for help on using the changeset viewer.