def isPolySimple(polypoints):
    npolypoints = len(polypoints)
    #-- Check if the polygon is vertical, i.e. a projection cannot be made.
    #-- First copy the list so the originals are not modified
    temppolypoints = copy.deepcopy(polypoints)
    newpolypoints = copy.deepcopy(temppolypoints)
    #-- If the polygon is vertical
    if math.fabs(unit_normal(temppolypoints[0], temppolypoints[1], temppolypoints[2])[2]) < 10e-6:
        vertical = True
    else:
        vertical = False
    #-- We want to project the vertical polygon to the XZ plane
    #-- If a polygon is parallel with the YZ plane that will not be possible
    YZ = True
    for i in range(1, npolypoints):
        if temppolypoints[i][0] != temppolypoints[0][0]:
            YZ = False
            continue
    #-- Project the plane in the special case
    if YZ:
        for i in range(0, npolypoints):
            newpolypoints[i][0] = temppolypoints[i][1]
            newpolypoints[i][1] = temppolypoints[i][2]
    #-- Project the plane
    elif vertical:
        for i in range(0, npolypoints):
            newpolypoints[i][1] = temppolypoints[i][2]
    else:
        pass #-- No changes here
    #-- Check for the self-intersection edge by edge
    for i in range(0, npolypoints-3):
        if i == 0:
            m = npolypoints - 3
        else:
            m = npolypoints - 2
        for j in range (i + 2, m):
            if intersection(newpolypoints[i], newpolypoints[i+1], newpolypoints[j%npolypoints], newpolypoints[(j+1)%npolypoints]):
                return False
    return True
Current topology type is ReplicaSetWithPrimary. Is primary still known?
dataset/ETHPy150Open tudelft3d/CityGML2OBJs/polygon3dmodule.py/isPolySimple--crossover with--dataset/ETHPy150Open mongodb/mongo-python-driver/pymongo/topology_description.py/_check_has_primary