Index: /trunk/gui/scripts/mesh.tcl
===================================================================
--- /trunk/gui/scripts/mesh.tcl	(revision 4638)
+++ /trunk/gui/scripts/mesh.tcl	(revision 4639)
@@ -557,5 +557,5 @@
             set _dim 3
 	    set _numPoints [expr $xNum * $yNum * $zNum]
-            set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)]
+            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
             if { ($_numPoints*3) != $numCoords } {
                 puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>"
@@ -580,5 +580,5 @@
             set _dim 2
 	    set _numPoints [expr $xNum * $yNum]
-            set _numCells [expr ($xNum - 1) * ($yNum - 1)]
+            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
             if { ($_numPoints*2) != $numCoords } {
                 puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>"
@@ -630,5 +630,9 @@
         # This results in a STRUCTURED_POINTS
         if { $_dim == 1 } {
-            set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
+            if {$xNum == 1} {
+                set xSpace 0
+            } else {
+                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
+            }
 	    set _numPoints $xNum
             set _numCells [expr $xNum - 1]
@@ -642,8 +646,16 @@
             set _limits(z) [list 0 0]
 	} elseif { $_dim == 2 } {
-	    set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
-	    set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
+            if {$xNum == 1} {
+                set xSpace 0
+            } else {
+                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
+            }
+            if {$yNum == 1} {
+                set ySpace 0
+            } else {
+                set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
+            }
 	    set _numPoints [expr $xNum * $yNum]
-            set _numCells [expr ($xNum - 1) * ($yNum - 1)]
+            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
 	    append out "DATASET STRUCTURED_POINTS\n"
 	    append out "DIMENSIONS $xNum $yNum 1\n"
@@ -656,9 +668,21 @@
             set _limits(z) [list 0 0]
 	} elseif { $_dim == 3 } {
-	    set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
-	    set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
-	    set zSpace [expr ($zMax - $zMin) / double($zNum - 1)]
+            if {$xNum == 1} {
+                set xSpace 0
+            } else {
+                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
+            }
+            if {$yNum == 1} {
+                set ySpace 0
+            } else {
+                set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
+            }
+            if {$zNum == 1} {
+                set zSpace 0
+            } else {
+                set zSpace [expr ($zMax - $zMin) / double($zNum - 1)]
+            }
 	    set _numPoints [expr $xNum * $yNum * $zNum]
-            set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)]
+            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
 	    append out "DATASET STRUCTURED_POINTS\n"
 	    append out "DIMENSIONS $xNum $yNum $zNum\n"
@@ -713,5 +737,5 @@
     if { $_dim == 3 } {
 	set _numPoints [expr $xNum * $yNum * $zNum]
-        set _numCells [expr ($xNum - 1) * ($yNum - 1) * ($zNum - 1)]
+        set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
 	append out "DATASET RECTILINEAR_GRID\n"
 	append out "DIMENSIONS $xNum $yNum $zNum\n"
@@ -733,5 +757,5 @@
     } elseif { $_dim == 2 } {
 	set _numPoints [expr $xNum * $yNum]
-        set _numCells [expr ($xNum - 1) * ($yNum - 1)]
+        set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
 	append out "DATASET RECTILINEAR_GRID\n"
 	append out "DIMENSIONS $xNum $yNum 1\n"
