Program: 178239
Project: 178239
Buggy source:
/** 
 * Compute the infill hatching polygons for this set of patterns
 * @param stl
 * @param layerConditions
 * @param startNearHere
 * @return
 */
public RrPolygonList computeInfill(int stl,LayerRules layerConditions){
  freeze();
  int layer=layerConditions.getMachineLayer();
  BooleanGridList slice=slice(stl,layerConditions.getModelLayer(),layerConditions);
  BooleanGridList adjacentSlices=slice(stl,layer + 1,layerConditions);
  adjacentSlices=BooleanGridList.intersections(slice(stl,layer + 2,layerConditions),adjacentSlices);
  BooleanGridList supportBeneath=slice(stl,layer - 1,layerConditions);
  adjacentSlices=BooleanGridList.intersections(supportBeneath,adjacentSlices);
  adjacentSlices=BooleanGridList.intersections(slice(stl,layer - 2,layerConditions),adjacentSlices);
  BooleanGridList insides=null;
  BooleanGridList nothingAbove=slice;
  BooleanGridList unSupported=null;
  BooleanGridList lands=null;
  if (adjacentSlices != null && layerConditions.getModelLayer() > 1) {
    insides=BooleanGridList.intersections(slice,adjacentSlices);
    nothingAbove=BooleanGridList.differences(slice,adjacentSlices,false);
    unSupported=BooleanGridList.differences(nothingAbove,supportBeneath,true);
    nothingAbove=BooleanGridList.differences(nothingAbove,unSupported,false);
    nothingAbove=nothingAbove.offset(layerConditions,false,-2);
    nothingAbove=BooleanGridList.intersections(nothingAbove,slice);
    unSupported=unSupported.offset(layerConditions,false,-2);
    unSupported=BooleanGridList.intersections(unSupported,slice);
  }
  nothingAbove=nothingAbove.offset(layerConditions,false,1);
  if (unSupported != null)   unSupported=unSupported.offset(layerConditions,false,1);
  if (insides != null) {
    insides=insides.offset(layerConditions,false,1);
    lands=BooleanGridList.intersections(unSupported,insides);
    insides=BooleanGridList.differences(insides,nothingAbove,false);
    insides=BooleanGridList.differences(insides,unSupported,false);
  }
  RrPolygonList hatchedPolygons=nothingAbove.hatch(layerConditions,true,null);
  if (unSupported != null && lands != null)   hatchedPolygons.add(bridges(unSupported,lands,layerConditions));
  if (insides != null)   hatchedPolygons.add(insides.hatch(layerConditions,false,null));
  return hatchedPolygons;
}

Fixed version (ground truth):
/** 
 * Compute the infill hatching polygons for this set of patterns
 * @param stl
 * @param layerConditions
 * @param startNearHere
 * @return
 */
public RrPolygonList computeInfill(int stl,LayerRules layerConditions){
  freeze();
  int layer=layerConditions.getMachineLayer();
  BooleanGridList slice=slice(stl,layerConditions.getModelLayer(),layerConditions);
  BooleanGridList adjacentSlices=slice(stl,layer + 1,layerConditions);
  BooleanGridList supportBeneath=null;
  adjacentSlices=BooleanGridList.intersections(slice(stl,layer + 2,layerConditions),adjacentSlices);
  supportBeneath=slice(stl,layer - 1,layerConditions);
  adjacentSlices=BooleanGridList.intersections(supportBeneath,adjacentSlices);
  adjacentSlices=BooleanGridList.intersections(slice(stl,layer - 2,layerConditions),adjacentSlices);
  BooleanGridList insides=null;
  BooleanGridList nothingAbove=slice;
  BooleanGridList unSupported=null;
  BooleanGridList lands=null;
  if (adjacentSlices != null && layerConditions.getModelLayer() > 1) {
    insides=BooleanGridList.intersections(slice,adjacentSlices);
    nothingAbove=BooleanGridList.differences(slice,adjacentSlices,false);
    unSupported=BooleanGridList.differences(nothingAbove,supportBeneath,true);
    nothingAbove=BooleanGridList.differences(nothingAbove,unSupported,false);
    nothingAbove=nothingAbove.offset(layerConditions,false,-2);
    nothingAbove=BooleanGridList.intersections(nothingAbove,slice);
    unSupported=unSupported.offset(layerConditions,false,-2);
    unSupported=BooleanGridList.intersections(unSupported,slice);
  }
  nothingAbove=nothingAbove.offset(layerConditions,false,1);
  if (unSupported != null)   unSupported=unSupported.offset(layerConditions,false,1);
  if (insides != null) {
    insides=insides.offset(layerConditions,false,1);
    lands=BooleanGridList.intersections(unSupported,insides);
    insides=BooleanGridList.differences(insides,nothingAbove,false);
    insides=BooleanGridList.differences(insides,unSupported,false);
  }
  RrPolygonList hatchedPolygons=nothingAbove.hatch(layerConditions,true,null);
  if (unSupported != null && lands != null)   hatchedPolygons.add(bridges(unSupported,lands,layerConditions));
  if (insides != null)   hatchedPolygons.add(insides.hatch(layerConditions,false,null));
  return hatchedPolygons;
}