Program: 86586
Project: 86586
Buggy source:
/** 
 * Refine mesh according to the type of refinement that has been defined in the refinement variable
 * @throws DelaunayError
 */
public void refineMesh() throws DelaunayError {
  if (!isMeshComputed())   throw new DelaunayError(DelaunayError.DelaunayError_notGenerated);
 else {
    LinkedList<MyTriangle> badTrianglesList=new LinkedList<MyTriangle>();
    LinkedList<MyPoint> barycenter=new LinkedList<MyPoint>();
    boolean softInterpolate=((refinement & refinement_softInterpolate) != 0);
    int iterDone=0;
    int nbDone=0;
    do {
      iterDone++;
      nbDone=0;
      if ((refinement & refinement_maxArea) != 0) {
        for (        MyTriangle aTriangle : triangles) {
          double area=aTriangle.computeArea();
          if (area > maxArea) {
            badTrianglesList.add(aTriangle);
            MyPoint newPoint=aTriangle.getBarycenter();
            if (softInterpolate) {
              double ZValue=aTriangle.softInterpolateZ(newPoint);
              newPoint.setZ(ZValue);
            }
            barycenter.add(newPoint);
          }
        }
        while (!badTrianglesList.isEmpty()) {
          MyTriangle aTriangle=badTrianglesList.getFirst();
          MyPoint newPoint=barycenter.getFirst();
          badTrianglesList.removeFirst();
          barycenter.removeFirst();
          nbDone++;
          addPoint(aTriangle,newPoint);
        }
      }
      if ((refinement & refinement_minAngle) != 0) {
        for (        MyTriangle aTriangle : triangles) {
          if (aTriangle.badAngle(minAngle) >= 0)           badTrianglesList.add(aTriangle);
        }
        while (!badTrianglesList.isEmpty()) {
          MyTriangle aTriangle=badTrianglesList.getFirst();
          badTrianglesList.removeFirst();
          MyEdge longest=aTriangle.edges[0];
          double maxLength=longest.getSquared2DLength();
          for (int i=1; i < 3; i++) {
            double length=aTriangle.edges[i].getSquared2DLength();
            ;
            if (length > maxLength) {
              maxLength=length;
              longest=aTriangle.edges[i];
            }
          }
          tryFlipFlap(aTriangle,longest);
        }
      }
      if ((refinement & refinement_obtuseAngle) != 0) {
      }
    }
 while (nbDone != 0);
  }
}

Fixed version (ground truth):
/** 
 * Refine mesh according to the type of refinement that has been defined in the refinement variable
 * @throws DelaunayError
 */
public void refineMesh() throws DelaunayError {
  if (!isMeshComputed())   throw new DelaunayError(DelaunayError.DelaunayError_notGenerated);
 else {
    LinkedList<MyTriangle> badTrianglesList=new LinkedList<MyTriangle>();
    LinkedList<MyPoint> barycenter=new LinkedList<MyPoint>();
    boolean softInterpolate=((refinement & refinement_softInterpolate) != 0);
    int iterDone=0;
    int nbDone=0;
    do {
      iterDone++;
      nbDone=0;
      if ((refinement & refinement_maxArea) != 0) {
        for (        MyTriangle aTriangle : triangles) {
          double area=aTriangle.computeArea();
          if (area > maxArea) {
            badTrianglesList.add(aTriangle);
            MyPoint newPoint=aTriangle.getBarycenter();
            if (softInterpolate) {
              double ZValue=aTriangle.softInterpolateZ(newPoint);
              newPoint.setZ(ZValue);
            }
            barycenter.add(newPoint);
          }
        }
        while (!badTrianglesList.isEmpty()) {
          MyTriangle aTriangle=badTrianglesList.getFirst();
          MyPoint newPoint=barycenter.getFirst();
          badTrianglesList.removeFirst();
          barycenter.removeFirst();
          nbDone++;
          addPoint(aTriangle,newPoint);
        }
      }
      if ((refinement & refinement_minAngle) != 0) {
        for (        MyTriangle aTriangle : triangles) {
          if (aTriangle.badAngle(minAngle) >= 0)           badTrianglesList.add(aTriangle);
        }
        while (!badTrianglesList.isEmpty()) {
          MyTriangle aTriangle=badTrianglesList.getFirst();
          badTrianglesList.removeFirst();
          MyEdge longest=aTriangle.edges[0];
          double maxLength=longest.getSquared2DLength();
          for (int i=1; i < 3; i++) {
            double length=aTriangle.edges[i].getSquared2DLength();
            ;
            if (length > maxLength) {
              maxLength=length;
              longest=aTriangle.edges[i];
            }
          }
          tryFlipFlap(aTriangle,longest);
        }
      }
      if ((refinement & refinement_obtuseAngle) != 0) {
        for (        MyTriangle aTriangle : triangles) {
          if (aTriangle.getMaxAmgle() >= 90)           badTrianglesList.add(aTriangle);
        }
        while (!badTrianglesList.isEmpty()) {
          MyTriangle aTriangle=badTrianglesList.getFirst();
          badTrianglesList.removeFirst();
        }
      }
    }
 while (nbDone != 0);
    this.trianglesQuadTrees.cancelUsability();
  }
}