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(, occ.PlaneSurface): # PlaneSurface is not correct
        normal =, 0.5)
    elif isinstance(face, occ.CylinderSurface): # CylinderSurface is not correct
        normal = surface.Axis().Dir()
        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:


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