def _TriDict(tris):
    """tris is a list of triangles (a,b,c), CCW-oriented indices.
    Return dict mapping all edges in the triangles to the containing
    triangle list."""

    ans = dict()
    for i in range(0, len(tris)):
        (a, b, c) = t = tris[i]
        ans[(a, b)] = t
        ans[(b, c)] = t
        ans[(c, a)] = t
    return ans