Program: 43040
Project: 43040
Buggy source:
/** 
 * Verify that the mesh structure is correct.  Chase as many pointers and references as we can to confirm that nothing is messed up.
 * @param mesh
 * @return
 */
public static boolean verifyStructure(WingedEdgeTriangleMesh mesh,boolean manifold){
  StructMixedData edges=mesh.getEdges();
  int startEdge=mesh.getStartEdge();
  StructMixedData faces=mesh.getFaces();
  int startFace=mesh.getStartFace();
  StructMixedData vertices=mesh.getVertices();
  int startVertex=mesh.getStartVertex();
  StructMixedData hedges=mesh.getHalfEdges();
  int e=startEdge;
  while (e != -1) {
    int he=Edge.getHe(edges,e);
    if (he == -1) {
      System.out.println("String_Node_Str" + e);
      return false;
    }
    int twin=HalfEdge.getTwin(hedges,he);
    if (manifold && twin == -1) {
      System.out.println("String_Node_Str" + e);
      return false;
    }
    if (twin != -1) {
      int estart=HalfEdge.getStart(hedges,he);
      int eend=HalfEdge.getEnd(hedges,he);
      int tstart=HalfEdge.getStart(hedges,twin);
      int tend=HalfEdge.getEnd(hedges,twin);
      if (estart != tend || eend != tstart) {
        System.out.println("String_Node_Str" + he + "String_Node_Str"+ twin);
        return false;
      }
    }
    e=Edge.getNext(edges,e);
  }
  int f=startFace;
  while (f != -1) {
    int he=Face.getHe(faces,f);
    int start=he;
    if (he == -1) {
      System.out.println("String_Node_Str" + f);
      return false;
    }
    int cnt=0;
    while (he != -1) {
      int edge=HalfEdge.getEdge(hedges,he);
      if (!findEdge(mesh,edge)) {
        System.out.println("String_Node_Str" + edge);
        return false;
      }
      int left=HalfEdge.getLeft(hedges,he);
      if (!findFace(mesh,left)) {
        System.out.println("String_Node_Str" + left);
        return false;
      }
      cnt++;
      he=HalfEdge.getNext(hedges,he);
      if (he == start) {
        break;
      }
    }
    if (cnt != 3) {
      System.out.println("String_Node_Str" + f);
      return false;
    }
    he=Face.getHe(faces,f);
    start=he;
    cnt=0;
    while (he != -1) {
      cnt++;
      he=HalfEdge.getPrev(hedges,he);
      if (he == start) {
        break;
      }
    }
    if (cnt != 3) {
      System.out.println("String_Node_Str" + f);
      return false;
    }
    f=Face.getNext(faces,f);
  }
  int v=startVertex;
  while (v != -1) {
    int he=Vertex.getLink(vertices,v);
    if (he == -1) {
      System.out.println("String_Node_Str" + v);
      return false;
    }
    int start=HalfEdge.getStart(hedges,he);
    int end=HalfEdge.getEnd(hedges,he);
    if (start != v && end != v) {
      System.out.println("String_Node_Str" + v + "String_Node_Str"+ he);
      return false;
    }
    v=Vertex.getNext(vertices,v);
  }
  int e1=startEdge;
  int e2=startEdge;
  while (e1 != -1) {
    while (e2 != -1) {
      if (e1 == e2) {
        e2=Edge.getNext(edges,e2);
      }
      int he1=Edge.getHe(edges,e1);
      int he2=Edge.getHe(edges,e2);
      if (he1 != -1) {
        int start=HalfEdge.getStart(hedges,he1);
        int end=HalfEdge.getEnd(hedges,he1);
        if (start == end) {
          System.out.println("String_Node_Str" + he1);
          return false;
        }
      }
      if (he2 != -1) {
        int start=HalfEdge.getStart(hedges,he2);
        int end=HalfEdge.getEnd(hedges,he2);
        if (start == end) {
          System.out.println("String_Node_Str" + he2);
          return false;
        }
      }
      if (he1 != -1 && he2 != -1) {
        int start1=HalfEdge.getStart(hedges,he1);
        int end1=HalfEdge.getEnd(hedges,he1);
        int start2=HalfEdge.getStart(hedges,he2);
        int end2=HalfEdge.getEnd(hedges,he2);
        if ((start1 == start2 && end1 == end2) || (start1 == end2 && end1 == start2)) {
          System.out.println("String_Node_Str" + e1 + "String_Node_Str"+ e2);
          return false;
        }
      }
      e2=Edge.getNext(edges,e2);
    }
    e1=Edge.getNext(edges,e1);
  }
  v=startVertex;
  while (v != -1) {
    int start=Vertex.getLink(vertices,v);
    int he=start;
    int tricount=0;
    do {
      int twin=HalfEdge.getTwin(hedges,he);
      he=HalfEdge.getNext(hedges,twin);
    }
 while (he != start && tricount++ < 20);
    if (tricount >= 20) {
      System.out.println("String_Node_Str");
      return false;
    }
    v=Vertex.getNext(vertices,v);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Verify that the mesh structure is correct.  Chase as many pointers and references as we can to confirm that nothing is messed up.
 * @param mesh
 * @return
 */
public static boolean verifyStructure(WingedEdgeTriangleMesh mesh,boolean manifold){
  StructMixedData edges=mesh.getEdges();
  int startEdge=mesh.getStartEdge();
  StructMixedData faces=mesh.getFaces();
  int startFace=mesh.getStartFace();
  StructMixedData vertices=mesh.getVertices();
  int startVertex=mesh.getStartVertex();
  StructMixedData hedges=mesh.getHalfEdges();
  int e=startEdge;
  int edgeCount=0;
  while (e != -1) {
    edgeCount++;
    int he=Edge.getHe(edges,e);
    if (he == -1) {
      System.out.println("String_Node_Str" + e);
      return false;
    }
    int twin=HalfEdge.getTwin(hedges,he);
    if (manifold && twin == -1) {
      System.out.println("String_Node_Str" + e);
      return false;
    }
    if (twin != -1) {
      int estart=HalfEdge.getStart(hedges,he);
      int eend=HalfEdge.getEnd(hedges,he);
      int tstart=HalfEdge.getStart(hedges,twin);
      int tend=HalfEdge.getEnd(hedges,twin);
      if (estart != tend || eend != tstart) {
        System.out.println("String_Node_Str" + he + "String_Node_Str"+ twin);
        return false;
      }
    }
    e=Edge.getNext(edges,e);
  }
  assertEquals("String_Node_Str",mesh.getEdgeCount(),edgeCount);
  int f=startFace;
  int faceCount=0;
  while (f != -1) {
    faceCount++;
    int he=Face.getHe(faces,f);
    int start=he;
    if (he == -1) {
      System.out.println("String_Node_Str" + f);
      return false;
    }
    int cnt=0;
    while (he != -1) {
      int edge=HalfEdge.getEdge(hedges,he);
      if (!findEdge(mesh,edge)) {
        System.out.println("String_Node_Str" + edge);
        return false;
      }
      int left=HalfEdge.getLeft(hedges,he);
      if (!findFace(mesh,left)) {
        System.out.println("String_Node_Str" + left);
        return false;
      }
      cnt++;
      he=HalfEdge.getNext(hedges,he);
      if (he == start) {
        break;
      }
    }
    if (cnt != 3) {
      System.out.println("String_Node_Str" + f);
      return false;
    }
    he=Face.getHe(faces,f);
    start=he;
    cnt=0;
    while (he != -1) {
      cnt++;
      he=HalfEdge.getPrev(hedges,he);
      if (he == start) {
        break;
      }
    }
    if (cnt != 3) {
      System.out.println("String_Node_Str" + f);
      return false;
    }
    f=Face.getNext(faces,f);
  }
  assertEquals("String_Node_Str",mesh.getFaceCount(),faceCount);
  int v=startVertex;
  int vertexCount=0;
  while (v != -1) {
    vertexCount++;
    int he=Vertex.getLink(vertices,v);
    if (he == -1) {
      System.out.println("String_Node_Str" + v);
      return false;
    }
    int start=HalfEdge.getStart(hedges,he);
    int end=HalfEdge.getEnd(hedges,he);
    if (start != v && end != v) {
      System.out.println("String_Node_Str" + v + "String_Node_Str"+ he);
      return false;
    }
    v=Vertex.getNext(vertices,v);
  }
  assertEquals("String_Node_Str",mesh.getVertexCount(),vertexCount);
  int e1=startEdge;
  int e2=startEdge;
  while (e1 != -1) {
    while (e2 != -1) {
      if (e1 == e2) {
        e2=Edge.getNext(edges,e2);
      }
      int he1=Edge.getHe(edges,e1);
      int he2=Edge.getHe(edges,e2);
      if (he1 != -1) {
        int start=HalfEdge.getStart(hedges,he1);
        int end=HalfEdge.getEnd(hedges,he1);
        if (start == end) {
          System.out.println("String_Node_Str" + he1);
          return false;
        }
      }
      if (he2 != -1) {
        int start=HalfEdge.getStart(hedges,he2);
        int end=HalfEdge.getEnd(hedges,he2);
        if (start == end) {
          System.out.println("String_Node_Str" + he2);
          return false;
        }
      }
      if (he1 != -1 && he2 != -1) {
        int start1=HalfEdge.getStart(hedges,he1);
        int end1=HalfEdge.getEnd(hedges,he1);
        int start2=HalfEdge.getStart(hedges,he2);
        int end2=HalfEdge.getEnd(hedges,he2);
        if ((start1 == start2 && end1 == end2) || (start1 == end2 && end1 == start2)) {
          System.out.println("String_Node_Str" + e1 + "String_Node_Str"+ e2);
          return false;
        }
      }
      e2=Edge.getNext(edges,e2);
    }
    e1=Edge.getNext(edges,e1);
  }
  v=startVertex;
  while (v != -1) {
    int start=Vertex.getLink(vertices,v);
    int he=start;
    int tricount=0;
    do {
      int twin=HalfEdge.getTwin(hedges,he);
      he=HalfEdge.getNext(hedges,twin);
    }
 while (he != start && tricount++ < 20);
    if (tricount >= 20) {
      System.out.println("String_Node_Str");
      return false;
    }
    v=Vertex.getNext(vertices,v);
  }
  return true;
}