     @minCoord    = null
 
   addContour : (pos) ->
+
+    # If the distance to the last point is larger than MIN_DISTANCE,
+    # interpolate so that the winding number alg. used in contains2dCoordinate
+    # has enough points to be accurate
+    if @contourList.length > 0
+      last = @contourList[@contourList.length - 1]
+      step = Math.min(@MIN_DISTANCE / @calculateDistance(last, pos), 1)
+      for f in [step...1] by step
+        hpos = @interpolatePositions( last, pos, f)
+        @contourList.push(hpos)
+        @updateArea(hpos)
     
     @contourList.push(pos)
     @updateArea(pos)



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

      x = Math.floor(x); y = Math.floor(y)
      map[x - minCoord2d[0]][y - minCoord2d[1]] = true

    to2DCoordinate = (x, y) ->

      return [x + minCoord2d[0] + 0.5, y + minCoord2d[1] + 0.5]


    @drawOutlineVoxels(setMap)

    @fillOutline(map, width, height, to2DCoordinate)

    iterator = {
      hasNext : true
