- Timestamp:
- Feb 13, 2014, 1:38:33 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/field.tcl
r4126 r4177 150 150 private method DicomToVtk.old { cname contents } 151 151 private method BuildPointsOnMesh { cname } 152 private method ConvertToVtkData { cname }153 152 protected method GetAssociation { cname } 154 153 protected method GetTypeAndSize { cname } … … 1119 1118 # numComponents -- 1120 1119 # 1121 # Returns ifthe number of components in the field component.1120 # Returns the number of components in the field component. 1122 1121 # 1123 1122 itcl::body Rappture::Field::numComponents {cname} { … … 1154 1153 } 1155 1154 return $_comp2extents($cname) 1156 }1157 1158 itcl::body Rappture::Field::ConvertToVtkData { cname } {1159 set ds ""1160 switch -- [typeof $cname] {1161 "unirect2d" {1162 foreach { x1 x2 xN y1 y2 yN } [$dataobj mesh $cname] break1163 set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]1164 set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]1165 1166 set ds [vtkImageData $this-grdataTemp]1167 $ds SetDimensions $xN $yN 11168 $ds SetOrigin $x1 $y1 01169 $ds SetSpacing $spacingX $spacingY 01170 set arr [vtkDoubleArray $this-arrTemp]1171 foreach {val} [$dataobj values $cname] {1172 $arr InsertNextValue $val1173 }1174 [$ds GetPointData] SetScalars $arr1175 }1176 "unirect3d" {1177 foreach { x1 x2 xN y1 y2 yN z1 z2 zN } [$dataobj mesh $cname] break1178 set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]1179 set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]1180 set spacingZ [expr {double($z2 - $z1)/double($zN - 1)}]1181 1182 set ds [vtkImageData $this-grdataTemp]1183 $ds SetDimensions $xN $yN $zN1184 $ds SetOrigin $x1 $y1 $z11185 $ds SetSpacing $spacingX $spacingY $spacingZ1186 set arr [vtkDoubleArray $this-arrTemp]1187 foreach {val} [$dataobj values $cname] {1188 $arr InsertNextValue $val1189 }1190 [$ds GetPointData] SetScalars $val1191 }1192 "contour" {1193 return [$dataobj blob $cname]1194 }1195 "dx" {1196 return [Rappture::DxToVtk $_comp2dx($cname)]1197 }1198 default {1199 set mesh [$dataobj mesh $cname]1200 switch -- [$mesh GetClassName] {1201 vtkPoints {1202 # handle cloud of points1203 set ds [vtkPolyData $this-polydataTemp]1204 $ds SetPoints $mesh1205 [$ds GetPointData] SetScalars [$dataobj values $cname]1206 }1207 vtkPolyData {1208 set ds [vtkPolyData $this-polydataTemp]1209 $ds ShallowCopy $mesh1210 [$ds GetPointData] SetScalars [$dataobj values $cname]1211 }1212 vtkUnstructuredGrid {1213 # handle 3D grid with connectivity1214 set ds [vtkUnstructuredGrid $this-grdataTemp]1215 $ds ShallowCopy $mesh1216 [$ds GetPointData] SetScalars [$dataobj values $cname]1217 }1218 vtkRectilinearGrid {1219 # handle 3D grid with connectivity1220 set ds [vtkRectilinearGrid $this-grdataTemp]1221 $ds ShallowCopy $mesh1222 [$ds GetPointData] SetScalars [$dataobj values $cname]1223 }1224 default {1225 error "don't know how to handle [$mesh GetClassName] data"1226 }1227 }1228 }1229 }1230 1231 if {"" != $ds} {1232 set writer [vtkDataSetWriter $this-dsWriterTmp]1233 $writer SetInput $ds1234 $writer SetFileTypeToASCII1235 $writer WriteToOutputStringOn1236 $writer Write1237 set out [$writer GetOutputString]1238 $ds Delete1239 $writer Delete1240 } else {1241 set out ""1242 error "No DataSet to write"1243 }1244 1245 append out "\n"1246 return $out1247 1155 } 1248 1156
Note: See TracChangeset
for help on using the changeset viewer.