Changeset 4666 for branches/1.3


Ignore:
Timestamp:
Nov 8, 2014, 8:58:32 PM (5 years ago)
Author:
ldelgass
Message:

Merge r4639,r4659 from trunk

Location:
branches/1.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/gui/scripts/field.tcl

    r4665 r4666  
    15141514        set dim 0
    15151515        foreach axis {x y z} {
    1516             foreach {min max} [$mesh limits $axis] { 
     1516            foreach {min max} [$mesh limits $axis] {
    15171517                if { $min < $max } {
    15181518                    incr dim
  • branches/1.3/gui/scripts/mesh.tcl

    r4512 r4666  
    518518            set ${axis}Max $max
    519519            set ${axis}Num $num
     520            if {$min > $max} {
     521                puts stderr "ERROR: grid $axis axis minimum larger than maximum"
     522                return 0
     523            }
    520524            incr numUniform
    521525        } elseif { $coords != "" } {
     
    557561            set _dim 3
    558562            set _numPoints [expr $xNum * $yNum * $zNum]
    559             set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)]
     563            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
    560564            if { ($_numPoints*3) != $numCoords } {
    561565                puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>"
     
    580584            set _dim 2
    581585            set _numPoints [expr $xNum * $yNum]
    582             set _numCells [expr ($xNum - 1) * ($yNum - 1)]
     586            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
    583587            if { ($_numPoints*2) != $numCoords } {
    584588                puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>"
     
    630634        # This results in a STRUCTURED_POINTS
    631635        if { $_dim == 1 } {
    632             set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
     636            if {$xNum == 1} {
     637                set xSpace 0
     638            } else {
     639                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
     640            }
    633641            set _numPoints $xNum
    634642            set _numCells [expr $xNum - 1]
     
    642650            set _limits(z) [list 0 0]
    643651        } elseif { $_dim == 2 } {
    644             set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
    645             set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
     652            if {$xNum == 1} {
     653                set xSpace 0
     654            } else {
     655                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
     656            }
     657            if {$yNum == 1} {
     658                set ySpace 0
     659            } else {
     660                set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
     661            }
    646662            set _numPoints [expr $xNum * $yNum]
    647             set _numCells [expr ($xNum - 1) * ($yNum - 1)]
     663            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
    648664            append out "DATASET STRUCTURED_POINTS\n"
    649665            append out "DIMENSIONS $xNum $yNum 1\n"
     
    656672            set _limits(z) [list 0 0]
    657673        } 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)]
     674            if {$xNum == 1} {
     675                set xSpace 0
     676            } else {
     677                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
     678            }
     679            if {$yNum == 1} {
     680                set ySpace 0
     681            } else {
     682                set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
     683            }
     684            if {$zNum == 1} {
     685                set zSpace 0
     686            } else {
     687                set zSpace [expr ($zMax - $zMin) / double($zNum - 1)]
     688            }
    661689            set _numPoints [expr $xNum * $yNum * $zNum]
    662             set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)]
     690            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
    663691            append out "DATASET STRUCTURED_POINTS\n"
    664692            append out "DIMENSIONS $xNum $yNum $zNum\n"
     
    713741    if { $_dim == 3 } {
    714742        set _numPoints [expr $xNum * $yNum * $zNum]
    715         set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)]
     743        set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
    716744        append out "DATASET RECTILINEAR_GRID\n"
    717745        append out "DIMENSIONS $xNum $yNum $zNum\n"
     
    733761    } elseif { $_dim == 2 } {
    734762        set _numPoints [expr $xNum * $yNum]
    735         set _numCells [expr ($xNum - 1) * ($yNum - 1)]
     763        set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
    736764        append out "DATASET RECTILINEAR_GRID\n"
    737765        append out "DIMENSIONS $xNum $yNum 1\n"
Note: See TracChangeset for help on using the changeset viewer.