Ignore:
Timestamp:
May 27, 2015, 2:36:55 PM (9 years ago)
Author:
ldelgass
Message:

Remove old unirect blob encodings for sending data to nanovis. Unirect2d/3d are
now treated as deprecated mesh types that are converted to VTK, like cloud.

File:
1 edited

Legend:

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

    r5610 r5611  
    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
     
    4041        return $_numPoints
    4142    }
    42     public method order {} {
    43         return _axisOrder;
    44     }
    4543    public method units { axis }
    46     public method values {}
    4744    public method vtkdata {{what -partial}} {}
    4845
     
    5148    private method GetSize { obj path varName }
    5249
    53     private variable _axisOrder  "x y z"
    5450    private variable _xMax       0
    5551    private variable _xMin       0
     
    6157    private variable _zMin       0
    6258    private variable _zNum       0;     # Number of points along z-axis
    63     private variable _compNum    1;     # Number of components in values
    64     private variable _values     "";    # BLT vector containing the values
    6559    private variable _hints
    6660    private variable _vtkdata    ""
    6761    private variable _numPoints  0
    6862    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    }
    69111}
    70112
     
    72114# Constructor
    73115# ----------------------------------------------------------------------
    74 itcl::body Rappture::Unirect3d::constructor {xmlobj field cname {numComponents 1}} {
     116itcl::body Rappture::Unirect3d::constructor {xmlobj path} {
    75117    if {![Rappture::library isvalid $xmlobj]} {
    76118        error "bad value \"$xmlobj\": should be Rappture::library"
    77119    }
    78     set path [$field get $cname.mesh]
    79120    set m [$xmlobj element -as object $path]
    80121    GetValue $m "xaxis.min" _xMin
     
    87128    GetSize $m "yaxis.numpoints" _yNum
    88129    GetSize $m "zaxis.numpoints" _zNum
    89     set _compNum $numComponents
    90130    foreach {key path} {
    91         group   about.group
    92131        label   about.label
    93132        color   about.color
    94133        style   about.style
    95         type    about.type
    96134        xlabel  xaxis.label
    97135        xdesc   xaxis.description
     
    112150        zmin    zaxis.min
    113151        zmax    zaxis.max
    114         order   about.axisorder
    115152    } {
    116153        set str [$m get $path]
    117         if {"" != $str} {
    118             set _hints($key) $str
    119         }
    120     }
    121     foreach {key} { axisorder } {
    122         set str [$field get $cname.$key]
    123154        if {"" != $str} {
    124155            set _hints($key) $str
     
    130161        set _vtkdata ""
    131162        return
    132     }
    133     set _values [blt::vector create #auto]
    134     $_values set [$field get "$cname.values"]
    135     set n [expr $_numPoints * $_compNum]
    136     if { [$_values length] != $n } {
    137         error "wrong \# of values in \"$cname.values\": expected $n values, got [$_values length]"
    138163    }
    139164    append out "DATASET STRUCTURED_POINTS\n"
     
    165190# ----------------------------------------------------------------------
    166191itcl::body Rappture::Unirect3d::destructor {} {
    167     if { $_values != "" } {
    168         blt::vector destroy $_values
    169     }
    170 }
    171 
    172 # ----------------------------------------------------------------------
    173 # method blob
    174 #       Returns a Tcl list that represents the Tcl command and data to
    175 #       recreate the uniform rectangular grid on the nanovis server.
    176 # ----------------------------------------------------------------------
    177 itcl::body Rappture::Unirect3d::blob {} {
    178     set data "unirect3d"
    179     lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum
    180     lappend data "ymin" $_yMin "ymax" $_yMax "ynum" $_yNum
    181     lappend data "zmin" $_zMin "zmax" $_zMax "znum" $_zNum
    182     lappend data "axisorder" $_axisOrder
    183     if { [$_values length] > 0 } {
    184         lappend data "values" [$_values range 0 end]
    185     }
    186     return $data
    187 }
    188 
    189 # ----------------------------------------------------------------------
    190 # method values
    191 #       Returns a BLT vector that represents the field values
    192 # ----------------------------------------------------------------------
    193 itcl::body Rappture::Unirect3d::values {} {
    194     return $_values
     192    # empty
    195193}
    196194
     
    217215            set max $_zMax
    218216        }
    219         v - vlin - vlog {
    220             if { [$_values length] > 0 } {
    221                set min [blt::vector expr min($_values)]
    222                set max [blt::vector expr max($_values)]
    223             } else {
    224                 set min 0.0
    225                 set max 1.0
    226             }
    227         }
    228217        default {
    229218            error "unknown axis description \"$which\""
     
    277266        set _hints(ylabel) "$_hints(zlabel) ($_hints(zunits))"
    278267    }
    279 
    280268    if {[info exists _hints(group)] && [info exists _hints(label)]} {
    281269        # pop-up help for each curve
Note: See TracChangeset for help on using the changeset viewer.