Program: 178232
Project: 178232
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){
  RrPolygonList hatchedPolygons;
  freeze();
  int layer=layerConditions.getMachineLayer();
  BooleanGridList slice=slice(stl,layerConditions.getModelLayer(),layerConditions);
  if (layerConditions.getModelLayer() < 2 || layerConditions.getModelLayer() > layerConditions.getModelLayerMax() - 3) {
    slice=slice.offset(layerConditions,false,-1);
    hatchedPolygons=slice.hatch(layerConditions,true,null);
    return hatchedPolygons;
  }
  BooleanGridList above=slice(stl,layer + 2,layerConditions);
  above=BooleanGridList.intersections(slice(stl,layer + 1,layerConditions),above);
  BooleanGridList below=slice(stl,layer - 2,layerConditions);
  below=BooleanGridList.intersections(slice(stl,layer - 1,layerConditions),below);
  BooleanGridList nothingabove=BooleanGridList.differences(slice,above);
  BooleanGridList nothingbelow=BooleanGridList.differences(slice,below);
  BooleanGridList insides=BooleanGridList.differences(slice,nothingbelow);
  insides=BooleanGridList.differences(insides,nothingabove);
  BooleanGridList bridges=nothingbelow.cullNonNull();
  nothingbelow=nothingbelow.cullNull();
  BooleanGridList surfaces=BooleanGridList.unions(nothingbelow,nothingabove);
  bridges=bridges.offset(layerConditions,false,2);
  bridges=BooleanGridList.intersections(bridges,slice);
  BooleanGridList lands=BooleanGridList.intersections(bridges,BooleanGridList.unions(insides,surfaces));
  insides=BooleanGridList.differences(insides,lands);
  surfaces=BooleanGridList.differences(surfaces,lands);
  bridges=bridges.offset(layerConditions,false,0.75);
  insides=insides.offset(layerConditions,false,0.75);
  surfaces=surfaces.offset(layerConditions,false,0.75);
  bridges=BooleanGridList.intersections(bridges,slice);
  insides=BooleanGridList.intersections(insides,slice);
  surfaces=BooleanGridList.intersections(surfaces,slice);
  bridges=bridges.offset(layerConditions,false,-1);
  insides=insides.offset(layerConditions,false,-1);
  surfaces=surfaces.offset(layerConditions,false,-1);
  hatchedPolygons=insides.hatch(layerConditions,false,null);
  hatchedPolygons.add(surfaces.hatch(layerConditions,true,null));
  hatchedPolygons.add(bridgeHatch(bridges,lands,layerConditions));
  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){
  InFillPatterns infill=new InFillPatterns();
  freeze();
  int layer=layerConditions.getMachineLayer();
  BooleanGridList slice=slice(stl,layerConditions.getModelLayer(),layerConditions);
  if (layerConditions.getModelLayer() < 2 || layerConditions.getModelLayer() > layerConditions.getModelLayerMax() - 3) {
    slice=slice.offset(layerConditions,false,-1);
    infill.hatchedPolygons=slice.hatch(layerConditions,true,null);
    return infill.hatchedPolygons;
  }
  BooleanGridList above=slice(stl,layer + 2,layerConditions);
  above=BooleanGridList.intersections(slice(stl,layer + 1,layerConditions),above);
  BooleanGridList below=slice(stl,layer - 2,layerConditions);
  below=BooleanGridList.intersections(slice(stl,layer - 1,layerConditions),below);
  BooleanGridList nothingabove=BooleanGridList.differences(slice,above);
  BooleanGridList nothingbelow=BooleanGridList.differences(slice,below);
  infill.insides=BooleanGridList.differences(slice,nothingbelow);
  infill.insides=BooleanGridList.differences(infill.insides,nothingabove);
  infill.bridges=nothingbelow.cullNonNull();
  nothingbelow=nothingbelow.cullNull();
  infill.surfaces=BooleanGridList.unions(nothingbelow,nothingabove);
  infill.bridges=infill.bridges.offset(layerConditions,false,2);
  infill.bridges=BooleanGridList.intersections(infill.bridges,slice);
  BooleanGridList lands=BooleanGridList.intersections(infill.bridges,BooleanGridList.unions(infill.insides,infill.surfaces));
  infill.bridges=infill.bridges.offset(layerConditions,false,0.75);
  infill.insides=infill.insides.offset(layerConditions,false,0.75);
  infill.surfaces=infill.surfaces.offset(layerConditions,false,0.75);
  infill.bridges=BooleanGridList.intersections(infill.bridges,slice);
  infill.insides=BooleanGridList.intersections(infill.insides,slice);
  infill.surfaces=BooleanGridList.intersections(infill.surfaces,slice);
  infill.bridges=infill.bridges.offset(layerConditions,false,-1);
  infill.insides=infill.insides.offset(layerConditions,false,-1);
  infill.surfaces=infill.surfaces.offset(layerConditions,false,-1);
  infill=bridgeHatch(infill,lands,layerConditions);
  infill.hatchedPolygons.add(infill.insides.hatch(layerConditions,false,null));
  infill.hatchedPolygons.add(infill.surfaces.hatch(layerConditions,true,null));
  return infill.hatchedPolygons;
}