Program: 86554
Project: 86554
Buggy source:
/** 
 * Split the edges that have benn found to be encroached.
 * @param ed The edge to be split.
 * @param minLength The threshold used to determine the minimum length of an edge that could be added by splitting an encroached edge.
 * @throws DelaunayError
 */
final void splitEncroachedEdge(DEdge ed,double minLength) throws DelaunayError {
  DTriangle left=ed.getLeft();
  DTriangle right=ed.getRight();
  DPoint middle=ed.getMiddle();
  DEdge secondHalf=new DEdge(middle,ed.getEndPoint());
  if (secondHalf.getSquared2DLength() < minLength * minLength) {
    return;
  }
  middle.setGID(++pointGID);
  points.add(middle);
  secondHalf.setGID(++edgeGID);
  DEdge ed1=null;
  DEdge last1=null;
  DEdge startOp1=null;
  DTriangle other1=null;
  if (left != null) {
    ed1=new DEdge(middle,left.getOppositePoint(ed));
    ed1.setGID(++edgeGID);
    last1=left.getOppositeEdge(ed.getEndPoint());
    startOp1=left.getOppositeEdge(ed.getStartPoint());
    other1=new DTriangle(ed1,secondHalf,startOp1);
    other1.setGID(++triangleGID);
  }
  DEdge ed2=null;
  DEdge last2=null;
  DEdge startOp2=null;
  DTriangle other2=null;
  if (right != null) {
    ed2=new DEdge(middle,right.getOppositePoint(ed));
    ed2.setGID(++edgeGID);
    last2=right.getOppositeEdge(ed.getEndPoint());
    startOp2=right.getOppositeEdge(ed.getStartPoint());
    other2=new DTriangle(ed2,secondHalf,startOp2);
    other2.setGID(++triangleGID);
  }
  secondHalf.setLocked(ed.isLocked());
  ed.setEndPoint(middle);
  badEdgesQueueList=new LinkedList<DEdge>();
  if (left != null) {
    int indexExc=left.getEdgeIndex(startOp1);
    left.setEdge(indexExc,ed1);
    left.recomputeCenter();
    ed1.setLeft(left);
    ed1.setRight(other1);
    if (startOp1.isRight(middle)) {
      startOp1.setRight(other1);
    }
 else {
      startOp1.setLeft(other1);
    }
    secondHalf.setLeft(other1);
    triangleList.add(other1);
    badEdgesQueueList.add(last1);
    badEdgesQueueList.add(ed1);
    badEdgesQueueList.add(startOp1);
    edges.add(ed1);
  }
  if (right != null) {
    int indexExc=right.getEdgeIndex(startOp2);
    right.setEdge(indexExc,ed2);
    right.recomputeCenter();
    ed2.setRight(right);
    ed2.setLeft(other2);
    if (startOp2.isRight(middle)) {
      startOp2.setRight(other2);
    }
 else {
      startOp2.setLeft(other2);
    }
    secondHalf.setRight(other2);
    triangleList.add(other2);
    badEdgesQueueList.add(last2);
    badEdgesQueueList.add(ed2);
    badEdgesQueueList.add(startOp2);
    edges.add(ed2);
  }
  processBadEdges();
  if (ed.isLocked()) {
    constraintEdges.add(secondHalf);
  }
  edges.add(secondHalf);
  if (ed.isEncroached()) {
    splitEncroachedEdge(ed,minLength);
  }
  if (secondHalf.isEncroached()) {
    splitEncroachedEdge(secondHalf,minLength);
  }
  if (right != null) {
    if (last2.isEncroached()) {
      splitEncroachedEdge(last2,minLength);
    }
    if (startOp2.isEncroached()) {
      splitEncroachedEdge(startOp2,minLength);
    }
  }
  if (left != null) {
    if (last1.isEncroached()) {
      splitEncroachedEdge(last1,minLength);
    }
    if (startOp1.isEncroached()) {
      splitEncroachedEdge(startOp1,minLength);
    }
  }
}

Fixed version (ground truth):
/** 
 * Split the edges that have benn found to be encroached.
 * @param ed The edge to be split.
 * @param minLength The threshold used to determine the minimum length of an edge that could be added by splitting an encroached edge.
 * @throws DelaunayError
 */
final void splitEncroachedEdge(DEdge ed,double minLength) throws DelaunayError {
  badEdgesQueueList=new LinkedList<DEdge>();
  DTriangle left=ed.getLeft();
  DTriangle right=ed.getRight();
  DPoint middle=ed.getMiddle();
  DEdge secondHalf=new DEdge(middle,ed.getEndPoint());
  if (secondHalf.getSquared2DLength() < minLength * minLength) {
    return;
  }
  middle.setGID(++pointGID);
  points.add(middle);
  secondHalf.setGID(++edgeGID);
  DEdge ed1=null;
  DEdge last1=null;
  DEdge startOp1=null;
  DTriangle other1=null;
  if (left != null) {
    ed1=new DEdge(middle,left.getOppositePoint(ed));
    ed1.setGID(++edgeGID);
    last1=left.getOppositeEdge(ed.getEndPoint());
    startOp1=left.getOppositeEdge(ed.getStartPoint());
    other1=new DTriangle(ed1,secondHalf,startOp1);
    other1.setGID(++triangleGID);
  }
  DEdge ed2=null;
  DEdge last2=null;
  DEdge startOp2=null;
  DTriangle other2=null;
  if (right != null) {
    ed2=new DEdge(middle,right.getOppositePoint(ed));
    ed2.setGID(++edgeGID);
    last2=right.getOppositeEdge(ed.getEndPoint());
    startOp2=right.getOppositeEdge(ed.getStartPoint());
    other2=new DTriangle(ed2,secondHalf,startOp2);
    other2.setGID(++triangleGID);
  }
  secondHalf.setLocked(ed.isLocked());
  ed.setEndPoint(middle);
  badEdgesQueueList=new LinkedList<DEdge>();
  if (left != null) {
    int indexExc=left.getEdgeIndex(startOp1);
    left.setEdge(indexExc,ed1);
    left.recomputeCenter();
    ed1.setLeft(left);
    ed1.setRight(other1);
    if (startOp1.isRight(middle)) {
      startOp1.setRight(other1);
    }
 else {
      startOp1.setLeft(other1);
    }
    secondHalf.setLeft(other1);
    triangleList.add(other1);
    badEdgesQueueList.add(last1);
    badEdgesQueueList.add(ed1);
    badEdgesQueueList.add(startOp1);
    edges.add(ed1);
  }
  if (right != null) {
    int indexExc=right.getEdgeIndex(startOp2);
    right.setEdge(indexExc,ed2);
    right.recomputeCenter();
    ed2.setRight(right);
    ed2.setLeft(other2);
    if (startOp2.isRight(middle)) {
      startOp2.setRight(other2);
    }
 else {
      startOp2.setLeft(other2);
    }
    secondHalf.setRight(other2);
    triangleList.add(other2);
    badEdgesQueueList.add(last2);
    badEdgesQueueList.add(ed2);
    badEdgesQueueList.add(startOp2);
    edges.add(ed2);
  }
  processBadEdges();
  if (ed.isLocked()) {
    constraintEdges.add(secondHalf);
  }
  edges.add(secondHalf);
  if (ed.isEncroached()) {
    splitEncroachedEdge(ed,minLength);
  }
  if (secondHalf.isEncroached()) {
    splitEncroachedEdge(secondHalf,minLength);
  }
  if (right != null) {
    if (last2.isEncroached()) {
      splitEncroachedEdge(last2,minLength);
    }
    if (startOp2.isEncroached()) {
      splitEncroachedEdge(startOp2,minLength);
    }
  }
  if (left != null) {
    if (last1.isEncroached()) {
      splitEncroachedEdge(last1,minLength);
    }
    if (startOp1.isEncroached()) {
      splitEncroachedEdge(startOp1,minLength);
    }
  }
}