Determine if an occ shape face is planar or cylindrical?

I’m iterating over the faces in an occ shape, to select either planar or cylindrical faces. Doing a print(face) for a cylindrical face does show Geom_CylindricalSurface so I suppose it’s possible to test for that, but I have no idea how to achieve that.

The end-goal is to (automatically) improve mesh quality for the more important magnet faces.

What I have so far:

def face_is_parallel_to_axis(axis, face):
    if isinstance(face.surf, occ.PlaneSurface): # PlaneSurface is not correct
        normal = face.surf.Normal(0.5, 0.5)
    elif isinstance(face, occ.CylinderSurface): # CylinderSurface is not correct
        normal = surface.Axis().Dir()
    else:
        return False
        
    # Normalize the direction vector and the normal
    A = ng.Normalize(axis)    
    B = ng.Normalize(normal)
    
    return CrossProduct_is_Zero(A, B)
    
for face in shape.faces:
    if not face_is_parallel_to_axis(axis, face):
        face.maxh = high_res

I think the better option is to increase the curvaturesafety meshing parameter. Then curved surfaces are meshed finer.

else you can find faces with center in plane like this:

shape.faces[X<1e-10][X>-1e-10]

This gives all faces that have center at X~=0