def set_entry_direction(poly, outside_pt, ggr=None):
    """Check and set entry direction for a polygon.

    :param poly: A polygon.
    :param outside_pt: A point beyond the outside face of the polygon.
    :param ggr: EnergyPlus global geometry rules
    :return: A polygon with the vertices correctly oriented.

    """
    if not ggr:
        entry_direction = 'counterclockwise'
    else:
        entry_direction = ggr.Vertex_Entry_Direction.lower()
    if entry_direction == 'counterclockwise':
        if poly.is_clockwise(outside_pt):
            poly = poly.invert_orientation()
    elif entry_direction == 'clockwise':
        if not poly.is_clockwise(outside_pt):
            poly = poly.invert_orientation()
    return poly
