       Drawing.drawLine2d(p1[0], p1[1], p2[0], p2[1], setMap)
 
 
-  fillOutline : (map, width, height) ->
+  fillOutline : (map, width, height, to2DCoordinate) ->
 
     setMap = (x, y) ->
       map[x][y] = true
     isEmpty = (x, y) ->
       return map[x][y] != true
 
-    y = Math.round(height / 2)
-    for x in [1...width]
-      if not isEmpty(x-1, y) and isEmpty(x, y)
-        break
-
-    Drawing.fillArea(x, y, width, height, false, isEmpty, setMap)
+    # Use a grid of points within the bounding box to flood fill
+    # the area.
+    for x in [0..(width - 1)] by Math.round(width / @GRID_SIZE)
+      for y in [0..(height - 1)] by Math.round(height / @GRID_SIZE)
+        if isEmpty(x, y) and @contains2dCoordinate( to2DCoordinate( x, y ))
+          Drawing.fillArea(x, y, width, height, false, isEmpty, setMap)
 
 
   get2DCoordinate : (coord3d) ->



class VolumeLayer
  
  constructor : (@plane, @thirdDimensionValue) ->
    


    unless @minCoord
      return { hasNext : false }

    @addContour( @contourList[0] )

    minCoord2d = @get2DCoordinate(@minCoord)
    maxCoord2d = @get2DCoordinate(@maxCoord)
