Changeset 5325 for branches/1.3


Ignore:
Timestamp:
Apr 26, 2015, 2:19:13 PM (10 years ago)
Author:
ldelgass
Message:

merge r5323 from trunk

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

    • Property svn:mergeinfo changed
      /trunkmerged: 5323
  • branches/1.3/gui/scripts/field.tcl

    r5318 r5325  
    158158    protected method ReadVtkDataSet { cname contents }
    159159    private method InitHints {}
    160 
    161160    private method VerifyVtkDataSet { contents }
    162161    private method VectorLimits { vector vectorsize {comp -1} }
     162    private method VtkDataSetToXy { dataset }
    163163}
    164164
     
    886886        } elseif {$type == "dx" || $type == "opendx" } {
    887887            #
    888             # HACK ALERT!  Extract gzipped, base64-encoded OpenDX
    889             # data.  Assume that it's 3D.  Pass it straight
    890             # off to the NanoVis visualizer.
    891             #
     888            # Extract gzipped, base64-encoded OpenDX data
     889            #
    892890            set viewer [$_field get "about.view"]
    893891            if { $viewer != "" } {
     
    901899                }
    902900            }
    903             set _dim 3
    904             set _comp2dims($cname) "3D"
    905901            set data [$_field get -decode no $cname.$type]
    906902            set contents [Rappture::encoding::decode -as zb64 $data]
     
    914910                close $f
    915911            }
     912            # Convert to VTK
    916913            if { [catch { Rappture::DxToVtk $contents } vtkdata] == 0 } {
    917914                unset contents
     915                # Read back VTK: this will set the field limits and the mesh
     916                # dimensions based on the bounds (sets _dim).  We rely on this
     917                # conversion for limits even if we send DX data to nanovis.
    918918                ReadVtkDataSet $cname $vtkdata
    919919                if 0 {
     
    924924            } else {
    925925                unset contents
    926                 puts stderr "Can't parse dx data"
     926                puts stderr "Can't parse DX data"
     927                continue;               # Ignore this component
    927928            }
    928929            if { $_alwaysConvertDX ||
     
    12351236    }
    12361237    set _comp2dims($cname) ${_dim}D
    1237     if { $_dim < 2 } {
    1238         set numPoints [$dataset GetNumberOfPoints]
    1239         set xv [blt::vector create \#auto]
    1240         for { set i 0 } { $i < $numPoints } { incr i } {
    1241             set point [$dataset GetPoint $i]
    1242             $xv append [lindex $point 0]
    1243         }
    1244         set yv [blt::vector create \#auto]
    1245         set dataAttrs [$dataset GetPointData]
    1246         if { $dataAttrs == ""} {
    1247             puts stderr "WARNING: No point data found in \"$_path\""
    1248             rename $reader ""
    1249             return 0
    1250         }
    1251         set array [$dataAttrs GetScalars]
    1252         if { $array == ""} {
    1253             puts stderr "WARNING: No scalar point data found in \"$_path\""
    1254             rename $reader ""
    1255             return 0
    1256         }
    1257         set numTuples [$array GetNumberOfTuples]
    1258         for { set i 0 } { $i < $numTuples } { incr i } {
    1259             $yv append [$array GetComponent $i 0]
    1260         }
    1261         $xv sort $yv
    1262         set _comp2xy($cname) [list $xv $yv]
    1263     }
    12641238    lappend limits x [list $xmin $xmax]
    12651239    lappend limits y [list $ymin $ymax]
     
    12961270
    12971271    rename $reader ""
     1272}
     1273
     1274#
     1275# VtkDataSetToXy --
     1276#
     1277#        Attempt to convert 0 or 1 dimensional VTK DataSet to XY data (curve).
     1278#
     1279itcl::body Rappture::Field::VtkDataSetToXy { dataset } {
     1280    foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break
     1281    # Only X can have non-zero range.  X can have zero range if there is
     1282    # only one point
     1283    if { $ymax > $ymin } {
     1284        return 0
     1285    }
     1286    if { $zmax > $zmin } {
     1287        return 0
     1288    }
     1289    set numPoints [$dataset GetNumberOfPoints]
     1290    set xv [blt::vector create \#auto]
     1291    for { set i 0 } { $i < $numPoints } { incr i } {
     1292        set point [$dataset GetPoint $i]
     1293        $xv append [lindex $point 0]
     1294    }
     1295    set yv [blt::vector create \#auto]
     1296    set dataAttrs [$dataset GetPointData]
     1297    if { $dataAttrs == ""} {
     1298        puts stderr "WARNING: No point data found"
     1299        return 0
     1300    }
     1301    set array [$dataAttrs GetScalars]
     1302    if { $array == ""} {
     1303        puts stderr "WARNING: No scalar point data found"
     1304        return 0
     1305    }
     1306    # Multi-component scalars (e.g. color scalars) are not supported
     1307    if { [$array GetNumberOfComponents] != 1 } {
     1308        return 0
     1309    }
     1310    set numTuples [$array GetNumberOfTuples]
     1311    for { set i 0 } { $i < $numTuples } { incr i } {
     1312        $yv append [$array GetComponent $i 0]
     1313    }
     1314    $xv sort $yv
     1315    set _comp2xy($cname) [list $xv $yv]
     1316    return 1
    12981317}
    12991318
     
    17111730    }
    17121731
    1713     # Save viewer choice
    1714     set viewer $_viewer
    17151732    ReadVtkDataSet $cname $data(vtkdata)
    1716     # Restore viewer choice (ReadVtkDataSet wants to set it to contour/isosurface)
    1717     set _viewer $viewer
    17181733    return $data(vtkdata)
    17191734}
Note: See TracChangeset for help on using the changeset viewer.