public static int EdgeComp(TriEdge x, TriEdge y) { uint xa = x.A; uint xb = x.B; uint ya = y.A; uint yb = y.B; return(((xa < ya) || ((xa == ya) && (xb < yb))) ? -1 : 1); }
void LinkNeighbours(GraphArray <Triangle> Triangles, List <TriEdge> EdgeMap, TriEdge Edge) { //Find the first edge equal to Edge //See if there are any other edges that are equal //(if so, it means that more than 2 triangles are sharing the same edge, //which is unlikely but not impossible) for (int i = BinarySearch <TriEdge>(EdgeMap, Edge, EdgeComp); i < EdgeMap.Count && Edge == EdgeMap[i]; i++) { Triangles.InsertArc(Edge.TriPos, EdgeMap[i].TriPos); } //Note: degenerated triangles will also point themselves as neighbour triangles }