Changeset 4639
- Timestamp:
- Sep 30, 2014 8:09:28 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/mesh.tcl
r4418 r4639 557 557 set _dim 3 558 558 set _numPoints [expr $xNum * $yNum * $zNum] 559 set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum -1)]559 set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)] 560 560 if { ($_numPoints*3) != $numCoords } { 561 561 puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>" … … 580 580 set _dim 2 581 581 set _numPoints [expr $xNum * $yNum] 582 set _numCells [expr ($xNum - 1) * ($yNum -1)]582 set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)] 583 583 if { ($_numPoints*2) != $numCoords } { 584 584 puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>" … … 630 630 # This results in a STRUCTURED_POINTS 631 631 if { $_dim == 1 } { 632 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 632 if {$xNum == 1} { 633 set xSpace 0 634 } else { 635 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 636 } 633 637 set _numPoints $xNum 634 638 set _numCells [expr $xNum - 1] … … 642 646 set _limits(z) [list 0 0] 643 647 } elseif { $_dim == 2 } { 644 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 645 set ySpace [expr ($yMax - $yMin) / double($yNum - 1)] 648 if {$xNum == 1} { 649 set xSpace 0 650 } else { 651 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 652 } 653 if {$yNum == 1} { 654 set ySpace 0 655 } else { 656 set ySpace [expr ($yMax - $yMin) / double($yNum - 1)] 657 } 646 658 set _numPoints [expr $xNum * $yNum] 647 set _numCells [expr ($xNum - 1) * ($yNum -1)]659 set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)] 648 660 append out "DATASET STRUCTURED_POINTS\n" 649 661 append out "DIMENSIONS $xNum $yNum 1\n" … … 656 668 set _limits(z) [list 0 0] 657 669 } elseif { $_dim == 3 } { 658 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 659 set ySpace [expr ($yMax - $yMin) / double($yNum - 1)] 660 set zSpace [expr ($zMax - $zMin) / double($zNum - 1)] 670 if {$xNum == 1} { 671 set xSpace 0 672 } else { 673 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 674 } 675 if {$yNum == 1} { 676 set ySpace 0 677 } else { 678 set ySpace [expr ($yMax - $yMin) / double($yNum - 1)] 679 } 680 if {$zNum == 1} { 681 set zSpace 0 682 } else { 683 set zSpace [expr ($zMax - $zMin) / double($zNum - 1)] 684 } 661 685 set _numPoints [expr $xNum * $yNum * $zNum] 662 set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum -1)]686 set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)] 663 687 append out "DATASET STRUCTURED_POINTS\n" 664 688 append out "DIMENSIONS $xNum $yNum $zNum\n" … … 713 737 if { $_dim == 3 } { 714 738 set _numPoints [expr $xNum * $yNum * $zNum] 715 set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum -1)]739 set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)] 716 740 append out "DATASET RECTILINEAR_GRID\n" 717 741 append out "DIMENSIONS $xNum $yNum $zNum\n" … … 733 757 } elseif { $_dim == 2 } { 734 758 set _numPoints [expr $xNum * $yNum] 735 set _numCells [expr ($xNum - 1) * ($yNum -1)]759 set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)] 736 760 append out "DATASET RECTILINEAR_GRID\n" 737 761 append out "DIMENSIONS $xNum $yNum 1\n"
Note: See TracChangeset
for help on using the changeset viewer.