Changeset 3546 for trunk/gui/scripts/field.tcl
- Timestamp:
- Mar 20, 2013 3:15:43 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/field.tcl
r3508 r3546 80 80 private variable _hints 81 81 private variable _viewer ""; # Hints which viewer to use 82 private variable _xv ""; # For 1D meshes only. Holds the points 82 83 constructor {xmlobj path} { 83 84 # defined below … … 278 279 if { [info exists _comp2vtk($cname)] } { 279 280 # FIXME: extract mesh from VTK file data. 281 if { $_comp2dims($cname) == "1D" } { 282 return $_xv 283 } 280 284 error "method \"mesh\" is not implemented for VTK file data" 281 285 } … … 314 318 if { [info exists _comp2vtk($cname)] } { 315 319 # FIXME: extract the values from the VTK file data 320 if { $_comp2dims($cname) == "1D" } { 321 return $_values 322 } 316 323 error "method \"values\" is not implemented for vtk file data" 317 324 } … … 731 738 set type "dx" 732 739 } 740 } elseif {[$_fldObj element $cname.ucd] != ""} { 741 set type "ucd" 733 742 } 734 743 set _comp2style($cname) "" … … 843 852 } 844 853 incr _counter 845 } elseif {[$_fldObj element $cname.ucd] != ""} { 846 set _viewer "isosurface" 847 set _comp2dims($cname) "3D" 854 } elseif { $type == "ucd"} { 848 855 set contents [$_fldObj get $cname.ucd] 849 856 set vtkdata [AvsToVtk $cname $contents] … … 1144 1151 } 1145 1152 set _comp2dims($cname) ${_dim}D 1153 if { $_dim < 2 } { 1154 set points [$dataset GetPoints] 1155 set numPoints [$points GetNumberOfPoints] 1156 puts stderr "\#points are $numPoints" 1157 set xv [blt::vector create \#auto] 1158 for { set i 0 } { $i < $numPoints } { incr i } { 1159 set point [$points GetPoint 0] 1160 $xv append [lindex $point 0] 1161 } 1162 set yv [blt::vector create \#auto] 1163 $yv seq 0 1 [$xv length] 1164 set _comp2xy($cname) [list $xv $yv] 1165 } 1146 1166 lappend limits x [list $xmin $xmax] 1147 1167 lappend limits y [list $ymin $ymax] 1148 1168 lappend limits z [list $zmin $zmax] 1149 1169 set dataAttrs [$dataset GetPointData] 1170 if { $_dim == 1 } { 1171 set numArrays [$dataAttrs GetNumberOfArrays] 1172 puts stderr "\#arrays are $numArrays" 1173 } 1150 1174 if { $dataAttrs == ""} { 1151 1175 puts stderr "No point data" … … 1378 1402 } 1379 1403 1380 itcl::body Rappture::Field::AvsToVtk { c ompcontents } {1404 itcl::body Rappture::Field::AvsToVtk { cname contents } { 1381 1405 package require vtk 1382 1406 1407 puts stderr "AVSToVTK" 1383 1408 set reader $this-datasetreader 1384 1409 vtkAVSucdReader $reader 1385 1410 1386 1411 # Write the contents to a file just in case it's binary. 1387 set tmpfile file[pid].vtk1412 set tmpfile $cname[pid].ucd 1388 1413 set f [open "$tmpfile" "w"] 1389 1414 fconfigure $f -translation binary -encoding binary … … 1401 1426 lappend _scalars $name $name "???" 1402 1427 } 1428 set tmpfile $cname[pid].vtk 1403 1429 set writer $this-datasetwriter 1404 1430 vtkDataSetWriter $writer … … 1408 1434 rename $reader "" 1409 1435 rename $writer "" 1436 1410 1437 set f [open "$tmpfile" "r"] 1411 1438 fconfigure $f -translation binary -encoding binary 1412 1439 set vtkdata [read $f] 1413 1440 close $f 1414 file delete $tmpfile 1441 puts stderr "wrote $tmpfile" 1442 #file delete $tmpfile 1415 1443 return $vtkdata 1416 1444 }
Note: See TracChangeset
for help on using the changeset viewer.