Changeset 4459 for branches/1.3
- Timestamp:
- Jul 3, 2014, 9:56:50 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/field.tcl
r4387 r4459 16 16 17 17 # TODO: 18 # 19 # o How to describe vector values in a field? 20 # <components>3</components> 21 # <values></values> 22 # 23 # Does anything need to know the limits for each component of the vector? 24 # 18 # Vector field limits are wrong: need to compute magnitude limits and 19 # component-wise limits. 25 20 26 21 # … … 29 24 # 2D Datasets 30 25 # vtk (range of z-axis is zero). 31 # unirect2d (deprecated except where extents > 1)26 # unirect2d (deprecated) 32 27 # cloud (x,y point coordinates) (deprecated) 33 28 # mesh 34 29 # 3D Datasets 35 30 # vtk 36 # unirect3d 31 # unirect3d (deprecated) 37 32 # cloud (x,y,z coordinates) (deprecated) 38 33 # mesh … … 50 45 # unirect3d 3 unirect2d + extents > 1 flow flow nanovis 51 46 # 52 # With <views>, can specify which viewer for aspecific datasets. So it's OK53 # to if the same dataset canbe viewed in more than one way.47 # With <views>, can specify which viewer for specific datasets. So it's OK 48 # for the same dataset to be viewed in more than one way. 54 49 # o Any 2D dataset can be viewed as a contour/heightmap. 55 50 # o Any 3D dataset can be viewed as a isosurface. 56 # o Any 2D dataset with vector data can be streamlines .51 # o Any 2D dataset with vector data can be streamlines or flow. 57 52 # o Any 3D uniform rectilinear dataset can be viewed as a volume. 58 53 # o Any 3D dataset with vector data can be streamlines or flow. 59 #60 # Vector data 2/3 streamlines61 # Scalar data 1/62 54 # 63 55 # Need <views> to properly do things like qdot: volume with a polydata … … 159 151 private method AvsToVtk { cname contents } 160 152 private method BuildPointsOnMesh { cname } 161 private method ConvertToVtkData { cname }162 153 protected method GetAssociation { cname } 163 154 protected method GetTypeAndSize { cname } … … 441 432 442 433 set vname [lindex $_comp2xy($cname) $pos] 434 443 435 if {$log} { 444 436 # on a log scale, use abs value and ignore 0's … … 540 532 foreach cname [array names _comp2limits] { 541 533 array set limits $_comp2limits($cname) 542 foreach fname $_comp2fldName($cname){534 foreach fname [fieldnames $cname] { 543 535 if { ![info exists limits($fname)] } { 544 536 puts stderr "ERROR: field \"$fname\" unknown in \"$cname\"" … … 779 771 set _comp2style($cname) "" 780 772 if { $type == "" } { 781 puts stderr "WARNING: ignoring field component \"$_path.$cname\": no data found."773 puts stderr "WARNING: Ignoring field component \"$_path.$cname\": no data found." 782 774 continue 783 775 } … … 855 847 set contents [$_field get $cname.vtk] 856 848 if { $contents == "" } { 857 puts stderr "WARNING: no data fo\"$_path.$cname.vtk\""849 puts stderr "WARNING: No data for \"$_path.$cname.vtk\"" 858 850 continue; # Ignore this component 859 851 } … … 880 872 set vtkdata [$_field get -decode yes $cname.$type] 881 873 if { $vtkdata == "" } { 882 puts stderr "WARNING: no data for \"$_path.$cname.$type\""874 puts stderr "WARNING: No data for \"$_path.$cname.$type\"" 883 875 continue; # Ignore this component 884 876 } … … 900 892 set contents [$_field get -decode no $cname.$type] 901 893 if { $contents == "" } { 902 puts stderr "WARNING: no data for \"$_path.$cname.$type\""894 puts stderr "WARNING: No data for \"$_path.$cname.$type\"" 903 895 continue; # Ignore this component 904 896 } … … 915 907 set contents [$_field get $cname.ucd] 916 908 if { $contents == "" } { 917 continue; # Ignore this compo ennt909 continue; # Ignore this component 918 910 } 919 911 set vtkdata [AvsToVtk $cname $contents] … … 926 918 } 927 919 if { [array size _isValidComponent] == 0 } { 928 puts stderr " WARNING: no valid components for field \"$_path\""920 puts stderr "ERROR: All components of field \"$_path\" are invalid." 929 921 return 0 930 922 } … … 938 930 } 939 931 if { $dim != $_comp2dims($cname) } { 940 puts stderr "WARNING: field can't have components of different dimensions: [join [array get _comp2dims] ,]"932 puts stderr "WARNING: A field can't have components of different dimensions: [join [array get _comp2dims] ,]" 941 933 return 0 942 934 } 943 935 } 936 944 937 # FIXME: about.scalars and about.vectors are temporary. With views 945 938 # the label and units for each field will be specified there. … … 1059 1052 # type -- 1060 1053 # 1061 # Returns the style associated with a component of the field. 1054 # Returns the data storage type of the field. 1055 # 1056 # FIXME: What are the valid types? 1062 1057 # 1063 1058 itcl::body Rappture::Field::type {} { … … 1103 1098 } 1104 1099 return $_comp2extents($cname) 1105 }1106 1107 itcl::body Rappture::Field::ConvertToVtkData { cname } {1108 set ds ""1109 switch -- [typeof $cname] {1110 "unirect2d" {1111 foreach { x1 x2 xN y1 y2 yN } [$dataobj mesh $cname] break1112 set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]1113 set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]1114 1115 set ds [vtkImageData $this-grdataTemp]1116 $ds SetDimensions $xN $yN 11117 $ds SetOrigin $x1 $y1 01118 $ds SetSpacing $spacingX $spacingY 01119 set arr [vtkDoubleArray $this-arrTemp]1120 foreach {val} [$dataobj values $cname] {1121 $arr InsertNextValue $val1122 }1123 [$ds GetPointData] SetScalars $arr1124 }1125 "unirect3d" {1126 foreach { x1 x2 xN y1 y2 yN z1 z2 zN } [$dataobj mesh $cname] break1127 set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]1128 set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]1129 set spacingZ [expr {double($z2 - $z1)/double($zN - 1)}]1130 1131 set ds [vtkImageData $this-grdataTemp]1132 $ds SetDimensions $xN $yN $zN1133 $ds SetOrigin $x1 $y1 $z11134 $ds SetSpacing $spacingX $spacingY $spacingZ1135 set arr [vtkDoubleArray $this-arrTemp]1136 foreach {val} [$dataobj values $cname] {1137 $arr InsertNextValue $val1138 }1139 [$ds GetPointData] SetScalars $val1140 }1141 "contour" {1142 return [$dataobj blob $cname]1143 }1144 "dx" {1145 return [Rappture::DxToVtk $_comp2dx($cname)]1146 }1147 default {1148 set mesh [$dataobj mesh $cname]1149 switch -- [$mesh GetClassName] {1150 vtkPoints {1151 # handle cloud of points1152 set ds [vtkPolyData $this-polydataTemp]1153 $ds SetPoints $mesh1154 [$ds GetPointData] SetScalars [$dataobj values $cname]1155 }1156 vtkPolyData {1157 set ds [vtkPolyData $this-polydataTemp]1158 $ds ShallowCopy $mesh1159 [$ds GetPointData] SetScalars [$dataobj values $cname]1160 }1161 vtkUnstructuredGrid {1162 # handle 3D grid with connectivity1163 set ds [vtkUnstructuredGrid $this-grdataTemp]1164 $ds ShallowCopy $mesh1165 [$ds GetPointData] SetScalars [$dataobj values $cname]1166 }1167 vtkRectilinearGrid {1168 # handle 3D grid with connectivity1169 set ds [vtkRectilinearGrid $this-grdataTemp]1170 $ds ShallowCopy $mesh1171 [$ds GetPointData] SetScalars [$dataobj values $cname]1172 }1173 default {1174 error "don't know how to handle [$mesh GetClassName] data"1175 }1176 }1177 }1178 }1179 1180 if {"" != $ds} {1181 set writer [vtkDataSetWriter $this-dsWriterTmp]1182 $writer SetInput $ds1183 $writer SetFileTypeToASCII1184 $writer WriteToOutputStringOn1185 $writer Write1186 set out [$writer GetOutputString]1187 $ds Delete1188 $writer Delete1189 } else {1190 set out ""1191 error "No DataSet to write"1192 }1193 1194 append out "\n"1195 return $out1196 1100 } 1197 1101 … … 1223 1127 set dataAttrs [$dataset GetPointData] 1224 1128 if { $dataAttrs == ""} { 1225 puts stderr "WARNING: no point data found in \"$_path\""1129 puts stderr "WARNING: No point data found in \"$_path\"" 1226 1130 rename $reader "" 1227 1131 return 0 … … 1286 1190 set dataAttrs [$dataset GetPointData] 1287 1191 if { $dataAttrs == ""} { 1288 puts stderr "WARNING: no point data found in \"$_path\""1192 puts stderr "WARNING: No point data found in \"$_path\"" 1289 1193 rename $reader "" 1290 1194 return 0 … … 1292 1196 set array [$dataAttrs GetScalars] 1293 1197 if { $array == ""} { 1294 puts stderr "WARNING: no scalar point data found in \"$_path\""1198 puts stderr "WARNING: No scalar point data found in \"$_path\"" 1295 1199 rename $reader "" 1296 1200 return 0 … … 1308 1212 set dataAttrs [$dataset GetPointData] 1309 1213 if { $dataAttrs == ""} { 1310 puts stderr "WARNING: no point data found in \"$_path\""1214 puts stderr "WARNING: No point data found in \"$_path\"" 1311 1215 rename $reader "" 1312 1216 return 0 … … 1543 1447 } 1544 1448 } 1545 1449 1546 1450 if {$_dim == 1} { 1547 1451 # 1D data: Create vectors for graph widget. … … 1648 1552 file delete $tmpfile 1649 1553 1650 set tmpfile $ this-$cname[pid].vtk1554 set tmpfile $cname[pid].vtk 1651 1555 set writer $this-datasetwriter 1652 1556 vtkDataSetWriter $writer
Note: See TracChangeset
for help on using the changeset viewer.