Program: 29973
Project: 29973
Buggy source:
/** 
 */
private void createNodes(){
  int i=0;
  for (  WB_FrameNode node : frame.getNodes()) {
    node=frame.getNode(i);
    final ArrayList<WB_FrameStrut> struts=node.getStruts();
    final ArrayList<HE_Vertex> hullPoints=new ArrayList<HE_Vertex>();
    if (nodeTypes[i] == NodeType.ENDPOINT) {
      if (cap) {
        int offset;
        if (node == struts.get(0).start()) {
          offset=struts.get(0).getIndex() * 2;
        }
 else {
          offset=(struts.get(0).getIndex() * 2) + 1;
        }
        final ArrayList<HE_Halfedge> hes=new ArrayList<HE_Halfedge>(strutFacets);
        final HE_Face f=new HE_Face();
        mesh.add(f);
        for (int k=0; k < strutFacets; k++) {
          final HE_Halfedge he=new HE_Halfedge();
          mesh.setVertex(he,strutNodeConnections[offset].vertices.get(k));
          mesh.setFace(he,f);
          hes.add(he);
          mesh.add(he);
        }
        mesh.setHalfedge(f,hes.get(0));
        f.setTemporaryLabel(3);
        if (node == struts.get(0).start()) {
          for (int k=0, j=strutFacets - 1; k < strutFacets; j=k, k++) {
            mesh.setNext(hes.get(k),hes.get(j));
          }
        }
 else {
          for (int k=0, j=strutFacets - 1; k < strutFacets; j=k, k++) {
            mesh.setNext(hes.get(j),hes.get(k));
          }
        }
      }
    }
 else {
      if ((nodeTypes[i] != NodeType.ISOLATED) || createIsolatedNodes) {
        double br=strutRadius.evaluate(node.xd(),node.yd(),node.zd());
        for (int j=0; j < struts.size(); j++) {
          int offset;
          if (node == struts.get(j).start()) {
            offset=struts.get(j).getIndex() * 2;
          }
 else {
            offset=(struts.get(j).getIndex() * 2) + 1;
          }
          for (int k=0; k < strutFacets; k++) {
            hullPoints.add(strutNodeConnections[offset].vertices.get(k));
            br=Math.min(br,strutNodeConnections[offset].radius);
          }
        }
        br*=fillfactor;
        final int n=hullPoints.size();
        if ((nodeTypes[i] != NodeType.STRAIGHT) && (nodeTypes[i] != NodeType.BEND) && (!suppressBalljoint)) {
          final HE_Mesh ball=new HE_Mesh(new HEC_Sphere().setRadius(br).setUFacets(strutFacets).setVFacets(strutFacets).setCenter(node));
          hullPoints.addAll(ball.getVerticesAsList());
        }
        final HEC_ConvexHull ch=new HEC_ConvexHull().setPointsFromVertices(hullPoints);
        try {
          final HE_Mesh tmp=new HE_Mesh(ch);
          final Map<Long,Integer> vertexToPointIndex=ch.vertexToPointIndex;
          final Iterator<HE_Face> tmpfItr=tmp.fItr();
          HE_Face f;
          HE_Halfedge tmphe;
          final ArrayList<HE_Face> facesToRemove=new ArrayList<HE_Face>();
          while (tmpfItr.hasNext()) {
            f=tmpfItr.next();
            f.setTemporaryLabel(2);
            tmphe=f.getHalfedge();
            int initid=vertexToPointIndex.get(tmphe.getVertex().key());
            boolean endface=(initid < n);
            initid=initid / strutFacets;
            do {
              final int id=vertexToPointIndex.get(tmphe.getVertex().key());
              endface=((id / strutFacets) == initid) && (id < n);
              if (!endface) {
                break;
              }
              tmphe=tmphe.getNextInFace();
            }
 while (tmphe != f.getHalfedge());
            if (endface) {
              facesToRemove.add(f);
            }
          }
          for (int j=0; j < facesToRemove.size(); j++) {
            tmp.deleteFace(facesToRemove.get(j));
          }
          tmp.cleanUnusedElementsByFace();
          tmp.uncapBoundaryHalfedges();
          for (int j=0; j < struts.size(); j++) {
            int offset;
            if (node == struts.get(j).start()) {
              offset=struts.get(j).getIndex() * 2;
            }
 else {
              offset=(struts.get(j).getIndex() * 2) + 1;
            }
            final WB_Vector v=strutNodeConnections[offset].dir;
            v.mulSelf(strutNodeConnections[offset].offset - strutNodeConnections[offset].maxoffset);
            for (int k=0; k < strutFacets; k++) {
              strutNodeConnections[offset].vertices.get(k).addSelf(v);
            }
          }
          final Iterator<HE_Halfedge> tmpheItr=tmp.heItr();
          HE_Vertex tmpv;
          while (tmpheItr.hasNext()) {
            tmphe=tmpheItr.next();
            tmpv=tmphe.getVertex();
            final int j=vertexToPointIndex.get(tmpv.key());
            mesh.setVertex(tmphe,hullPoints.get(j));
            if (j >= n) {
              mesh.setHalfedge(hullPoints.get(j),tmphe);
            }
          }
          tmp.cleanUnusedElementsByFace();
          mesh.add(tmp);
        }
 catch (        final Exception e) {
        }
      }
    }
    i++;
  }
}

Fixed version (ground truth):
/** 
 */
private void createNodes(){
  int i=0;
  for (  WB_FrameNode node : frame.getNodes()) {
    node=frame.getNode(i);
    final ArrayList<WB_FrameStrut> struts=node.getStruts();
    final ArrayList<HE_Vertex> hullPoints=new ArrayList<HE_Vertex>();
    if (nodeTypes[i] == NodeType.ENDPOINT) {
      if (cap) {
        int offset;
        if (node == struts.get(0).start()) {
          offset=struts.get(0).getIndex() * 2;
        }
 else {
          offset=(struts.get(0).getIndex() * 2) + 1;
        }
        final ArrayList<HE_Halfedge> hes=new ArrayList<HE_Halfedge>(strutFacets);
        final HE_Face f=new HE_Face();
        mesh.add(f);
        for (int k=0; k < strutFacets; k++) {
          final HE_Halfedge he=new HE_Halfedge();
          mesh.setVertex(he,strutNodeConnections[offset].vertices.get(k));
          mesh.setFace(he,f);
          hes.add(he);
          mesh.add(he);
        }
        mesh.setHalfedge(f,hes.get(0));
        f.setInternalLabel(3);
        if (node == struts.get(0).start()) {
          for (int k=0, j=strutFacets - 1; k < strutFacets; j=k, k++) {
            mesh.setNext(hes.get(k),hes.get(j));
          }
        }
 else {
          for (int k=0, j=strutFacets - 1; k < strutFacets; j=k, k++) {
            mesh.setNext(hes.get(j),hes.get(k));
          }
        }
      }
    }
 else {
      if ((nodeTypes[i] != NodeType.ISOLATED) || createIsolatedNodes) {
        double br=strutRadius.evaluate(node.xd(),node.yd(),node.zd());
        for (int j=0; j < struts.size(); j++) {
          int offset;
          if (node == struts.get(j).start()) {
            offset=struts.get(j).getIndex() * 2;
          }
 else {
            offset=(struts.get(j).getIndex() * 2) + 1;
          }
          for (int k=0; k < strutFacets; k++) {
            hullPoints.add(strutNodeConnections[offset].vertices.get(k));
            br=Math.min(br,strutNodeConnections[offset].radius);
          }
        }
        br*=fillfactor;
        final int n=hullPoints.size();
        if ((nodeTypes[i] != NodeType.STRAIGHT) && (nodeTypes[i] != NodeType.BEND) && (!suppressBalljoint)) {
          final HE_Mesh ball=new HE_Mesh(new HEC_Sphere().setRadius(br).setUFacets(strutFacets).setVFacets(strutFacets).setCenter(node));
          hullPoints.addAll(ball.getVerticesAsList());
        }
        final HEC_ConvexHull ch=new HEC_ConvexHull().setPointsFromVertices(hullPoints);
        try {
          final HE_Mesh tmp=new HE_Mesh(ch);
          final Map<Long,Integer> vertexToPointIndex=ch.vertexToPointIndex;
          final Iterator<HE_Face> tmpfItr=tmp.fItr();
          HE_Face f;
          HE_Halfedge tmphe;
          final ArrayList<HE_Face> facesToRemove=new ArrayList<HE_Face>();
          while (tmpfItr.hasNext()) {
            f=tmpfItr.next();
            f.setInternalLabel(2);
            tmphe=f.getHalfedge();
            int initid=vertexToPointIndex.get(tmphe.getVertex().key());
            boolean endface=(initid < n);
            initid=initid / strutFacets;
            do {
              final int id=vertexToPointIndex.get(tmphe.getVertex().key());
              endface=((id / strutFacets) == initid) && (id < n);
              if (!endface) {
                break;
              }
              tmphe=tmphe.getNextInFace();
            }
 while (tmphe != f.getHalfedge());
            if (endface) {
              facesToRemove.add(f);
            }
          }
          for (int j=0; j < facesToRemove.size(); j++) {
            tmp.deleteFace(facesToRemove.get(j));
          }
          tmp.cleanUnusedElementsByFace();
          tmp.uncapBoundaryHalfedges();
          for (int j=0; j < struts.size(); j++) {
            int offset;
            if (node == struts.get(j).start()) {
              offset=struts.get(j).getIndex() * 2;
            }
 else {
              offset=(struts.get(j).getIndex() * 2) + 1;
            }
            final WB_Vector v=strutNodeConnections[offset].dir;
            v.mulSelf(strutNodeConnections[offset].offset - strutNodeConnections[offset].maxoffset);
            for (int k=0; k < strutFacets; k++) {
              strutNodeConnections[offset].vertices.get(k).addSelf(v);
            }
          }
          final Iterator<HE_Halfedge> tmpheItr=tmp.heItr();
          HE_Vertex tmpv;
          while (tmpheItr.hasNext()) {
            tmphe=tmpheItr.next();
            tmpv=tmphe.getVertex();
            final int j=vertexToPointIndex.get(tmpv.key());
            mesh.setVertex(tmphe,hullPoints.get(j));
            if (j >= n) {
              mesh.setHalfedge(hullPoints.get(j),tmphe);
            }
          }
          tmp.cleanUnusedElementsByFace();
          mesh.add(tmp);
        }
 catch (        final Exception e) {
        }
      }
    }
    i++;
  }
}