Changeset 5758 for branches/1.4
- Timestamp:
- Jul 19, 2015, 12:03:30 PM (9 years ago)
- Location:
- branches/1.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4
-
branches/1.4/gui/scripts/field.tcl
r5756 r5758 1147 1147 } 1148 1148 1149 # 1150 # FIXME: Allowing a VTK file to be used as a Field <component> means 1151 # there can be multiple VTK fields with different association, type, and 1152 # number of components (array elements) within a single Rappture::Field. 1153 # This breaks the concept of the Field object since the <component>'s 1154 # <association>, <elemtype> and <elemsize> can't be set to a single 1155 # value in this case. 1156 # 1157 # Rappture needs a Dataset object with a single Mesh and multiple Fields. 1158 # 1149 1159 itcl::body Rappture::Field::ReadVtkDataSet { cname contents } { 1150 1160 package require vtk … … 1196 1206 lappend limits y [list $ymin $ymax] 1197 1207 lappend limits z [list $zmin $zmax] 1208 set vmin 0 1209 set vmax 1 1210 set foundDefaultArray 0 1198 1211 set dataAttrs [$dataset GetPointData] 1199 1212 if { $dataAttrs == ""} { 1200 puts stderr " WARNING: No point data foundin \"$_path\""1213 puts stderr "ERROR: Can't get point data attributes in \"$_path\"" 1201 1214 rename $reader "" 1202 1215 return 0 1203 1216 } 1204 set vmin 01205 set vmax 11206 1217 set numArrays [$dataAttrs GetNumberOfArrays] 1207 if { $numArrays > 0 } { 1208 for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} { 1209 set array [$dataAttrs GetArray $i] 1210 set fname [$dataAttrs GetArrayName $i] 1211 foreach {min max} [$array GetRange -1] break 1212 if {$i == 0} { 1213 set vmin $min 1214 set vmax $max 1215 } 1218 for {set i 0} {$i < $numArrays} {incr i} { 1219 set array [$dataAttrs GetArray $i] 1220 set fname [$dataAttrs GetArrayName $i] 1221 foreach {min max} [$array GetRange -1] break 1222 if {!$foundDefaultArray} { 1223 set vmin $min 1224 set vmax $max 1225 set foundDefaultArray 1 1226 } 1227 lappend limits $fname [list $min $max] 1228 set _fld2Units($fname) "" 1229 set _fld2Label($fname) $fname 1230 # Let the VTK file override the <elemsize> 1231 set _fld2Components($fname) [$array GetNumberOfComponents] 1232 lappend _comp2fldName($cname) $fname 1233 } 1234 # FIXME: Can't properly handle field names that are re-used in point data 1235 # cell data and/or field data even though this is permitted in VTK. 1236 # For now, we'll use the first field found of point, cell, then field data 1237 set dataAttrs [$dataset GetCellData] 1238 if { $dataAttrs == ""} { 1239 puts stderr "ERROR: Can't get cell data attributes found in \"$_path\"" 1240 rename $reader "" 1241 return 0 1242 } 1243 set numArrays [$dataAttrs GetNumberOfArrays] 1244 for {set i 0} {$i < $numArrays} {incr i} { 1245 set array [$dataAttrs GetArray $i] 1246 set fname [$dataAttrs GetArrayName $i] 1247 foreach {min max} [$array GetRange -1] break 1248 if {!$foundDefaultArray} { 1249 set vmin $min 1250 set vmax $max 1251 set foundDefaultArray 1 1252 } 1253 if {[info exists _fld2Components($fname)]} { 1254 puts stderr "WARNING: Re-use of field name within cell data attributes" 1255 } else { 1216 1256 lappend limits $fname [list $min $max] 1217 1257 set _fld2Units($fname) "" 1218 1258 set _fld2Label($fname) $fname 1219 # Let the VTK file override the < type> designated.1259 # Let the VTK file override the <elemsize> 1220 1260 set _fld2Components($fname) [$array GetNumberOfComponents] 1221 1261 lappend _comp2fldName($cname) $fname 1222 1262 } 1223 1263 } 1224 1264 set dataAttrs [$dataset GetFieldData] 1265 if { $dataAttrs == ""} { 1266 puts stderr "ERROR: Can't get field data attributes found in \"$_path\"" 1267 rename $reader "" 1268 return 0 1269 } 1270 set numArrays [$dataAttrs GetNumberOfArrays] 1271 for {set i 0} {$i < $numArrays} {incr i} { 1272 set array [$dataAttrs GetArray $i] 1273 set fname [$dataAttrs GetArrayName $i] 1274 foreach {min max} [$array GetRange -1] break 1275 if {!$foundDefaultArray} { 1276 set vmin $min 1277 set vmax $max 1278 set foundDefaultArray 1 1279 } 1280 if {[info exists _fld2Components($fname)]} { 1281 puts stderr "WARNING: Re-use of field name within field data attributes" 1282 } else { 1283 lappend limits $fname [list $min $max] 1284 set _fld2Units($fname) "" 1285 set _fld2Label($fname) $fname 1286 # Let the VTK file override the <elemsize> 1287 set _fld2Components($fname) [$array GetNumberOfComponents] 1288 lappend _comp2fldName($cname) $fname 1289 } 1290 } 1291 # This is set to the range of the first array found 1225 1292 lappend limits v [list $vmin $vmax] 1226 1293 set _comp2limits($cname) $limits
Note: See TracChangeset
for help on using the changeset viewer.