Changeset 4474 for branches/1.3
- Timestamp:
- Jul 9, 2014, 8:33:55 PM (10 years ago)
- Location:
- branches/1.3
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
- Property svn:mergeinfo changed
/trunk merged: 3917,3921-3923,3934,3996,4021,4030,4133,4136-4138,4140,4189,4250,4259,4395,4401,4442
- Property svn:mergeinfo changed
-
branches/1.3/gui/scripts/Makefile.in
r3684 r4474 133 133 $(srcdir)/vtkglyphviewer.tcl \ 134 134 $(srcdir)/vtkisosurfaceviewer.tcl \ 135 $(srcdir)/vtkmeshviewer.tcl \ 135 136 $(srcdir)/vtkstreamlinesviewer.tcl \ 136 137 $(srcdir)/vtkvolumeviewer.tcl \ -
branches/1.3/gui/scripts/cloud.tcl
r3571 r4474 20 20 private variable _xmlobj ""; # ref to XML obj with device data 21 21 private variable _cloud ""; # lib obj representing this cloud 22 private variable _units "m m m" ; # system of units for x, y, z 22 private variable _units "" ; # system of units for x, y, z 23 private variable _axis2label; # 24 private variable _axis2units; # 23 25 private variable _limits; # limits x, y, z 24 26 private common _xp2obj ; # Used for fetch/release ref counting … … 38 40 public method points {} 39 41 public method mesh {} 42 public method units { axis } 43 public method label { axis } 40 44 public method vtkdata {} 41 45 public method size {} … … 110 114 set _cloud [$xmlobj element -as object $path] 111 115 112 set u [$_cloud get units] 113 if {"" != $u} { 114 while {[llength $u] < 3} { 115 lappend u [lindex $u end] 116 } 117 set _units $u 116 set _units [$_cloud get units] 117 set first [lindex $_units 0] 118 set list {} 119 foreach u $_units axis { x y z } { 120 if { $u != "" } { 121 set _axis2units($axis) $u 122 } else { 123 set _axis2units($axis) $first 124 } 125 lappend list $_axis2units($axis) 126 } 127 set _units $list 128 foreach label [$_cloud get labels] axis { x y z } { 129 if { $label != "" } { 130 set _axis2label($axis) $label 131 } else { 132 set _axis2label($axis) [string toupper $axis] 133 } 118 134 } 119 135 … … 125 141 } 126 142 127 set _dim [llength $line]128 143 # make sure we have x,y,z 129 144 while {[llength $line] < 3} { … … 135 150 foreach axis {x y z} units $_units { 136 151 set value [Rappture::Units::convert [set $axis] \ 137 -context $units -to $units -units off] 138 152 -context $units -to $units -units off] 139 153 set $axis $value; # Set the (x/y/z) coordinate to 140 154 # converted value. … … 162 176 return 163 177 } 164 # Check each axis to verify that data exists178 set _dim 0 165 179 foreach { xmin xmax } $_limits(x) break 166 if { $xmin >= $xmax } { 167 return 168 } 169 if { $_dim > 1 } { 170 foreach { ymin ymax } $_limits(y) break 171 if { $ymin >= $ymax } { 172 return 173 } 174 } 175 if { $_dim > 2 } { 176 foreach { zmin zmax } $_limits(z) break 177 if { $zmin >= $zmax } { 178 return 179 } 180 if { $xmax > $xmin } { 181 incr _dim 182 } 183 foreach { ymin ymax } $_limits(y) break 184 if { $ymax > $ymin } { 185 incr _dim 186 } 187 foreach { zmin zmax } $_limits(z) break 188 if { $zmax > $zmin } { 189 incr _dim 180 190 } 181 191 set _isValid 1 … … 236 246 } 237 247 return $_limits($axis) 248 } 249 250 # 251 # units -- 252 # 253 # Returns the units of the given axis. 254 # 255 itcl::body Rappture::Cloud::units { axis } { 256 if { ![info exists _axis2units($axis)] } { 257 return "" 258 } 259 return $_axis2units($axis) 260 } 261 262 # 263 # label -- 264 # 265 # Returns the label of the given axis. 266 # 267 itcl::body Rappture::Cloud::label { axis } { 268 if { ![info exists _axis2label($axis)] } { 269 return "" 270 } 271 return $_axis2label($axis) 238 272 } 239 273 -
branches/1.3/gui/scripts/field.tcl
r4473 r4474 154 154 protected method GetTypeAndSize { cname } 155 155 protected method ReadVtkDataSet { cname contents } 156 private method InitHints {} 156 157 157 158 private method VerifyVtkDataSet { contents } … … 201 202 # build up vectors for various components of the field 202 203 Build 204 InitHints 203 205 } 204 206 … … 651 653 # ---------------------------------------------------------------------- 652 654 itcl::body Rappture::Field::hints {{keyword ""}} { 653 if { ![info exists _hints] } {654 foreach {key path} {655 camera camera.position656 color about.color657 default about.default658 group about.group659 label about.label660 scale about.scale661 seeds about.seeds662 style about.style663 type about.type664 xlabel about.xaxis.label665 ylabel about.yaxis.label666 zlabel about.zaxis.label667 xunits about.xaxis.units668 yunits about.yaxis.units669 zunits about.zaxis.units670 units units671 updir updir672 vectors about.vectors673 } {674 set str [$_field get $path]675 if { "" != $str } {676 set _hints($key) $str677 }678 }679 foreach {key path} {680 toolid tool.id681 toolname tool.name682 toolcommand tool.execute683 tooltitle tool.title684 toolrevision tool.version.application.revision685 } {686 set str [$_xmlobj get $path]687 if { "" != $str } {688 set _hints($key) $str689 }690 }691 # Set toolip and path hints692 set _hints(path) $_path693 if { [info exists _hints(group)] && [info exists _hints(label)] } {694 # pop-up help for each curve695 set _hints(tooltip) $_hints(label)696 }697 }698 655 if { $keyword != "" } { 699 656 if {[info exists _hints($keyword)]} { … … 703 660 } 704 661 return [array get _hints] 662 } 663 664 665 # ---------------------------------------------------------------------- 666 # USAGE: InitHints 667 # 668 # Returns a list of key/value pairs for various hints about plotting 669 # this field. If a particular <keyword> is specified, then it returns 670 # the hint for that <keyword>, if it exists. 671 # ---------------------------------------------------------------------- 672 itcl::body Rappture::Field::InitHints {} { 673 foreach {key path} { 674 camera camera.position 675 color about.color 676 default about.default 677 group about.group 678 label about.label 679 scale about.scale 680 seeds about.seeds 681 style about.style 682 type about.type 683 xlabel about.xaxis.label 684 ylabel about.yaxis.label 685 zlabel about.zaxis.label 686 xunits about.xaxis.units 687 yunits about.yaxis.units 688 zunits about.zaxis.units 689 units units 690 updir updir 691 vectors about.vectors 692 } { 693 set str [$_field get $path] 694 if { "" != $str } { 695 set _hints($key) $str 696 } 697 } 698 foreach cname [components] { 699 if { ![info exists _comp2mesh($cname)] } { 700 continue 701 } 702 set mesh [lindex $_comp2mesh($cname) 0] 703 foreach axis {x y z} { 704 if { ![info exists _hints(${axis}units)] } { 705 set _hints(${axis}units) [$mesh units $axis] 706 } 707 if { ![info exists _hints(${axis}label)] } { 708 set _hints(${axis}label) [$mesh label $axis] 709 } 710 } 711 } 712 foreach {key path} { 713 toolid tool.id 714 toolname tool.name 715 toolcommand tool.execute 716 tooltitle tool.title 717 toolrevision tool.version.application.revision 718 } { 719 set str [$_xmlobj get $path] 720 if { "" != $str } { 721 set _hints($key) $str 722 } 723 } 724 # Set toolip and path hints 725 set _hints(path) $_path 726 if { [info exists _hints(group)] && [info exists _hints(label)] } { 727 # pop-up help for each curve 728 set _hints(tooltip) $_hints(label) 729 } 705 730 } 706 731 … … 1403 1428 set _values [$_field get $cname.values] 1404 1429 set limits {} 1405 foreach axis { x y } {1430 foreach axis { x y z } { 1406 1431 lappend limits $axis [$_comp2unirect2d($cname) limits $axis] 1407 1432 } … … 1510 1535 incr _counter 1511 1536 array unset _comp2limits $cname 1512 lappend _comp2limits($cname) x [$mesh limits x] 1513 lappend _comp2limits($cname) y [$mesh limits y] 1537 foreach axis { x y z } { 1538 lappend _comp2limits($cname) $axis [$mesh limits $axis] 1539 } 1514 1540 lappend _comp2limits($cname) $cname [$v limits] 1515 1541 lappend _comp2limits($cname) v [$v limits] … … 1551 1577 set _comp2style($cname) [$_field get $cname.style] 1552 1578 incr _counter 1553 lappend _comp2limits($cname) x [$mesh limits x]1554 lappend _comp2limits($cname) y [$mesh limits y]1555 lappend _comp2limits($cname) z [$mesh limits z]1579 foreach axis { x y z } { 1580 lappend _comp2limits($cname) $axis [$mesh limits $axis] 1581 } 1556 1582 lappend _comp2limits($cname) $cname [$v limits] 1557 1583 lappend _comp2limits($cname) v [$v limits] -
branches/1.3/gui/scripts/mesh.tcl
r4472 r4474 27 27 private variable _dim 0; # Dimension of mesh (1, 2, or 3) 28 28 private variable _type ""; # Indicates the type of mesh. 29 private variable _units "m m m" ; # System of units for x, y, z 29 private variable _axis2units; # System of units for x, y, z 30 private variable _axis2labels; # 31 private variable _hints 30 32 private variable _limits ; # Array of mesh limits. Keys are 31 33 # xmin, xmax, ymin, ymax, ... … … 46 48 public method dimensions {} 47 49 public method limits {which} 50 public method units { axis } 51 public method label { axis } 48 52 public method hints {{key ""}} 49 53 public method isvalid {} { … … 52 56 public proc fetch {xmlobj path} 53 57 public proc release {obj} 54 public method vtkdata { }58 public method vtkdata {{what -partial}} 55 59 public method type {} { 56 60 return $_type … … 59 63 return $_numPoints 60 64 } 61 65 public method numcells {} { 66 return $_numCells 67 } 62 68 63 69 private common _xp2obj ; # used for fetch/release ref counting … … 73 79 private method GetDouble { path } 74 80 private method GetInt { path } 81 private method InitHints {} 75 82 private method ReadGrid { path } 76 83 private method ReadUnstructuredGrid { path } … … 149 156 set _limits($axis) "" 150 157 } 151 set u [$_mesh get units] 152 if {"" != $u} { 153 while {[llength $u] < 3} { 154 lappend u [lindex $u end] 155 } 156 set _units $u 158 set units [$_mesh get units] 159 set first [lindex $units 0] 160 foreach u $units axis { x y z } { 161 if { $u != "" } { 162 set _axis2units($axis) $u 163 } else { 164 set _axis2units($axis) $first 165 } 166 } 167 foreach label [$_mesh get labels] axis { x y z } { 168 if { $label != "" } { 169 set _axis2labels($axis) $label 170 } else { 171 set _axis2labels($axis) [string toupper $axis] 172 } 157 173 } 158 174 … … 200 216 } 201 217 set _isValid $result 218 InitHints 202 219 } 203 220 … … 226 243 # arrays before generating output to send to the remote render server. 227 244 # 228 itcl::body Rappture::Mesh::vtkdata {} { 229 return $_vtkdata 245 itcl::body Rappture::Mesh::vtkdata {{what -partial}} { 246 if {$what == "-full"} { 247 append out "# vtk DataFile Version 3.0\n" 248 append out "[hints label]\n" 249 append out "ASCII\n" 250 append out $_vtkdata 251 return $out 252 } else { 253 return $_vtkdata 254 } 230 255 } 231 256 … … 237 262 itcl::body Rappture::Mesh::points {} { 238 263 return "" 264 } 265 266 # 267 # units -- 268 # 269 # Returns the units of the given axis. 270 # 271 itcl::body Rappture::Mesh::units { axis } { 272 if { ![info exists _axis2units($axis)] } { 273 return "" 274 } 275 return $_axis2units($axis) 276 } 277 278 # 279 # label -- 280 # 281 # Returns the label of the given axis. 282 # 283 itcl::body Rappture::Mesh::label { axis } { 284 if { ![info exists _axis2labels($axis)] } { 285 return "" 286 } 287 return $_axis2labels($axis) 239 288 } 240 289 … … 344 393 # ---------------------------------------------------------------------- 345 394 itcl::body Rappture::Mesh::hints {{keyword ""}} { 346 foreach key {label color units} { 347 set str [$_mesh get $key] 395 if {$keyword != ""} { 396 if {[info exists _hints($keyword)]} { 397 return $_hints($keyword) 398 } 399 return "" 400 } 401 return [array get _hints] 402 } 403 404 # ---------------------------------------------------------------------- 405 # USAGE: InitHints 406 # 407 # Returns a list of key/value pairs for various hints about plotting 408 # this mesh. If a particular <keyword> is specified, then it returns 409 # the hint for that <keyword>, if it exists. 410 # ---------------------------------------------------------------------- 411 itcl::body Rappture::Mesh::InitHints {} { 412 foreach {key path} { 413 camera camera.position 414 color about.color 415 label about.label 416 style about.style 417 units units 418 } { 419 set str [$_mesh get $path] 348 420 if {"" != $str} { 349 set hints($key) $str 350 } 351 } 352 353 if {$keyword != ""} { 354 if {[info exists hints($keyword)]} { 355 return $hints($keyword) 356 } 357 return "" 358 } 359 return [array get hints] 421 set _hints($key) $str 422 } 423 } 360 424 } 361 425 … … 367 431 } 368 432 if { [scan $string "%d" _dim] == 1 } { 369 if { $_dim == 2 || $_dim == 3 } {433 if { $_dim == 1 || $_dim == 2 || $_dim == 3 } { 370 434 return 1 371 435 } 372 436 } 373 puts stderr "WARNING: bad <dim> tag value \"$string\": should be 2 or 3."437 puts stderr "WARNING: bad <dim> tag value \"$string\": should be 1, 2 or 3." 374 438 return 0 375 439 } … … 471 535 return 0 472 536 } 473 if { $numCurvilinear < 2 } {474 puts stderr "WARNING: bad grid \"$path\": curvilinear grid must be 2D or 3D."475 return 0476 }477 537 set points [$_xmlobj get $path.grid.points] 478 538 if { $points == "" } { … … 480 540 return 0 481 541 } 482 if { ![info exists xNum] || ![info exists yNum]} {483 puts stderr "WARNING: bad grid \"$path\": invalid dimensions for curvilinear grid: missing <xdim> or <ydim>from grid description."542 if { ![info exists xNum] } { 543 puts stderr "WARNING: bad grid \"$path\": invalid dimensions for curvilinear grid: missing <xdim> from grid description." 484 544 return 0 485 545 } … … 493 553 set _dim 3 494 554 set _numPoints [expr $xNum * $yNum * $zNum] 555 set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)] 495 556 if { ($_numPoints*3) != $numCoords } { 496 puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> "557 puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>" 497 558 return 0 498 559 } … … 512 573 append out "\n" 513 574 set _vtkdata $out 514 } else {575 } elseif { [info exists yNum] } { 515 576 set _dim 2 516 577 set _numPoints [expr $xNum * $yNum] 578 set _numCells [expr ($xNum - 1) * ($yNum - 1)] 517 579 if { ($_numPoints*2) != $numCoords } { 518 puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim> * <zdim>"580 puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>" 519 581 return 0 520 582 } … … 527 589 set _limits($axis) [$vector limits] 528 590 } 591 set _limits(z) [list 0 0] 529 592 $zv seq 0 0 [$xv length] 530 593 $all merge $xv $yv $zv … … 535 598 append out "\n" 536 599 set _vtkdata $out 600 } else { 601 set _dim 1 602 set _numPoints $xNum 603 set _numCells [expr $xNum - 1] 604 if { $_numPoints != $numCoords } { 605 puts stderr "WARNING: bad grid \"$path\": \# of points does not match <xdim>" 606 return 0 607 } 608 set _limits(x) [$xv limits] 609 set _limits(y) [list 0 0] 610 set _limits(z) [list 0 0] 611 $yv seq 0 0 [$xv length] 612 $zv seq 0 0 [$xv length] 613 $all merge $xv $yv $zv 614 append out "DATASET STRUCTURED_GRID\n" 615 append out "DIMENSIONS $xNum 1 1\n" 616 append out "POINTS $_numPoints double\n" 617 append out [$all range 0 end] 618 append out "\n" 619 set _vtkdata $out 537 620 } 538 621 blt::vector destroy $all $xv $yv $zv … … 541 624 if { $numRectilinear == 0 && $numUniform > 0} { 542 625 # This is the special case where all axes 2D/3D are uniform. 543 # This results in a STRUCTURE_POINTS 544 if { $_dim == 2 } { 626 # This results in a STRUCTURED_POINTS 627 if { $_dim == 1 } { 628 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 629 set _numPoints $xNum 630 set _numCells [expr $xNum - 1] 631 append out "DATASET STRUCTURED_POINTS\n" 632 append out "DIMENSIONS $xNum 1 1\n" 633 append out "ORIGIN $xMin 0 0\n" 634 append out "SPACING $xSpace 0 0\n" 635 set _vtkdata $out 636 set _limits(x) [list $xMin $xMax] 637 set _limits(y) [list 0 0] 638 set _limits(z) [list 0 0] 639 } elseif { $_dim == 2 } { 545 640 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 546 641 set ySpace [expr ($yMax - $yMin) / double($yNum - 1)] 547 642 set _numPoints [expr $xNum * $yNum] 643 set _numCells [expr ($xNum - 1) * ($yNum - 1)] 548 644 append out "DATASET STRUCTURED_POINTS\n" 549 645 append out "DIMENSIONS $xNum $yNum 1\n" … … 554 650 set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]] 555 651 } 652 set _limits(z) [list 0 0] 556 653 } elseif { $_dim == 3 } { 557 654 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] … … 559 656 set zSpace [expr ($zMax - $zMin) / double($zNum - 1)] 560 657 set _numPoints [expr $xNum * $yNum * $zNum] 658 set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)] 561 659 append out "DATASET STRUCTURED_POINTS\n" 562 660 append out "DIMENSIONS $xNum $yNum $zNum\n" … … 584 682 } 585 683 set yv [blt::vector create \#auto] 586 if { [info exists yMin] } { 587 $yv seq $yMin $yMax $yNum 684 if { $_dim > 1 } { 685 if { [info exists yMin] } { 686 $yv seq $yMin $yMax $yNum 687 } else { 688 $yv set [$_xmlobj get $path.grid.ycoords] 689 set yMin [$yv min] 690 set yMax [$yv max] 691 set yNum [$yv length] 692 } 588 693 } else { 589 $yv set [$_xmlobj get $path.grid.ycoords] 590 set yMin [$yv min] 591 set yMax [$yv max] 592 set yNum [$yv length] 694 set yNum 1 593 695 } 594 696 set zv [blt::vector create \#auto] … … 607 709 if { $_dim == 3 } { 608 710 set _numPoints [expr $xNum * $yNum * $zNum] 711 set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)] 609 712 append out "DATASET RECTILINEAR_GRID\n" 610 713 append out "DIMENSIONS $xNum $yNum $zNum\n" … … 626 729 } elseif { $_dim == 2 } { 627 730 set _numPoints [expr $xNum * $yNum] 731 set _numCells [expr ($xNum - 1) * ($yNum - 1)] 628 732 append out "DATASET RECTILINEAR_GRID\n" 629 733 append out "DIMENSIONS $xNum $yNum 1\n" … … 641 745 } 642 746 } 747 set _limits(z) [list 0 0] 748 set _vtkdata $out 749 } elseif { $_dim == 1 } { 750 set _numPoints $xNum 751 set _numCells [expr $xNum - 1] 752 append out "DATASET RECTILINEAR_GRID\n" 753 append out "DIMENSIONS $xNum 1 1\n" 754 append out "X_COORDINATES $xNum double\n" 755 append out [$xv range 0 end] 756 append out "\n" 757 append out "Y_COORDINATES 1 double\n" 758 append out "0\n" 759 append out "Z_COORDINATES 1 double\n" 760 append out "0\n" 761 if { [info exists xMin] } { 762 set _limits(x) [list $xMin $xMax] 763 } 764 set _limits(y) [list 0 0] 765 set _limits(z) [list 0 0] 643 766 set _vtkdata $out 644 767 } else { … … 660 783 set _vtkdata $out 661 784 set _limits(x) [$xv limits] 662 set _limits(y) [$yv limits] 785 if { $_dim > 1 } { 786 set _limits(y) [$yv limits] 787 } else { 788 set _limits(y) [list 0 0] 789 } 663 790 if { $_dim == 3 } { 664 791 set _limits(z) [$zv limits] 792 } else { 793 set _limits(z) [list 0 0] 665 794 } 666 795 return 1 … … 692 821 if { $_dim == 3 } { 693 822 set _limits(z) [$zv limits] 823 } else { 824 set _limits(z) [list 0 0] 694 825 } 695 826 set _vtkdata $out … … 722 853 if { $_dim == 3 } { 723 854 set _limits(z) [$zv limits] 855 } else { 856 set _limits(z) [list 0 0] 724 857 } 725 858 set _vtkdata $out … … 750 883 set _limits(x) [$xv limits] 751 884 set _limits(y) [$yv limits] 752 if { $_dim == 3 } { 753 set _limits(z) [$zv limits] 754 } 885 set _limits(z) [$zv limits] 886 755 887 set _vtkdata $out 756 888 return 1 … … 780 912 set _limits(x) [$xv limits] 781 913 set _limits(y) [$yv limits] 782 if { $_dim == 3 } { 783 set _limits(z) [$zv limits] 784 } 914 set _limits(z) [$zv limits] 915 785 916 set _vtkdata $out 786 917 return 1 … … 810 941 set _limits(x) [$xv limits] 811 942 set _limits(y) [$yv limits] 812 if { $_dim == 3 } { 813 set _limits(z) [$zv limits] 814 } 943 set _limits(z) [$zv limits] 944 815 945 set _vtkdata $out 816 946 return 1 … … 840 970 set _limits(x) [$xv limits] 841 971 set _limits(y) [$yv limits] 842 if { $_dim == 3 } { 843 set _limits(z) [$zv limits] 844 } 972 set _limits(z) [$zv limits] 973 845 974 set _vtkdata $out 846 975 return 1 … … 854 983 set celltype [GetCellType $celltypes] 855 984 } 856 if { $_dim == 2 } { 857 set _numPoints [$xv length] 858 set data {} 859 set count 0 860 set _numCells 0 861 set celltypes {} 862 foreach line $lines { 863 set length [llength $line] 864 if { $length == 0 } { 865 continue 866 } 867 if { $numCellTypes > 1 } { 868 set cellType [GetCellType [lindex $cellTypes $_numCells]] 869 } 870 set numIndices [GetNumIndices $celltype] 871 if { $numIndices > 0 && $numIndices != $length } { 872 puts stderr "WARNING: bad unstructured grid \"$path\": wrong \# of indices specified for celltype $celltype on line \"$line\"" 873 return 0 874 } 875 append data " $numIndices $line\n" 876 lappend celltypes $celltype 877 incr count $length; # Include the indices 878 incr count; # and the number of indices 879 incr _numCells 880 } 881 append out "DATASET UNSTRUCTURED_GRID\n" 882 append out "POINTS $_numPoints double\n" 883 set all [blt::vector create \#auto] 884 $all merge $xv $yv $zv 885 append out [$all range 0 end] 886 blt::vector destroy $all 887 append out "CELLS $_numCells $count\n" 888 append out $data 889 append out "CELL_TYPES $_numCells\n" 890 append out $celltypes 891 set _limits(x) [$xv limits] 892 set _limits(y) [$yv limits] 985 986 set _numPoints [$xv length] 987 set data {} 988 set count 0 989 set _numCells 0 990 set celltypes {} 991 foreach line $lines { 992 set length [llength $line] 993 if { $length == 0 } { 994 continue 995 } 996 if { $numCellTypes > 1 } { 997 set cellType [GetCellType [lindex $cellTypes $_numCells]] 998 } 999 set numIndices [GetNumIndices $celltype] 1000 if { $numIndices > 0 && $numIndices != $length } { 1001 puts stderr "WARNING: bad unstructured grid \"$path\": wrong \# of indices specified for celltype $celltype on line \"$line\"" 1002 return 0 1003 } else { 1004 set numIndices $length 1005 } 1006 append data " $numIndices $line\n" 1007 lappend celltypes $celltype 1008 incr count $length; # Include the indices 1009 incr count; # and the number of indices 1010 incr _numCells 1011 } 1012 append out "DATASET UNSTRUCTURED_GRID\n" 1013 append out "POINTS $_numPoints double\n" 1014 set all [blt::vector create \#auto] 1015 $all merge $xv $yv $zv 1016 append out [$all range 0 end] 1017 blt::vector destroy $all 1018 append out "CELLS $_numCells $count\n" 1019 append out $data 1020 append out "CELL_TYPES $_numCells\n" 1021 append out $celltypes 1022 set _limits(x) [$xv limits] 1023 set _limits(y) [$yv limits] 1024 if { $_dim < 3 } { 1025 set _limits(z) [list 0 0] 893 1026 } else { 894 set _numPoints [$xv length] 895 896 set data {} 897 set count 0 898 set _numCells 0 899 foreach line $lines { 900 set length [llength $line] 901 if { $length == 0 } { 902 continue 903 } 904 if { $numCellTypes > 1 } { 905 set cellType [GetCellType [lindex $cellTypes $_numCells]] 906 } 907 set numIndices [GetNumIndices $celltype] 908 if { $numIndices > 0 && $numIndices != $length } { 909 puts stderr "WARNING: bad unstructured grid \"$path\": wrong \# of indices specified for celltype $celltype on line \"$line\"" 910 return 0 911 } 912 append data " $length $line\n" 913 incr count $length 914 incr count 915 incr _numCells 916 } 917 append out "DATASET UNSTRUCTURED_GRID\n" 918 append out "POINTS $_numPoints double\n" 919 set all [blt::vector create \#auto] 920 $all merge $xv $yv $zv 921 append out [$all range 0 end] 922 blt::vector destroy $all 923 append out "\n" 924 append out "CELLS $_numCells $count\n" 925 append out $data 926 append out "CELL_TYPES $_numCells\n" 927 append out $celltypes 928 set _limits(x) [$xv limits] 929 set _limits(y) [$yv limits] 930 set _limits(z) [$zv limits] 931 } 1027 set _limits(z) [$zv limits] 1028 } 1029 932 1030 set _vtkdata $out 933 1031 return 1 … … 969 1067 # <xcoords>, <ycoords>, <zcoords>. Split and convert into 970 1068 # 3 vectors, one for each coordinate. 971 if { $_dim == 2 } { 1069 if { $_dim == 1 } { 1070 set xcoords [$_xmlobj get $path.unstructured.xcoords] 1071 set ycoords [$_xmlobj get $path.unstructured.ycoords] 1072 set zcoords [$_xmlobj get $path.unstructured.zcoords] 1073 set data [$_xmlobj get $path.unstructured.points] 1074 if { $ycoords != "" } { 1075 put stderr "can't specify <ycoords> with a 1D mesh" 1076 return 0 1077 } 1078 if { $zcoords != "" } { 1079 put stderr "can't specify <zcoords> with a 1D mesh" 1080 return 0 1081 } 1082 if { $xcoords != "" } { 1083 set xv [blt::vector create \#auto] 1084 $xv set $xcoords 1085 } elseif { $data != "" } { 1086 Rappture::ReadPoints $data dim points 1087 if { $points == "" } { 1088 puts stderr "WARNING: bad unstructured grid \"$path\": no <points> found." 1089 return 0 1090 } 1091 if { $dim != 1 } { 1092 puts stderr "WARNING: bad unstructured grid \"$path\": \# of coordinates per point is \"$dim\": does not agree with dimension specified for mesh \"$_dim\"" 1093 return 0 1094 } 1095 set xv [blt::vector create \#auto] 1096 $xv set $points 1097 } else { 1098 puts stderr "WARNING: bad unstructured grid \"$path\": no points specified." 1099 return 0 1100 } 1101 set yv [blt::vector create \#auto] 1102 set zv [blt::vector create \#auto] 1103 $yv seq 0 0 [$xv length]; # Make an all zeroes vector. 1104 $zv seq 0 0 [$xv length]; # Make an all zeroes vector. 1105 } elseif { $_dim == 2 } { 972 1106 set xcoords [$_xmlobj get $path.unstructured.xcoords] 973 1107 set ycoords [$_xmlobj get $path.unstructured.ycoords] … … 1072 1206 # ---------------------------------------------------------------------- 1073 1207 itcl::body Rappture::Mesh::ReadNodesElements {path} { 1074 set type "nodeselements"1208 set _type "nodeselements" 1075 1209 set count 0 1076 1210 … … 1091 1225 set _limits(x) [$xv limits] 1092 1226 set _limits(y) [$yv limits] 1227 set _limits(z) [list 0 0] 1093 1228 # 2D Dataset. All Z coordinates are 0 1094 1229 $zv seq 0.0 0.0 $_numPoints -
branches/1.3/gui/scripts/resultviewer.tcl
r4254 r4474 346 346 return; # Ignore invalid mesh objects. 347 347 } 348 switch -- [$dataobj dimensions] { 349 2 { 350 set mode "mesh" 351 if {![info exists _mode2widget($mode)]} { 352 set w $itk_interior.mesh 353 Rappture::MeshResult $w 354 set _mode2widget($mode) $w 355 } 356 } 357 default { 358 error "can't handle [$dataobj dimensions]D field" 359 } 348 set mode "vtkmeshviewer" 349 if {![info exists _mode2widget($mode)]} { 350 set servers [Rappture::VisViewer::GetServerList "vtkvis"] 351 set w $itk_interior.$mode 352 Rappture::VtkMeshViewer $w $servers 353 set _mode2widget($mode) $w 360 354 } 361 355 } -
branches/1.3/gui/scripts/unirect2d.tcl
r3571 r4474 35 35 private variable _isValid 0; # Indicates if the data is valid. 36 36 37 private method GetString { obj path varName } 38 private method GetValue { obj path varName } 39 private method GetSize { obj path varName } 40 37 41 constructor {xmlobj path} { 38 42 # defined below … … 44 48 public proc release {obj} 45 49 public method limits {axis} 50 public method units { axis } 51 public method label { axis } 46 52 public method blob {} 47 53 public method hints {{keyword ""}} … … 59 65 return $_vtkdata 60 66 } 61 62 private method GetString { obj path varName }63 private method GetValue { obj path varName }64 private method GetSize { obj path varName }65 66 67 } 67 68 … … 88 89 89 90 # ---------------------------------------------------------------------- 90 # USAGE: Rappture:: Mesh::release <obj>91 # USAGE: Rappture::Unirect2d::release <obj> 91 92 # 92 93 # Clients call this when they're no longer using a Mesh fetched … … 210 211 set min $_xMin 211 212 set max $_xMax 212 set axis "xaxis"213 213 } 214 214 y - ylin - ylog { 215 215 set min $_yMin 216 216 set max $_yMax 217 set axis "yaxis" 217 } 218 z - zlin - zlog { 219 set min 0 220 set max 0 218 221 } 219 222 default { … … 224 227 } 225 228 229 # 230 # units -- 231 # 232 # Returns the units of the given axis. 233 # 234 itcl::body Rappture::Unirect2d::units { axis } { 235 if { [info exists _hints(${axis}units)] } { 236 return $_hints(${axis}units) 237 } 238 return "" 239 } 240 241 # 242 # label -- 243 # 244 # Returns the label of the given axis. 245 # 246 itcl::body Rappture::Unirect2d::label { axis } { 247 if { [info exists _hints(${axis}label)] } { 248 return $_hints(${axis}label) 249 } 250 return "" 251 } 226 252 227 253 # ---------------------------------------------------------------------- … … 241 267 set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))" 242 268 } 243 244 269 if {[info exists _hints(group)] && [info exists _hints(label)]} { 245 270 # pop-up help for each curve … … 254 279 return [array get _hints] 255 280 } 256 257 281 258 282 itcl::body Rappture::Unirect2d::GetSize { obj path varName } { -
branches/1.3/gui/scripts/unirect3d.tcl
r3330 r4474 27 27 public method mesh {} 28 28 public method values {} 29 public method units { axis } 30 public method label { axis } 29 31 public method hints {{keyword ""}} 30 32 public method order {} { … … 187 189 set min $_xMin 188 190 set max $_xMax 189 set axis "xaxis"190 191 } 191 192 y - ylin - ylog { 192 193 set min $_yMin 193 194 set max $_yMax 194 set axis "yaxis"195 195 } 196 196 z - zlin - zlog { 197 197 set min $_zMin 198 198 set max $_zMax 199 set axis "zaxis"200 199 } 201 200 v - vlin - vlog { … … 207 206 set max 1.0 208 207 } 209 set axis "vaxis"210 208 } 211 209 default { … … 216 214 } 217 215 216 # 217 # units -- 218 # 219 # Returns the units of the given axis. 220 # 221 itcl::body Rappture::Unirect3d::units { axis } { 222 if { [info exists _hints({$axis}units)] } { 223 return $_hints(${axis}units) 224 } 225 return "" 226 } 227 228 # 229 # label -- 230 # 231 # Returns the label of the given axis. 232 # 233 itcl::body Rappture::Unirect3d::label { axis } { 234 if { [info exists _hints({$axis}label)] } { 235 return $_hints(${axis}label) 236 } 237 return "" 238 } 218 239 219 240 # ---------------------------------------------------------------------- -
branches/1.3/gui/scripts/vtkvolumeviewer.tcl
r4455 r4474 1655 1655 "static_triad" "static" \ 1656 1656 "closest_triad" "closest" \ 1657 "furthest_triad" "f urthest" \1657 "furthest_triad" "farthest" \ 1658 1658 "outer_edges" "outer" 1659 1659 $itk_component(axismode) value "static"
Note: See TracChangeset
for help on using the changeset viewer.