Program: 43069
Project: 43069
Buggy source:
/** 
 * Execute an operation on a grid.  If the operation changes the grid dimensions then a new one will be returned from the call.
 * @param grid The grid to use for grid A.
 * @return The new grid
 */
public Grid execute(Grid grid){
  gridOp=grid;
  System.out.println("String_Node_Str");
  Grid result=grid.createEmpty(grid.getWidth(),grid.getHeight(),grid.getDepth(),grid.getVoxelSize(),grid.getSliceHeight());
  byte state;
  byte last=Grid.OUTSIDE;
  int status=0;
  int width=grid.getWidth();
  int height=grid.getHeight();
  int depth=grid.getDepth();
  System.out.println("String_Node_Str" + material);
  for (int y=0; y < height; y++) {
    for (int z=0; z < depth; z++) {
      status=0;
      for (int x=0; x < width; x++) {
        VoxelData vd=grid.getData(x,y,z);
        state=vd.getState();
        if (vd.getMaterial() != material && state != Grid.OUTSIDE) {
          continue;
        }
        if (status == 0) {
          if (state == Grid.EXTERIOR) {
            status=1;
          }
 else           if (state == Grid.INTERIOR) {
            status=3;
          }
        }
 else         if (status == 1) {
          if (state == Grid.OUTSIDE) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=3;
            continue;
          }
 else           if (state == Grid.INTERIOR) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=3;
          }
        }
 else         if (status == 2) {
          if (state == Grid.OUTSIDE) {
            status=0;
          }
 else           if (state == Grid.INTERIOR) {
            status=3;
          }
        }
 else         if (status == 3) {
          if (state == Grid.OUTSIDE) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            continue;
          }
 else           if (state == Grid.INTERIOR) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            continue;
          }
 else           if (state == Grid.EXTERIOR) {
            status=2;
          }
        }
      }
    }
  }
  System.out.println("String_Node_Str" + result.findCount(Grid.VoxelClasses.INTERIOR));
  for (int x=0; x < width; x++) {
    for (int z=0; z < depth; z++) {
      status=0;
      for (int y=0; y < height; y++) {
        VoxelData vd=grid.getData(x,y,z);
        state=vd.getState();
        if (vd.getMaterial() != material && state != Grid.OUTSIDE) {
          continue;
        }
        if (status == 0) {
          if (state == Grid.EXTERIOR) {
            status=1;
          }
 else           if (state == Grid.INTERIOR) {
            status=3;
            continue;
          }
        }
 else         if (status == 1) {
          if (state == Grid.OUTSIDE) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=3;
            continue;
          }
 else           if (state == Grid.INTERIOR) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=3;
          }
        }
 else         if (status == 2) {
          if (state == Grid.OUTSIDE) {
            status=0;
          }
 else           if (state == Grid.INTERIOR) {
            status=3;
            continue;
          }
        }
 else         if (status == 3) {
          if (state == Grid.OUTSIDE) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            continue;
          }
 else           if (state == Grid.INTERIOR) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            continue;
          }
 else           if (state == Grid.EXTERIOR) {
            status=2;
          }
        }
        result.setData(x,y,z,Grid.OUTSIDE,(byte)0);
      }
    }
  }
  System.out.println("String_Node_Str" + result.findCount(Grid.VoxelClasses.INTERIOR));
  status=0;
  for (int x=0; x < width; x++) {
    for (int y=0; y < height; y++) {
      status=0;
      for (int z=0; z < depth; z++) {
        VoxelData vd=grid.getData(x,y,z);
        state=vd.getState();
        if (vd.getMaterial() != material && state != Grid.OUTSIDE) {
          continue;
        }
        if (status == 0) {
          if (state == Grid.EXTERIOR) {
            status=1;
          }
 else           if (state == Grid.INTERIOR) {
            status=3;
          }
        }
 else         if (status == 1) {
          if (state == Grid.OUTSIDE) {
            if (result.getState(x,y,z) == Grid.INTERIOR) {
              status=3;
              continue;
            }
          }
 else           if (state == Grid.INTERIOR) {
            if (result.getState(x,y,z) == Grid.INTERIOR) {
              status=3;
            }
          }
        }
 else         if (status == 2) {
          if (state == Grid.OUTSIDE) {
            status=0;
          }
 else           if (state == Grid.INTERIOR) {
            status=3;
            continue;
          }
        }
 else         if (status == 3) {
          if (state == Grid.OUTSIDE) {
            if (result.getState(x,y,z) == Grid.INTERIOR) {
              result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
              continue;
            }
          }
 else           if (state == Grid.INTERIOR) {
            if (result.getState(x,y,z) == Grid.INTERIOR) {
              result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
              continue;
            }
          }
 else           if (state == Grid.EXTERIOR) {
            status=2;
          }
        }
        result.setData(x,y,z,Grid.OUTSIDE,(byte)0);
      }
    }
  }
  System.out.println("String_Node_Str" + result.findCount(Grid.VoxelClasses.INTERIOR));
  result.find(Grid.VoxelClasses.INTERIOR,this);
  gridOp=null;
  return grid;
}

Fixed version (ground truth):
/** 
 * Execute an operation on a grid.  If the operation changes the grid dimensions then a new one will be returned from the call.
 * @param grid The grid to use for grid A.
 * @return The new grid
 */
public Grid execute(Grid grid){
  gridOp=grid;
  System.out.println("String_Node_Str");
  Grid result=grid.createEmpty(grid.getWidth(),grid.getHeight(),grid.getDepth(),grid.getVoxelSize(),grid.getSliceHeight());
  byte state;
  byte last=Grid.OUTSIDE;
  int status=0;
  int width=grid.getWidth();
  int height=grid.getHeight();
  int depth=grid.getDepth();
  System.out.println("String_Node_Str" + material);
  for (int y=0; y < height; y++) {
    for (int z=0; z < depth; z++) {
      status=0;
      for (int x=0; x < width; x++) {
        VoxelData vd=grid.getData(x,y,z);
        state=vd.getState();
        if (vd.getMaterial() != material && state != Grid.OUTSIDE) {
          continue;
        }
        if (status == OUTSIDE) {
          if (state == Grid.EXTERIOR) {
            status=ENTERING;
          }
 else           if (state == Grid.INTERIOR) {
            status=INSIDE;
          }
        }
 else         if (status == ENTERING) {
          if (state == Grid.OUTSIDE) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=OUTSIDE;
            continue;
          }
 else           if (state == Grid.INTERIOR) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=INSIDE;
          }
        }
 else         if (status == EXITING) {
          if (state == Grid.OUTSIDE) {
            status=OUTSIDE;
          }
 else           if (state == Grid.INTERIOR) {
            status=INSIDE;
          }
        }
 else         if (status == INSIDE) {
          if (state == Grid.OUTSIDE) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=OUTSIDE;
            continue;
          }
 else           if (state == Grid.INTERIOR) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            continue;
          }
 else           if (state == Grid.EXTERIOR) {
            status=EXITING;
          }
        }
      }
    }
  }
  System.out.println("String_Node_Str" + result.findCount(Grid.VoxelClasses.INTERIOR));
  for (int x=0; x < width; x++) {
    for (int z=0; z < depth; z++) {
      status=0;
      for (int y=0; y < height; y++) {
        VoxelData vd=grid.getData(x,y,z);
        state=vd.getState();
        if (vd.getMaterial() != material && state != Grid.OUTSIDE) {
          continue;
        }
        if (status == OUTSIDE) {
          if (state == Grid.EXTERIOR) {
            status=ENTERING;
          }
 else           if (state == Grid.INTERIOR) {
            status=INSIDE;
            continue;
          }
        }
 else         if (status == ENTERING) {
          if (state == Grid.OUTSIDE) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=OUTSIDE;
            continue;
          }
 else           if (state == Grid.INTERIOR) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=INSIDE;
          }
        }
 else         if (status == ENTERING) {
          if (state == Grid.OUTSIDE) {
            status=OUTSIDE;
          }
 else           if (state == Grid.INTERIOR) {
            status=INSIDE;
            continue;
          }
        }
 else         if (status == INSIDE) {
          if (state == Grid.OUTSIDE) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            status=OUTSIDE;
            continue;
          }
 else           if (state == Grid.INTERIOR) {
            result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
            continue;
          }
 else           if (state == Grid.EXTERIOR) {
            status=EXITING;
          }
        }
        result.setData(x,y,z,Grid.OUTSIDE,(byte)0);
      }
    }
  }
  System.out.println("String_Node_Str" + result.findCount(Grid.VoxelClasses.INTERIOR));
  status=0;
  for (int x=0; x < width; x++) {
    for (int y=0; y < height; y++) {
      status=0;
      for (int z=0; z < depth; z++) {
        VoxelData vd=grid.getData(x,y,z);
        state=vd.getState();
        if (vd.getMaterial() != material && state != Grid.OUTSIDE) {
          continue;
        }
        if (status == OUTSIDE) {
          if (state == Grid.EXTERIOR) {
            status=ENTERING;
          }
 else           if (state == Grid.INTERIOR) {
            status=INSIDE;
          }
        }
 else         if (status == ENTERING) {
          if (state == Grid.OUTSIDE) {
            if (result.getState(x,y,z) == Grid.INTERIOR) {
              status=OUTSIDE;
              continue;
            }
          }
 else           if (state == Grid.INTERIOR) {
            if (result.getState(x,y,z) == Grid.INTERIOR) {
              status=INSIDE;
            }
          }
        }
 else         if (status == EXITING) {
          if (state == Grid.OUTSIDE) {
            status=OUTSIDE;
          }
 else           if (state == Grid.INTERIOR) {
            status=INSIDE;
            continue;
          }
        }
 else         if (status == INSIDE) {
          if (state == Grid.OUTSIDE) {
            if (result.getState(x,y,z) == Grid.INTERIOR) {
              result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
              continue;
            }
          }
 else           if (state == Grid.INTERIOR) {
            if (result.getState(x,y,z) == Grid.INTERIOR) {
              result.setData(x,y,z,Grid.INTERIOR,innerMaterial);
              continue;
            }
          }
 else           if (state == Grid.EXTERIOR) {
            status=ENTERING;
          }
        }
        result.setData(x,y,z,Grid.OUTSIDE,(byte)0);
      }
    }
  }
  System.out.println("String_Node_Str" + result.findCount(Grid.VoxelClasses.INTERIOR));
  result.find(Grid.VoxelClasses.INTERIOR,this);
  gridOp=null;
  return grid;
}