Changeset 5679 for branches/uq/gui/scripts/field.tcl
- Timestamp:
- Jun 9, 2015 1:55:08 PM (9 years ago)
- Location:
- branches/uq
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uq
- Property svn:mergeinfo changed
-
branches/uq/gui/scripts/field.tcl
r5121 r5679 21 21 # Possible field dataset types: 22 22 # 23 # 1D Datasets 24 # 1D A field contained in a structure 23 25 # 2D Datasets 24 # vtk(range of z-axis is zero).25 # unirect2d(deprecated)26 # cloud(x,y point coordinates) (deprecated)27 # 26 # vtk (range of z-axis is zero). 27 # unirect2d (deprecated) 28 # cloud (x,y point coordinates) (deprecated) 29 # mesh 28 30 # 3D Datasets 29 # 30 # 31 # cloud(x,y,z coordinates) (deprecated)32 # 33 # dx(FIXME: make dx-to-vtk converter work)34 # ucd avs31 # 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) 35 37 # 36 38 # 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 45 48 # 46 49 # With <views>, can specify which viewer for specific datasets. So it's OK … … 64 67 65 68 itcl::class Rappture::Field { 66 protected variable _dim 0; # Dimension of the mesh67 private variable _xmlobj ""; # ref to XML obj with field data68 private variable _limits; # maps axis name => {z0 z1} limits69 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 element73 private variable _comp2assoc; # cname => association (e.g. pointdata)74 private variable _fld2Components; # field name => number of components75 private variable _fld2Label; # field name => label76 private variable _fld2Units; # field name => units77 private variable _hints78 private variable _viewer ""; # Hints which viewer to use79 private variable _xv ""; # For 1D meshes only. Holds the points80 private variable _isValid 0; # Indicates if the field contains81 # valid data.82 private variable _isValidComponent; # Array of valid components found83 private variable _alwaysConvertDX 0;84 85 69 constructor {xmlobj path} { 86 70 # defined below … … 92 76 public method components {args} 93 77 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 }119 78 public method fieldinfo { fname } { 120 79 lappend out $_fld2Label($fname) … … 123 82 return $out 124 83 } 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 ""}} 125 93 public method isvalid {} { 126 94 return $_isValid 127 95 } 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 } 128 103 public method viewer {} { 129 104 return $_viewer 130 105 } 106 public method vtkdata {cname} 107 public method xErrorValues { cname } { 108 } 109 public method yErrorValues { cname } { 110 } 111 131 112 protected method Build {} 132 113 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 } 152 117 153 118 private method AvsToVtk { cname contents } 154 119 private method DicomToVtk { cname contents } 155 120 private method BuildPointsOnMesh { cname } 156 protected method GetAssociation { cname }157 protected method GetTypeAndSize { cname }158 protected method ReadVtkDataSet { cname contents }159 121 private method InitHints {} 160 161 122 private method VerifyVtkDataSet { contents } 162 123 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 164 163 } 165 164 … … 218 217 foreach name [array names _comp2xy] { 219 218 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)226 219 } 227 220 foreach name [array names _comp2flowhints] { … … 302 295 # USAGE: mesh ?<name>? 303 296 # 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. 307 299 # ---------------------------------------------------------------------- 308 300 itcl::body Rappture::Field::mesh {{cname -overall}} { … … 313 305 return [lindex $_comp2xy($cname) 0] ;# return xv 314 306 } 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)]} { 320 308 error "method \"mesh\" is not implemented for VTK file data" 321 309 } 322 310 if {[info exists _comp2dx($cname)]} { 323 return "" ;# no mesh -- it's embedded in the blob data311 error "method \"mesh\" is not implemented for DX file data" 324 312 } 325 313 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" 335 315 } 336 316 error "can't get field mesh: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]" … … 340 320 # USAGE: values ?<name>? 341 321 # 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] 345 326 # ---------------------------------------------------------------------- 346 327 itcl::body Rappture::Field::values {cname} { … … 351 332 return [lindex $_comp2xy($cname) 1] ;# return yv 352 333 } 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" 365 336 } 366 337 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]] {, }]" 376 344 } 377 345 … … 385 353 set cname "component" 386 354 } 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 }393 355 if {[info exists _comp2dx($cname)]} { 394 356 return $_comp2dx($cname) ;# return gzipped, base64-encoded DX data 395 357 } 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" 403 366 } 404 367 error "can't get field blob: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]" … … 422 385 # 423 386 # Returns a list {min max} representing the limits for the specified 424 # axis .387 # axis over all components. 425 388 # ---------------------------------------------------------------------- 426 389 itcl::body Rappture::Field::limits {which} { … … 540 503 # USAGE: fieldlimits 541 504 # 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. 544 512 # ---------------------------------------------------------------------- 545 513 itcl::body Rappture::Field::fieldlimits {} { … … 757 725 } 758 726 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 }765 727 catch {unset _comp2xy} 766 728 catch {unset _comp2dx} 767 729 catch {unset _comp2dims} 768 730 catch {unset _comp2style} 769 array unset _comp2unirect2d770 array unset _comp2unirect3d771 array unset _comp2extents772 731 array unset _dataobj2type 773 732 # … … 787 746 } elseif { [$_field element $cname.vtk] != ""} { 788 747 set type "vtk" 789 set viewer [$_field get "about.view"]790 if { $viewer != "" } {791 set _viewer $viewer792 }793 748 } elseif {[$_field element $cname.opendx] != ""} { 794 global env795 if { [info exists env(VTKVOLUME)] } {796 set _viewer "vtkvolume"797 }798 749 set type "opendx" 799 750 } elseif {[$_field element $cname.dx] != ""} { 800 global env801 if { [info exists env(VTKVOLUME)] } {802 set _viewer "vtkvolume"803 }804 751 set type "dx" 805 752 } elseif {[$_field element $cname.ucd] != ""} { … … 813 760 continue 814 761 } 815 # Save the extents of the component816 if { [$_field element $cname.extents] != "" } {817 set extents [$_field get $cname.extents]818 } else {819 set extents 1820 }821 set _comp2extents($cname) $extents822 762 set _type $type 823 763 824 764 GetTypeAndSize $cname 825 765 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 } { 829 815 set _viewer "glyphs" 830 } 831 } 816 } elseif { $_comp2size($cname) > 1 && $haveFlow } { 817 set _viewer "flowvis" 818 } 819 } 820 832 821 if {$type == "1D"} { 833 822 # … … 895 884 } elseif {$type == "dx" || $type == "opendx" } { 896 885 # 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 900 887 # 901 set viewer [$_field get "about.view"]902 if { $viewer != "" } {903 set _viewer $viewer904 }905 888 if { $_viewer == "" } { 906 if { [$_field element $cname.flow] != ""} {889 if {$haveFlow} { 907 890 set _viewer "flowvis" 908 891 } else { 892 global env 893 if { [info exists env(VTKVOLUME)] } { 894 set _viewer "vtkvolume" 895 } 909 896 set _viewer "nanovis" 910 897 } 911 898 } 912 set _dim 3913 set _comp2dims($cname) "3D"914 899 set data [$_field get -decode no $cname.$type] 915 900 set contents [Rappture::encoding::decode -as zb64 $data] … … 923 908 close $f 924 909 } 910 # Convert to VTK 925 911 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. 926 916 ReadVtkDataSet $cname $vtkdata 927 917 if 0 { … … 931 921 } 932 922 } 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 934 927 } 935 928 if { $_alwaysConvertDX || … … 941 934 set _comp2dx($cname) $data 942 935 } 936 unset data 937 unset vtkdata 943 938 set _comp2style($cname) [$_field get $cname.style] 944 if { [$_field element $cname.flow] != ""} {939 if {$haveFlow} { 945 940 set _comp2flowhints($cname) \ 946 941 [Rappture::FlowHints ::\#auto $_field $cname $_units] … … 951 946 if { $contents == "" } { 952 947 continue; # Ignore this component 953 }954 set viewer [$_field get "about.view"]955 if { $viewer != "" } {956 set _viewer $viewer957 948 } 958 949 set vtkdata [DicomToVtk $cname $contents] … … 1068 1059 1069 1060 # 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 #1088 1061 # flowhints -- 1089 1062 # … … 1114 1087 # Returns the data storage type of the field. 1115 1088 # 1116 # FIXME: What are the valid types? 1089 # Types: 1090 # 1D,cloud,dicom,dx,mesh,ucd,unirect2d,unirect3d,vtk 1117 1091 # 1118 1092 itcl::body Rappture::Field::type {} { … … 1132 1106 } 1133 1107 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 01144 foreach cname [$_field children -type component] {1145 if { ![info exists _comp2unirect3d($cname)] &&1146 ![info exists _comp2extents($cname)] } {1147 continue1148 }1149 set value $_comp2extents($cname)1150 if { $max < $value } {1151 set max $value1152 }1153 }1154 return $max1155 }1156 if { $cname == "component0"} {1157 set cname [lindex [components -name] 0]1158 }1159 return $_comp2extents($cname)1160 1108 } 1161 1109 … … 1240 1188 } 1241 1189 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 01255 }1256 set array [$dataAttrs GetScalars]1257 if { $array == ""} {1258 puts stderr "WARNING: No scalar point data found in \"$_path\""1259 rename $reader ""1260 return 01261 }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 $yv1267 set _comp2xy($cname) [list $xv $yv]1268 }1269 1190 lappend limits x [list $xmin $xmax] 1270 1191 lappend limits y [list $ymin $ymax] … … 1304 1225 1305 1226 # 1227 # VtkDataSetToXy -- 1228 # 1229 # Attempt to convert 0 or 1 dimensional VTK DataSet to XY data (curve). 1230 # 1231 itcl::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 # 1306 1272 # vtkdata -- 1307 1273 # … … 1313 1279 set cname "component" 1314 1280 } 1281 # VTK file data: 1282 if { [info exists _comp2vtk($cname)] } { 1283 return $_comp2vtk($cname) 1284 } 1315 1285 # DX: Convert DX to VTK 1316 1286 if {[info exists _comp2dx($cname)]} { 1317 1287 set data $_comp2dx($cname) 1318 set data [Rappture::encoding::decode $data]1288 set data [Rappture::encoding::decode -as zb64 $data] 1319 1289 return [Rappture::DxToVtk $data] 1320 }1321 # Unirect3d: isosurface1322 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)1328 1290 } 1329 1291 # Points on mesh: Construct VTK file output. … … 1384 1346 return $out 1385 1347 } 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" 1387 1349 } 1388 1350 … … 1402 1364 if {[$_xmlobj element $path] == ""} { 1403 1365 # Unknown mesh designated. 1366 puts stderr "ERROR: Unknown mesh \"$path\"" 1404 1367 return 0 1405 }1406 set viewer [$_field get "about.view"]1407 if { $viewer != "" } {1408 set _viewer $viewer1409 1368 } 1410 1369 set element [$_xmlobj element -as type $path] … … 1420 1379 lappend _comp2fldName($cname) $name 1421 1380 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 11429 }1430 set _type unirect3d1431 set _dim 31432 if { $_viewer == "" } {1433 set _viewer flowvis1434 }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 limits1444 set vector [$_comp2unirect3d($cname) valuesObj]1445 set minmax [VectorLimits $vector $vectorsize]1446 lappend limits $cname $minmax1447 lappend limits v $minmax1448 set _comp2limits($cname) $limits1449 if {[$_field element $cname.flow] != ""} {1450 set _comp2flowhints($cname) \1451 [Rappture::FlowHints ::\#auto $_field $cname $_units]1452 }1453 incr _counter1454 return 11455 }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 11462 }1463 set _type unirect2d1464 set _dim 21465 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 $_values1481 set minmax [VectorLimits $xv $vectorsize]1482 lappend limits $cname $minmax1483 lappend limits v $minmax1484 blt::vector destroy $xv1485 set _comp2limits($cname) $limits1486 incr _counter1487 return 11488 }1489 1381 switch -- $element { 1490 1382 "cloud" { … … 1502 1394 set mesh [Rappture::Unirect2d::fetch $_xmlobj $path] 1503 1395 set _type unirect2d 1396 } 1397 "unirect3d" { 1398 set mesh [Rappture::Unirect3d::fetch $_xmlobj $path] 1399 set _type unirect3d 1504 1400 } 1505 1401 } … … 1534 1430 # higher dimensions? If there isn't, let's kill this in favor 1535 1431 # or explicitly using a <curve> instead. Otherwise, the features 1536 # (methods such as xmarkers) o rthe <curve> need to be added1432 # (methods such as xmarkers) of the <curve> need to be added 1537 1433 # to the <field>. 1538 1434 # … … 1604 1500 $v set [$_field get $cname.values] 1605 1501 if { [$v length] == 0 } { 1502 puts stderr "ERROR: No field values" 1606 1503 return 0 1607 1504 } … … 1666 1563 $writer SetInputConnection [$reader GetOutputPort] 1667 1564 $writer SetFileName $tmpfile 1565 $writer SetFileTypeToBinary 1668 1566 $writer Write 1669 1567 rename $reader "" … … 1717 1615 } 1718 1616 1719 # Save viewer choice1720 set viewer $_viewer1721 1617 ReadVtkDataSet $cname $data(vtkdata) 1722 # Restore viewer choice (ReadVtkDataSet wants to set it to contour/isosurface)1723 set _viewer $viewer1724 1618 return $data(vtkdata) 1725 1619 } … … 1735 1629 } 1736 1630 set type [$_field get $cname.elemtype] 1631 # <extents> is a deprecated synonym for <elemsize> 1632 set extents [$_field get $cname.extents] 1737 1633 if { $type == "" } { 1738 set type "scalars" 1634 if { $extents != "" && $extents > 1 } { 1635 set type "vectors" 1636 } else { 1637 set type "scalars" 1638 } 1739 1639 } 1740 1640 if { ![info exists type2components($type)] } { … … 1743 1643 set size [$_field get $cname.elemsize] 1744 1644 if { $size == "" } { 1745 set size $type2components($type) 1645 if { $extents != "" } { 1646 set size $extents 1647 } else { 1648 set size $type2components($type) 1649 } 1746 1650 } 1747 1651 set _comp2type($cname) $type
Note: See TracChangeset
for help on using the changeset viewer.