def detect_self_intersection(mesh):
    """ Detect all self-intersections.

    Args:
        mesh (:class:`Mesh`): The input mesh.

    Returns:
        :py:class:`numpy.ndarray`: A n by 2 array of face indices.  Each
            row contains the indices of two intersecting faces. :math:`n` is
            the number of intersecting face pairs.
    """
    try:
        import PyCGAL
    except ImportError:
        raise NotImplementedError(
            'Self intersection detection is not supported')
    detector = PyCGAL.SelfIntersection(mesh.vertices, mesh.faces)
    detector.detect_self_intersection()
    intersecting_faces = detector.get_self_intersecting_pairs()
    return intersecting_faces
