Program: 29953
Project: 29953
Buggy source:
@Override protected HE_Mesh createBase(){
  if (cells == null) {
    return new HE_Mesh();
  }
  if (on == null) {
    return new HE_Mesh();
  }
  if (on.length > cells.size()) {
    return new HE_Mesh();
  }
  final int n=on.length;
  final FastTable<HE_Face> tmpfaces=new FastTable<HE_Face>();
  int nv=0;
  for (int i=0; i < n; i++) {
    final HE_Mesh m=cells.getMesh(i);
    if (on[i]) {
      final Iterator<HE_Face> fItr=m.fItr();
      while (fItr.hasNext()) {
        final HE_Face f=fItr.next();
        if (f.getTemporaryLabel() == -1) {
          tmpfaces.add(f);
          nv+=f.getFaceOrder();
        }
 else         if (!on[f.getTemporaryLabel()] || membrane) {
          tmpfaces.add(f);
          nv+=f.getFaceOrder();
        }
      }
    }
  }
  final WB_Coord[] vertices=new WB_Coord[nv];
  final int[][] faces=new int[tmpfaces.size()][];
  final int[] labels=new int[tmpfaces.size()];
  final int[] intlabels=new int[tmpfaces.size()];
  final int[] colors=new int[tmpfaces.size()];
  int cid=0;
  for (int i=0; i < tmpfaces.size(); i++) {
    final HE_Face f=tmpfaces.get(i);
    faces[i]=new int[f.getFaceOrder()];
    labels[i]=f.getLabel();
    intlabels[i]=f.getTemporaryLabel();
    colors[i]=f.getColor();
    HE_Halfedge he=f.getHalfedge();
    for (int j=0; j < f.getFaceOrder(); j++) {
      vertices[cid]=he.getVertex();
      faces[i][j]=cid;
      he=he.getNextInFace();
      cid++;
    }
  }
  final HEC_FromFacelist ffl=new HEC_FromFacelist().setVertices(vertices).setFaces(faces).setDuplicate(true);
  final HE_Mesh result=ffl.createBase();
  final Iterator<HE_Face> fItr=result.fItr();
  int i=0;
  HE_Face f;
  while (fItr.hasNext()) {
    f=fItr.next();
    f.setLabel(labels[i]);
    f.setTemporaryLabel(intlabels[i]);
    f.setColor(colors[i]);
    i++;
  }
  result.fixNonManifoldVertices();
  if (!capBoundaries) {
    final HE_Selection sel=HE_Selection.selectFacesWithInternalLabel(result,-1);
    final HE_FaceIterator fitr=sel.fItr();
    while (fitr.hasNext()) {
      result.deleteFace(fitr.next());
    }
    result.cleanUnusedElementsByFace();
    result.capHalfedges();
  }
  return result;
}

Fixed version (ground truth):
@Override protected HE_Mesh createBase(){
  if (cells == null) {
    return new HE_Mesh();
  }
  if (on == null) {
    return new HE_Mesh();
  }
  if (on.length > cells.size()) {
    return new HE_Mesh();
  }
  final int n=on.length;
  final FastTable<HE_Face> tmpfaces=new FastTable<HE_Face>();
  int nv=0;
  for (int i=0; i < n; i++) {
    final HE_Mesh m=cells.getMesh(i);
    if (on[i]) {
      final Iterator<HE_Face> fItr=m.fItr();
      while (fItr.hasNext()) {
        final HE_Face f=fItr.next();
        if (f.getTemporaryLabel() == -1) {
          tmpfaces.add(f);
          nv+=f.getFaceOrder();
        }
 else         if (!on[f.getTemporaryLabel()] || membrane) {
          tmpfaces.add(f);
          nv+=f.getFaceOrder();
        }
      }
    }
  }
  final WB_Coord[] vertices=new WB_Coord[nv];
  final int[][] faces=new int[tmpfaces.size()][];
  final int[] labels=new int[tmpfaces.size()];
  final int[] intlabels=new int[tmpfaces.size()];
  final int[] colors=new int[tmpfaces.size()];
  int cid=0;
  for (int i=0; i < tmpfaces.size(); i++) {
    final HE_Face f=tmpfaces.get(i);
    faces[i]=new int[f.getFaceOrder()];
    labels[i]=f.getLabel();
    intlabels[i]=f.getTemporaryLabel();
    colors[i]=f.getColor();
    HE_Halfedge he=f.getHalfedge();
    for (int j=0; j < f.getFaceOrder(); j++) {
      vertices[cid]=he.getVertex();
      faces[i][j]=cid;
      he=he.getNextInFace();
      cid++;
    }
  }
  final HEC_FromFacelist ffl=new HEC_FromFacelist().setVertices(vertices).setFaces(faces).setDuplicate(true);
  final HE_Mesh result=ffl.createBase();
  final Iterator<HE_Face> fItr=result.fItr();
  int i=0;
  HE_Face f;
  while (fItr.hasNext()) {
    f=fItr.next();
    f.setLabel(labels[i]);
    f.setTemporaryLabel(intlabels[i]);
    f.setColor(colors[i]);
    i++;
  }
  result.fixNonManifoldVertices();
  if (!capBoundaries) {
    final HE_Selection sel=HE_Selection.selectFacesWithTemporaryLabel(result,-1);
    final HE_FaceIterator fitr=sel.fItr();
    while (fitr.hasNext()) {
      result.deleteFace(fitr.next());
    }
    result.cleanUnusedElementsByFace();
    result.capHalfedges();
  }
  return result;
}