Program: 86588
Project: 86588
Buggy source:
/** 
 * Add a point on an edge
 * @param anEdge
 * @param aPoint
 * @return impactedTriangles
 */
private LinkedList<MyTriangle> processAddPoint(MyEdge anEdge,MyPoint aPoint){
  LinkedList<MyTriangle> impactedTriangles=new LinkedList<MyTriangle>();
  if (!anEdge.isExtremity(aPoint)) {
    MyPoint start=anEdge.getStartPoint();
    MyPoint end=anEdge.getEndPoint();
    MyTriangle triangleList[]=new MyTriangle[2];
    MyTriangle new_triangleList[]=new MyTriangle[2];
    MyEdge remainEdge=null;
    MyPoint alterPointList[]=new MyPoint[2];
    MyEdge newEdges[]=new MyEdge[3];
    MyEdge alterEdgeList_start[]=new MyEdge[2];
    MyEdge alterEdgeList_end[]=new MyEdge[2];
    MyTriangle alterTriangleList_end[]=new MyTriangle[2];
    for (int k=0; k < 2; k++) {
      MyTriangle aTriangle1=null;
      if (k == 0)       aTriangle1=anEdge.getLeft();
 else       aTriangle1=anEdge.getRight();
      triangleList[k]=aTriangle1;
      new_triangleList[k]=null;
      alterPointList[k]=null;
      newEdges[k]=null;
      alterEdgeList_start[k]=null;
      alterEdgeList_end[k]=null;
      alterTriangleList_end[k]=null;
      if (aTriangle1 != null) {
        new_triangleList[k]=new MyTriangle(aTriangle1);
        alterPointList[k]=aTriangle1.getAlterPoint(start,end);
        newEdges[k]=new MyEdge(alterPointList[k],aPoint);
        alterEdgeList_start[k]=aTriangle1.getEdgeFromPoints(start,alterPointList[k]);
        alterEdgeList_end[k]=aTriangle1.getEdgeFromPoints(end,alterPointList[k]);
        if (alterEdgeList_end[k] == null)         System.out.println("String_Node_Str");
 else         if (alterEdgeList_end[k].getLeft() == aTriangle1)         alterTriangleList_end[k]=alterEdgeList_end[k].getRight();
 else         alterTriangleList_end[k]=alterEdgeList_end[k].getLeft();
      }
    }
    remainEdge=new MyEdge(anEdge);
    remainEdge.setStartPoint(aPoint);
    anEdge.setEndPoint(aPoint);
    for (int k=0; k < 2; k++) {
      if (new_triangleList[k] != null) {
        int i=0;
        boolean found=false;
        while ((i < 3) && (!found)) {
          if (new_triangleList[k].edges[i] == anEdge)           found=true;
 else           i++;
        }
        if (found)         new_triangleList[k].edges[i]=remainEdge;
        i=0;
        found=false;
        while ((i < 3) && (!found)) {
          if (new_triangleList[k].edges[i] == alterEdgeList_start[k])           found=true;
 else           i++;
        }
        if (found)         new_triangleList[k].edges[i]=newEdges[k];
      }
      if (triangleList[k] != null) {
        boolean found=false;
        int i=0;
        found=false;
        while ((i < 3) && (!found)) {
          if (triangleList[k].edges[i] == alterEdgeList_end[k])           found=true;
 else           i++;
        }
        if (found)         triangleList[k].edges[i]=newEdges[k];
      }
    }
    for (int k=0; k < 2; k++) {
      if (alterEdgeList_end[k] != null) {
        if (alterEdgeList_end[k].getLeft() == triangleList[k])         alterEdgeList_end[k].setLeft(new_triangleList[k]);
 else         alterEdgeList_end[k].setRight(new_triangleList[k]);
      }
    }
    for (int k=0; k < 2; k++) {
      if (remainEdge != null) {
        if (remainEdge.getLeft() == triangleList[k])         remainEdge.setLeft(new_triangleList[k]);
        if (remainEdge.getRight() == triangleList[k])         remainEdge.setRight(new_triangleList[k]);
      }
    }
    for (int k=0; k < 2; k++) {
      if (newEdges[k] != null) {
        if (newEdges[k].isLeft(end)) {
          newEdges[k].setLeft(new_triangleList[k]);
          newEdges[k].setRight(triangleList[k]);
        }
 else {
          newEdges[k].setLeft(triangleList[k]);
          newEdges[k].setRight(new_triangleList[k]);
        }
      }
    }
    for (int k=0; k < 2; k++) {
      if (triangleList[k] != null)       triangleList[k].recomputeCenter();
      if (new_triangleList[k] != null)       new_triangleList[k].recomputeCenter();
    }
    points.add(aPoint);
    newEdges[2]=remainEdge;
    for (int k=0; k < 3; k++) {
      if (newEdges[k] != null) {
        edges.add(newEdges[k]);
        if (!isMeshComputed())         if (!badEdgesQueueList.contains(newEdges[k]))         badEdgesQueueList.add(newEdges[k]);
      }
    }
    for (int k=0; k < 2; k++) {
      if (new_triangleList[k] != null)       triangles.add(new_triangleList[k]);
    }
    for (int k=0; k < 2; k++) {
      if (triangleList[k] != null)       impactedTriangles.add(triangleList[k]);
      if (new_triangleList[k] != null)       impactedTriangles.add(new_triangleList[k]);
    }
  }
  return impactedTriangles;
}

Fixed version (ground truth):
/** 
 * Add a point on an edge
 * @param anEdge
 * @param aPoint
 * @return impactedTriangles
 */
private LinkedList<MyTriangle> processAddPoint(MyEdge anEdge,MyPoint aPoint){
  LinkedList<MyTriangle> impactedTriangles=new LinkedList<MyTriangle>();
  if (!anEdge.isExtremity(aPoint)) {
    MyPoint start=anEdge.getStartPoint();
    MyPoint end=anEdge.getEndPoint();
    MyTriangle triangleList[]=new MyTriangle[2];
    MyTriangle new_triangleList[]=new MyTriangle[2];
    MyEdge remainEdge=null;
    MyPoint alterPointList[]=new MyPoint[2];
    MyEdge newEdges[]=new MyEdge[3];
    MyEdge alterEdgeList_start[]=new MyEdge[2];
    MyEdge alterEdgeList_end[]=new MyEdge[2];
    MyTriangle alterTriangleList_end[]=new MyTriangle[2];
    for (int k=0; k < 2; k++) {
      MyTriangle aTriangle1=null;
      if (k == 0)       aTriangle1=anEdge.getLeft();
 else       aTriangle1=anEdge.getRight();
      triangleList[k]=aTriangle1;
      new_triangleList[k]=null;
      alterPointList[k]=null;
      newEdges[k]=null;
      alterEdgeList_start[k]=null;
      alterEdgeList_end[k]=null;
      alterTriangleList_end[k]=null;
      if (aTriangle1 != null) {
        new_triangleList[k]=new MyTriangle(aTriangle1);
        alterPointList[k]=aTriangle1.getAlterPoint(start,end);
        newEdges[k]=new MyEdge(alterPointList[k],aPoint);
        alterEdgeList_start[k]=aTriangle1.getEdgeFromPoints(start,alterPointList[k]);
        alterEdgeList_end[k]=aTriangle1.getEdgeFromPoints(end,alterPointList[k]);
        if (alterEdgeList_end[k] == null)         System.out.println("String_Node_Str");
 else         if (alterEdgeList_end[k].getLeft() == aTriangle1)         alterTriangleList_end[k]=alterEdgeList_end[k].getRight();
 else         alterTriangleList_end[k]=alterEdgeList_end[k].getLeft();
      }
    }
    remainEdge=new MyEdge(anEdge);
    remainEdge.setStartPoint(aPoint);
    anEdge.setEndPoint(aPoint);
    for (int k=0; k < 2; k++) {
      if (new_triangleList[k] != null) {
        int i=0;
        boolean found=false;
        while ((i < 3) && (!found)) {
          if (new_triangleList[k].edges[i] == anEdge)           found=true;
 else           i++;
        }
        if (found)         new_triangleList[k].edges[i]=remainEdge;
        i=0;
        found=false;
        while ((i < 3) && (!found)) {
          if (new_triangleList[k].edges[i] == alterEdgeList_start[k])           found=true;
 else           i++;
        }
        if (found)         new_triangleList[k].edges[i]=newEdges[k];
      }
      if (triangleList[k] != null) {
        boolean found=false;
        int i=0;
        found=false;
        while ((i < 3) && (!found)) {
          if (triangleList[k].edges[i] == alterEdgeList_end[k])           found=true;
 else           i++;
        }
        if (found)         triangleList[k].edges[i]=newEdges[k];
      }
    }
    for (int k=0; k < 2; k++) {
      if (alterEdgeList_end[k] != null) {
        if (alterEdgeList_end[k].getLeft() == triangleList[k])         alterEdgeList_end[k].setLeft(new_triangleList[k]);
 else         alterEdgeList_end[k].setRight(new_triangleList[k]);
      }
    }
    for (int k=0; k < 2; k++) {
      if (remainEdge != null) {
        if (remainEdge.getLeft() == triangleList[k])         remainEdge.setLeft(new_triangleList[k]);
        if (remainEdge.getRight() == triangleList[k])         remainEdge.setRight(new_triangleList[k]);
      }
    }
    for (int k=0; k < 2; k++) {
      if (newEdges[k] != null) {
        if (newEdges[k].isLeft(end)) {
          newEdges[k].setLeft(new_triangleList[k]);
          newEdges[k].setRight(triangleList[k]);
        }
 else {
          newEdges[k].setLeft(triangleList[k]);
          newEdges[k].setRight(new_triangleList[k]);
        }
      }
    }
    for (int k=0; k < 2; k++) {
      if (triangleList[k] != null)       triangleList[k].recomputeCenter();
      if (new_triangleList[k] != null)       new_triangleList[k].recomputeCenter();
    }
    points.add(aPoint);
    newEdges[2]=remainEdge;
    for (int k=0; k < 3; k++) {
      if (newEdges[k] != null) {
        edges.add(newEdges[k]);
        if (!isMeshComputed())         if (!badEdgesQueueList.contains(newEdges[k]))         badEdgesQueueList.add(newEdges[k]);
      }
    }
    for (int k=0; k < 2; k++) {
      if (new_triangleList[k] != null)       triangles.add(new_triangleList[k]);
    }
    for (int k=0; k < 2; k++) {
      if (triangleList[k] != null)       impactedTriangles.add(triangleList[k]);
      if (new_triangleList[k] != null)       impactedTriangles.add(new_triangleList[k]);
    }
  }
  this.trianglesQuadTrees.cancelUsability();
  return impactedTriangles;
}