def generic_intersect(
    nodes1, degree1, nodes2, degree2, verify, all_intersections
):
    """Find all intersections among edges of two triangles.

    This treats intersections which have ``s == 1.0`` or ``t == 1.0``
    as duplicates. The duplicates will be checked by :func:`verify_duplicates`
    if ``verify`` is :data:`True`.

    Args:
        nodes1 (numpy.ndarray): The nodes defining the first triangle in
            the intersection (assumed in :math:`\\mathbf{R}^2`).
        degree1 (int): The degree of the triangle given by ``nodes1``.
        nodes2 (numpy.ndarray): The nodes defining the second triangle in
            the intersection (assumed in :math:`\\mathbf{R}^2`).
        degree2 (int): The degree of the triangle given by ``nodes2``.
        verify (Optional[bool]): Indicates if duplicate intersections
            should be checked.
        all_intersections (Callable[[numpy.ndarray, numpy.ndarray], \
            Tuple[numpy.ndarray, bool]]): A helper that intersects
            B |eacute| zier curves. Takes the nodes of each curve as input and
            returns an array (``2 x N``) of intersections.

    Returns:
        Tuple[Optional[list], Optional[bool], tuple]: 3-tuple of

        * List of "edge info" lists. Each list represents a curved polygon
          and contains 3-tuples of edge index, start and end (see the
          output of :func:`.ends_to_curve`).
        * "Contained" boolean. If not :data:`None`, indicates
          that one of the triangles is contained in the other.
        * The nodes of three edges of the first triangle being intersected
          followed by the nodes of the three edges of the second.
    """
    bbox_int = geometric_intersection.bbox_intersect(nodes1, nodes2)
    if bbox_int != INTERSECTION_T:
        return [], None, ()

    # We need **all** edges (as nodes).
    edge_nodes1 = triangle_helpers.compute_edge_nodes(nodes1, degree1)
    edge_nodes2 = triangle_helpers.compute_edge_nodes(nodes2, degree2)
    # Run through **all** pairs of edges.
    intersections, duplicates, unused, all_types = triangle_intersections(
        edge_nodes1, edge_nodes2, all_intersections
    )
    edge_infos, contained = triangle_helpers.combine_intersections(
        intersections, nodes1, degree1, nodes2, degree2, all_types
    )
    # Verify the duplicates and intersection if need be.
    if verify:
        verify_duplicates(duplicates, intersections + unused)
        verify_edge_segments(edge_infos)
    if edge_infos is None or edge_infos == []:
        return edge_infos, contained, ()

    return edge_infos, contained, edge_nodes1 + edge_nodes2
def check_edges(test_case, nodes1, degree1, nodes2, degree2, all_edge_nodes):
    from bezier.hazmat import triangle_helpers

    test_case.assertIsInstance(all_edge_nodes, tuple)
    test_case.assertEqual(len(all_edge_nodes), 6)
    edge_nodes1 = triangle_helpers.compute_edge_nodes(nodes1, degree1)
    edge_nodes2 = triangle_helpers.compute_edge_nodes(nodes2, degree2)
    test_case.assertEqual(edge_nodes1[0], all_edge_nodes[0])
    test_case.assertEqual(edge_nodes1[1], all_edge_nodes[1])
    test_case.assertEqual(edge_nodes1[2], all_edge_nodes[2])
    test_case.assertEqual(edge_nodes2[0], all_edge_nodes[3])
    test_case.assertEqual(edge_nodes2[1], all_edge_nodes[4])
    test_case.assertEqual(edge_nodes2[2], all_edge_nodes[5])