Changeset 894 for trunk/gui/scripts/field.tcl
- Timestamp:
- Feb 16, 2008 10:57:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/field.tcl
r885 r894 203 203 } 204 204 if {[info exists _comp2unirect2d($what)]} { 205 set mobj $_comp2unirect2d($what) 205 set mobj $_comp2unirect2d($what) 206 206 return [$mobj values] 207 207 } … … 228 228 } 229 229 if {[info exists _comp2unirect2d($what)]} { 230 230 set mobj $_comp2unirect2d($what) 231 231 return [$mobj blob] 232 232 } … … 503 503 set class [$mobj info class] 504 504 ${class}::release $mobj 505 505 506 506 set fobj [lindex $_comp2vtk($name) 1] 507 507 rename $fobj "" … … 516 516 catch {unset _comp2style} 517 517 array unset _comp2unirect2d 518 518 519 519 # 520 520 # Scan through the components of the field and create … … 523 523 foreach cname [$_field children -type component] { 524 524 set type "" 525 if { ([$_field element $cname.constant] != "" && 526 [$_field element $cname.domain] != "") || 527 525 if { ([$_field element $cname.constant] != "" && 526 [$_field element $cname.domain] != "") || 527 [$_field element $cname.xy] != ""} { 528 528 set type "1D" 529 } elseif {[$_field element $cname.mesh] != "" && 530 529 } elseif {[$_field element $cname.mesh] != "" && 530 [$_field element $cname.values] != ""} { 531 531 set type "points-on-mesh" 532 532 } elseif {[$_field element $cname.vtk] != ""} { … … 538 538 } 539 539 set _comp2style($cname) "" 540 540 541 541 if {$type == "1D"} { 542 542 # … … 546 546 set xv "" 547 547 set yv "" 548 548 549 549 set val [$_field get $cname.constant] 550 550 if {$val != ""} { … … 558 558 set xv [blt::vector create x$_counter] 559 559 $xv append $z0 $z1 560 560 561 561 foreach {val pcomp} [_getValue $val] break 562 562 set yv [blt::vector create y$_counter] 563 563 $yv append $val $val 564 564 565 565 if {$pcomp != ""} { 566 566 set zm [expr {0.5*($z0+$z1)}] … … 573 573 set xv [blt::vector create x$_counter] 574 574 set yv [blt::vector create y$_counter] 575 575 576 576 foreach line [split $xydata \n] { 577 577 if {[scan $line {%g %g} xval yval] == 2} { … … 582 582 } 583 583 } 584 584 585 585 if {$xv != "" && $yv != ""} { 586 586 # sort x-coords in increasing order 587 587 $xv sort $yv 588 588 589 589 set _comp2dims($cname) "1D" 590 590 set _comp2xy($cname) [list $xv $yv] … … 599 599 set path [$_field get $cname.mesh] 600 600 if {[$_xmlobj element $path] != ""} { 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 601 set element [$_xmlobj element -as type $path] 602 if { $element == "unirect2d" } { 603 set _comp2dims($cname) "2D" 604 set _comp2unirect2d($cname) \ 605 [Rappture::UniRect2d \#auto $_xmlobj $_field $cname] 606 set _comp2style($cname) [$_field get $cname.style] 607 incr _counter 608 } elseif { $element == "cloud" || $element == "mesh" } { 609 switch -- $element { 610 cloud { 611 set mobj [Rappture::Cloud::fetch $_xmlobj $path] 612 } 613 mesh { 614 set mobj [Rappture::Mesh::fetch $_xmlobj $path] 615 } 616 } 617 if {[$mobj dimensions] > 1} { 618 # 619 # 2D/3D data 620 # Store cloud/field as components 621 # 622 set values [$_field get $cname.values] 623 set farray [vtkFloatArray ::vals$_counter] 624 625 foreach v $values { 626 if {"" != $_units} { 627 set v [Rappture::Units::convert $v \ 628 -context $_units -to $_units -units off] 629 } 630 $farray InsertNextValue $v 631 } 632 633 set _comp2dims($cname) "[$mobj dimensions]D" 634 set _comp2vtk($cname) [list $mobj $farray] 635 set _comp2style($cname) [$_field get $cname.style] 636 incr _counter 637 } else { 638 # 639 # OOPS! This is 1D data 640 # Forget the cloud/field -- store BLT vectors 641 # 642 set xv [blt::vector create x$_counter] 643 set yv [blt::vector create y$_counter] 644 645 set vtkpts [$mobj points] 646 set max [$vtkpts GetNumberOfPoints] 647 for {set i 0} {$i < $max} {incr i} { 648 set xval [lindex [$vtkpts GetPoint $i] 0] 649 $xv append $xval 650 } 651 set class [$mobj info class] 652 ${class}::release $mobj 653 654 set values [$_field get $cname.values] 655 foreach yval $values { 656 if {"" != $_units} { 657 set yval [Rappture::Units::convert $yval \ 658 -context $_units -to $_units -units off] 659 } 660 $yv append $yval 661 } 662 663 # sort x-coords in increasing order 664 $xv sort $yv 665 666 set _comp2dims($cname) "1D" 667 set _comp2xy($cname) [list $xv $yv] 668 incr _counter 669 } 670 } 671 } else { 672 puts "WARNING: can't find mesh $path for field component" 673 } 674 674 } elseif {$type == "vtk"} { 675 675 #
Note: See TracChangeset
for help on using the changeset viewer.