Changeset 2424 for trunk/gui/apps
- Timestamp:
- Aug 27, 2011, 2:22:44 AM (13 years ago)
- Location:
- trunk/gui/apps
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/apps/vtkcontour-test
r2415 r2424 31 31 package require Rappture 32 32 package require RapptureGUI 33 package require vtk 33 34 34 35 option add *comm.font -*-courier-medium-r-normal-*-*-120-* … … 73 74 itcl::class visData { 74 75 constructor {args} { 75 set _data [lindex $args 0] 76 } 77 76 set _reader [vtkDataSetReader $this-xvtkDataSetReader] 77 $_reader SetFileName [lindex $args 0] 78 $_reader Update 79 set _data [$_reader GetOutput] 80 } 81 destructor { 82 rename _data "" 83 rename _reader "" 84 } 78 85 public method components {args} { 79 86 if {[llength $args] == 0} { … … 82 89 return "" 83 90 } 91 public method mesh {args} { 92 switch -- [$_data GetClassName] { 93 vtkPolyData { 94 if {[$_data GetNumberOfCells] > 0} { 95 return $_data 96 } else { 97 return [$_data GetPoints] 98 } 99 } 100 vtkStructuredPoints - 101 vtkUniformGrid - 102 vtkImageData { 103 foreach { x1 y1 z1 } [$_data GetOrigin] break 104 foreach { xN yN zN } [$_data GetDimensions] break 105 foreach { xS yS zS } [$_data GetSpacing] break 106 set x2 [expr {$x1 + $xN * $xS}] 107 set y2 [expr {$x1 + $yN * $yS}] 108 set z2 [expr {$x1 + $zN * $zS}] 109 if {$zN == 1} { 110 lappend out $x1 $x2 $xN $y1 $y2 $yN 111 } else { 112 lappend out $x1 $x2 $xN $y1 $y2 $yN $z1 $z2 $zN 113 } 114 return $out 115 } 116 default { 117 return $_data 118 } 119 } 120 } 121 public method isunirect2d {args} { 122 if {[$_data GetClassName] != "vtkImageData" && 123 [$_data GetClassName] != "vtkStructuredPoints" && 124 [$_data GetClassName] != "vtkUniformGrid"} { 125 return 0 126 } 127 foreach { xN yN zN } [$_data GetDimensions] break 128 if {$zN == 1} { 129 return 1 130 } else { 131 return 0 132 } 133 } 134 public method isunirect3d {args} { 135 if {[$_data GetClassName] != "vtkImageData" && 136 [$_data GetClassName] != "vtkStructuredPoints" && 137 [$_data GetClassName] != "vtkUniformGrid"} { 138 return 0 139 } 140 foreach { xN yN zN } [$_data GetDimensions] break 141 if {$zN > 1} { 142 return 1 143 } else { 144 return 0 145 } 146 } 84 147 public method data {args} { 85 return $_data148 return [values $args] 86 149 } 87 150 public method values {args} { 88 return $_data 151 set dataAttrs [$_data GetPointData] 152 if {"" == $dataAttrs} { 153 puts stderr "No point data" 154 return "" 155 } 156 set scalarArr [$dataAttrs GetScalars] 157 if {"" == $scalarArr} { 158 for {set i 0} {$i < [$dataAttrs GetNumberOfArrays]} {incr i} { 159 if {[[$dataAttrs GetArray $i] GetNumberOfComponents] == 1} { 160 $dataAttrs SetActiveScalars [$dataAttrs GetArrayName $i] 161 puts stderr "Set scalars to '[$dataAttrs GetArrayName $i]'" 162 break 163 } 164 } 165 set scalarArr [$dataAttrs GetScalars] 166 if {"" == $scalarArr} { 167 puts stderr "No scalar point data" 168 return "" 169 } 170 } 171 if {[isunirect2d] || [isunirect3d]} { 172 for {set i 0} {$i < [$scalarArr GetNumberOfTuples]} {incr i} { 173 lappend out [$scalarArr GetComponent $i 0] 174 } 175 return $out 176 } 177 return $scalarArr 178 } 179 public method limits {which} { 180 foreach { xMin xMax yMin yMax zMin zMax} [$_data GetBounds] break 181 set min "" 182 set max "" 183 184 switch -- $which { 185 x - xlin - xlog { 186 set min $xMin 187 set max $xMax 188 set axis "xaxis" 189 } 190 y - ylin - ylog { 191 set min $yMin 192 set max $yMax 193 set axis "yaxis" 194 } 195 z - zlin - zlog { 196 set min $zMin 197 set max $zMax 198 set axis "zaxis" 199 } 200 v - vlin - vlog { 201 foreach { min max } [$_data GetScalarRange] break 202 set axis "vaxis" 203 } 204 default { 205 error "unknown axis description \"$which\"" 206 } 207 } 208 return [list $min $max] 89 209 } 90 210 public method hints {args} { … … 93 213 94 214 private variable _data "" 215 private variable _reader "" 95 216 } 96 217 … … 105 226 106 227 set file [tk_getOpenFile -title "Open VTK File"] 107 if {"" != $file && [catch { 108 set fid [open $file r] 109 fconfigure $fid -translation binary 110 set info [read $fid] 111 close $fid 112 }] == 0} { 113 set obj [visData #auto $info] 228 if {"" != $file} { 229 set obj [visData #auto $file] 114 230 $widgets(vtkcontourviewer) add $obj 115 231 } … … 336 452 set widgets(vtkcontourviewer) $f.viewer 337 453 338 puts stderr [winfo class $widgets(vtkcontourviewer)]339 340 454 $f.viewer configure \ 341 455 -sendcommand show_comm \ -
trunk/gui/apps/vtkviewer-test
r2415 r2424 340 340 set widgets(vtkviewer) $f.viewer 341 341 342 puts stderr [winfo class $widgets(vtkviewer)]343 344 342 $f.viewer configure \ 345 343 -sendcommand show_comm \
Note: See TracChangeset
for help on using the changeset viewer.