Changeset 5325 for branches/1.3
- Timestamp:
- Apr 26, 2015, 2:19:13 PM (10 years ago)
- Location:
- branches/1.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
-
branches/1.3/gui/scripts/field.tcl
r5318 r5325 158 158 protected method ReadVtkDataSet { cname contents } 159 159 private method InitHints {} 160 161 160 private method VerifyVtkDataSet { contents } 162 161 private method VectorLimits { vector vectorsize {comp -1} } 162 private method VtkDataSetToXy { dataset } 163 163 } 164 164 … … 886 886 } elseif {$type == "dx" || $type == "opendx" } { 887 887 # 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 # 892 890 set viewer [$_field get "about.view"] 893 891 if { $viewer != "" } { … … 901 899 } 902 900 } 903 set _dim 3904 set _comp2dims($cname) "3D"905 901 set data [$_field get -decode no $cname.$type] 906 902 set contents [Rappture::encoding::decode -as zb64 $data] … … 914 910 close $f 915 911 } 912 # Convert to VTK 916 913 if { [catch { Rappture::DxToVtk $contents } vtkdata] == 0 } { 917 914 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. 918 918 ReadVtkDataSet $cname $vtkdata 919 919 if 0 { … … 924 924 } else { 925 925 unset contents 926 puts stderr "Can't parse dx data" 926 puts stderr "Can't parse DX data" 927 continue; # Ignore this component 927 928 } 928 929 if { $_alwaysConvertDX || … … 1235 1236 } 1236 1237 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 01250 }1251 set array [$dataAttrs GetScalars]1252 if { $array == ""} {1253 puts stderr "WARNING: No scalar point data found in \"$_path\""1254 rename $reader ""1255 return 01256 }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 $yv1262 set _comp2xy($cname) [list $xv $yv]1263 }1264 1238 lappend limits x [list $xmin $xmax] 1265 1239 lappend limits y [list $ymin $ymax] … … 1296 1270 1297 1271 rename $reader "" 1272 } 1273 1274 # 1275 # VtkDataSetToXy -- 1276 # 1277 # Attempt to convert 0 or 1 dimensional VTK DataSet to XY data (curve). 1278 # 1279 itcl::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 1298 1317 } 1299 1318 … … 1711 1730 } 1712 1731 1713 # Save viewer choice1714 set viewer $_viewer1715 1732 ReadVtkDataSet $cname $data(vtkdata) 1716 # Restore viewer choice (ReadVtkDataSet wants to set it to contour/isosurface)1717 set _viewer $viewer1718 1733 return $data(vtkdata) 1719 1734 }
Note: See TracChangeset
for help on using the changeset viewer.