Program: 29954
Project: 29954
Buggy source:
@Override public HE_Mesh createBase(){
  if (container == null) {
    return new HE_Mesh();
  }
  if (points == null) {
    return container;
  }
  if (numberOfPoints == 0) {
    numberOfPoints=points.length;
  }
  if ((cellIndex < 0) || (cellIndex >= numberOfPoints)) {
    return container;
  }
  final HE_Mesh result=container.get();
  final ArrayList<WB_Plane> cutPlanes=new ArrayList<WB_Plane>();
  int id=0;
  final WB_Point O=new WB_Point();
  WB_Plane P;
  final int[] labels;
  if (limitPoints) {
    labels=new int[pointsToUse.length];
    for (    final int element : pointsToUse) {
      if (cellIndex != element) {
        final WB_Vector N=new WB_Vector(points[cellIndex]);
        N.subSelf(points[element]);
        N.normalizeSelf();
        O.set(points[cellIndex]);
        O.addSelf(points[element]);
        O.mulSelf(0.5);
        if (offset != 0) {
          O.addSelf(N.mul(offset));
        }
        P=new WB_Plane(O,N);
        cutPlanes.add(P);
        labels[id]=element;
        id++;
      }
    }
  }
 else {
    labels=new int[numberOfPoints - 1];
    for (int j=0; j < numberOfPoints; j++) {
      if (cellIndex != j) {
        final WB_Vector N=new WB_Vector(points[cellIndex]);
        N.subSelf(points[j]);
        N.normalizeSelf();
        O.set(points[cellIndex]);
        O.addSelf(points[j]);
        O.mulSelf(0.5);
        if (offset != 0) {
          O.addSelf(N.mul(offset));
        }
        P=new WB_Plane(O,N);
        cutPlanes.add(P);
        labels[id]=j;
        id++;
      }
    }
  }
  final HEM_MultiSlice msm=new HEM_MultiSlice();
  msm.setPlanes(cutPlanes).setCenter(new WB_Point(points[cellIndex])).setCap(!surface).setKeepCenter(true).setLabels(labels).setSimpleCap(simpleCap);
  result.modify(msm);
  inner=new HE_Selection(result);
  for (int i=0; i < labels.length; i++) {
    final HE_Selection sel=HE_Selection.selectFacesWithInternalLabel(result,labels[i]);
    if (sel.getNumberOfFaces() > 0) {
      final HE_FaceIterator fitr=sel.fItr();
      while (fitr.hasNext()) {
        result.deleteFace(fitr.next());
      }
      result.cleanUnusedElementsByFace();
      for (      final HE_Face f : result.capHoles()) {
        f.copyProperties(sel.getFaceWithIndex(0));
      }
    }
  }
  outer=msm.origFaces;
  return result;
}

Fixed version (ground truth):
@Override public HE_Mesh createBase(){
  if (container == null) {
    return new HE_Mesh();
  }
  if (points == null) {
    return container;
  }
  if (numberOfPoints == 0) {
    numberOfPoints=points.length;
  }
  if ((cellIndex < 0) || (cellIndex >= numberOfPoints)) {
    return container;
  }
  final HE_Mesh result=container.get();
  final ArrayList<WB_Plane> cutPlanes=new ArrayList<WB_Plane>();
  int id=0;
  final WB_Point O=new WB_Point();
  WB_Plane P;
  final int[] labels;
  if (limitPoints) {
    labels=new int[pointsToUse.length];
    for (    final int element : pointsToUse) {
      if (cellIndex != element) {
        final WB_Vector N=new WB_Vector(points[cellIndex]);
        N.subSelf(points[element]);
        N.normalizeSelf();
        O.set(points[cellIndex]);
        O.addSelf(points[element]);
        O.mulSelf(0.5);
        if (offset != 0) {
          O.addSelf(N.mul(offset));
        }
        P=new WB_Plane(O,N);
        cutPlanes.add(P);
        labels[id]=element;
        id++;
      }
    }
  }
 else {
    labels=new int[numberOfPoints - 1];
    for (int j=0; j < numberOfPoints; j++) {
      if (cellIndex != j) {
        final WB_Vector N=new WB_Vector(points[cellIndex]);
        N.subSelf(points[j]);
        N.normalizeSelf();
        O.set(points[cellIndex]);
        O.addSelf(points[j]);
        O.mulSelf(0.5);
        if (offset != 0) {
          O.addSelf(N.mul(offset));
        }
        P=new WB_Plane(O,N);
        cutPlanes.add(P);
        labels[id]=j;
        id++;
      }
    }
  }
  final HEM_MultiSlice msm=new HEM_MultiSlice();
  msm.setPlanes(cutPlanes).setCenter(new WB_Point(points[cellIndex])).setCap(!surface).setKeepCenter(true).setLabels(labels).setSimpleCap(simpleCap);
  result.modify(msm);
  inner=new HE_Selection(result);
  for (int i=0; i < labels.length; i++) {
    final HE_Selection sel=HE_Selection.selectFacesWithTemporaryLabel(result,labels[i]);
    if (sel.getNumberOfFaces() > 0) {
      final HE_FaceIterator fitr=sel.fItr();
      while (fitr.hasNext()) {
        result.deleteFace(fitr.next());
      }
      result.cleanUnusedElementsByFace();
      for (      final HE_Face f : result.capHoles()) {
        f.copyProperties(sel.getFaceWithIndex(0));
      }
    }
  }
  outer=msm.origFaces;
  return result;
}