Program: 86579
Project: 86579
Buggy source:
/** 
 * This test checks that intersections are well processed by the sweep line algorithm. It obviously directly depends on the previous tests, and on the algorithms checked in these tests.
 */
public void testProcessIntersections() throws DelaunayError {
  ConstrainedMesh mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,0,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  List<MyEdge> edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 4);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,0,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 2);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,2,0),new MyPoint(1,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,4,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(3,6,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,4,0),new MyPoint(7,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,3,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 5);
  MyEdge e1=edgeList.get(0);
  MyEdge e2;
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) == -1);
  }
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,4,0),new MyPoint(2,0,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(2,2,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(23.754617414248024,25.03430079155673,8.321899736147756,29.974500344589934,23.130254996554104,8.9565816678153));
  mesh.addConstraintEdge(new MyEdge(23.754617414248024,25.03430079155673,8.321899736147756,30.606126914660827,32.288840262582056,15.237518756619197));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 2);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,4,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(2,3,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  assertTrue(edgeList.get(0).equals(new MyEdge(2,1,0,2,2,0)));
  assertTrue(edgeList.get(1).equals(new MyEdge(2,2,0,2,3,0)));
  assertTrue(edgeList.get(2).equals(new MyEdge(2,3,0,2,4,0)));
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,4,0),new MyPoint(2,3,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(2,3,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 2);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,0,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,0,0),new MyPoint(2,1,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 6);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  assertTrue(sillyCheckIntersection(edgeList));
  e1=edgeList.get(0);
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) == -1);
  }
  mesh=new ConstrainedMesh();
  MyEdge edge1=new MyEdge(29.04662741160085,52.16572027299656,68.38018218763128,21.70784635428322,52.702506064941865,70.26548339515645);
  mesh.addConstraintEdge(edge1);
  MyEdge edge2=new MyEdge(32.696545765031715,62.25043024404333,48.051049255488714,27.630378535764756,51.60370887400286,81.41914742448961);
  mesh.addConstraintEdge(edge2);
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 4);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(50,17,11,1,32,6));
  mesh.addConstraintEdge(new MyEdge(97,30,99,46,1,98));
  mesh.addConstraintEdge(new MyEdge(63,17,56,91,26,35));
  mesh.addConstraintEdge(new MyEdge(59,12,96,47,35,24));
  mesh.addConstraintEdge(new MyEdge(44,44,10,72,7,27));
  mesh.addConstraintEdge(new MyEdge(29,9,35,33,67,39));
  mesh.addConstraintEdge(new MyEdge(4,5,18,89,12,17));
  mesh.addConstraintEdge(new MyEdge(38,81,70,33,35,36));
  mesh.addConstraintEdge(new MyEdge(70,74,55,2,2,64));
  mesh.addConstraintEdge(new MyEdge(51,50,47,8,21,73));
  edgeList=mesh.getConstraintEdges();
  e1=edgeList.get(0);
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) == -1);
  }
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(sillyCheckIntersection(edgeList));
  mesh=new ConstrainedMesh();
  List<MyEdge> randomEdges=getRandomEdges(1000);
  for (  MyEdge edge : randomEdges) {
    mesh.addConstraintEdge(edge);
  }
  double t1=System.currentTimeMillis();
  mesh.forceConstraintIntegrity();
  mesh.forceConstraintIntegrity();
  double t2=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (t2 - t1));
  assertTrue(sillyCheckIntersection(edgeList));
  edgeList=mesh.getConstraintEdges();
  e1=edgeList.get(0);
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) < 1);
  }
  t1=System.currentTimeMillis();
  boolean bool=sillyCheckIntersection(edgeList);
  t2=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (t2 - t1));
  assertTrue(bool);
}

Fixed version (ground truth):
/** 
 * This test checks that intersections are well processed by the sweep line algorithm. It obviously directly depends on the previous tests, and on the algorithms checked in these tests.
 */
public void testProcessIntersections() throws DelaunayError {
  ConstrainedMesh mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,0,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  List<MyEdge> edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 4);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,0,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 2);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,2,0),new MyPoint(1,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,4,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(3,6,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,4,0),new MyPoint(7,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,3,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 5);
  MyEdge e1=edgeList.get(0);
  MyEdge e2;
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) == -1);
  }
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(4,1,0),new MyPoint(5,6,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(4,4,0),new MyPoint(10,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,3,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,3,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,4,0),new MyPoint(2,1,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 8);
  e1=edgeList.get(0);
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) == -1);
  }
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(4,1,0),new MyPoint(8,6,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(4,4,0),new MyPoint(10,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(4,8,0),new MyPoint(10,10,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(5,10,0),new MyPoint(9,9,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 8);
  e1=edgeList.get(0);
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) == -1);
  }
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,3,0),new MyPoint(5,3,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,4,0),new MyPoint(3,1,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,0,0),new MyPoint(5,4,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 9);
  e1=edgeList.get(0);
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) == -1);
  }
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,4,0),new MyPoint(2,0,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,3,0),new MyPoint(10,6,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(7,5,0),new MyPoint(13,7,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(7,7,0),new MyPoint(13,5,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 5);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,3,0),new MyPoint(10,6,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(7,5,0),new MyPoint(13,7,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(7,7,0),new MyPoint(10,3,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 6);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(23.754617414248024,25.03430079155673,8.321899736147756,29.974500344589934,23.130254996554104,8.9565816678153));
  mesh.addConstraintEdge(new MyEdge(23.754617414248024,25.03430079155673,8.321899736147756,30.606126914660827,32.288840262582056,15.237518756619197));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 2);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,4,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(2,3,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 3);
  assertTrue(edgeList.get(0).equals(new MyEdge(2,1,0,2,2,0)));
  assertTrue(edgeList.get(1).equals(new MyEdge(2,2,0,2,3,0)));
  assertTrue(edgeList.get(2).equals(new MyEdge(2,3,0,2,4,0)));
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,4,0),new MyPoint(2,3,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(2,1,0),new MyPoint(2,3,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 2);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(new MyPoint(1,1,0),new MyPoint(2,2,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,2,0),new MyPoint(2,0,0)));
  mesh.addConstraintEdge(new MyEdge(new MyPoint(0,0,0),new MyPoint(2,1,0)));
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 6);
  assertTrue(mesh.listContainsPoint(new MyPoint(1,1,0)) > -1);
  assertTrue(sillyCheckIntersection(edgeList));
  e1=edgeList.get(0);
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) == -1);
  }
  mesh=new ConstrainedMesh();
  MyEdge edge1=new MyEdge(29.04662741160085,52.16572027299656,68.38018218763128,21.70784635428322,52.702506064941865,70.26548339515645);
  mesh.addConstraintEdge(edge1);
  MyEdge edge2=new MyEdge(32.696545765031715,62.25043024404333,48.051049255488714,27.630378535764756,51.60370887400286,81.41914742448961);
  mesh.addConstraintEdge(edge2);
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(edgeList.size() == 4);
  mesh=new ConstrainedMesh();
  mesh.addConstraintEdge(new MyEdge(50,17,11,1,32,6));
  mesh.addConstraintEdge(new MyEdge(97,30,99,46,1,98));
  mesh.addConstraintEdge(new MyEdge(63,17,56,91,26,35));
  mesh.addConstraintEdge(new MyEdge(59,12,96,47,35,24));
  mesh.addConstraintEdge(new MyEdge(44,44,10,72,7,27));
  mesh.addConstraintEdge(new MyEdge(29,9,35,33,67,39));
  mesh.addConstraintEdge(new MyEdge(4,5,18,89,12,17));
  mesh.addConstraintEdge(new MyEdge(38,81,70,33,35,36));
  mesh.addConstraintEdge(new MyEdge(70,74,55,2,2,64));
  mesh.addConstraintEdge(new MyEdge(51,50,47,8,21,73));
  edgeList=mesh.getConstraintEdges();
  e1=edgeList.get(0);
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) == -1);
  }
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  assertTrue(sillyCheckIntersection(edgeList));
  mesh=new ConstrainedMesh();
  List<MyEdge> randomEdges=getRandomEdges(1000);
  for (  MyEdge edge : randomEdges) {
    mesh.addConstraintEdge(edge);
  }
  double t1=System.currentTimeMillis();
  mesh.forceConstraintIntegrity();
  edgeList=mesh.getConstraintEdges();
  boolean bool=sillyCheckIntersection(edgeList);
  System.out.println("String_Node_Str" + edgeList.size());
  mesh.forceConstraintIntegrity();
  double t2=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (t2 - t1));
  edgeList=mesh.getConstraintEdges();
  edgeList=mesh.getConstraintEdges();
  System.out.println("String_Node_Str" + edgeList.size());
  e1=edgeList.get(0);
  t1=System.currentTimeMillis();
  bool=sillyCheckIntersection(edgeList);
  t2=System.currentTimeMillis();
  for (int i=1; i < edgeList.size(); i++) {
    e2=e1;
    e1=edgeList.get(i);
    assertTrue(e2.sortLeftRight(e1) < 1);
  }
  System.out.println("String_Node_Str" + (t2 - t1));
  assertTrue(bool);
}