Creating OpenCascade Geometry

I tried to model with the following script by opencascade.
It seems that only 4 faces are generated.
Would you let me know the problem?

case1

from netgen.occ import *
from netgen.webgui import Draw as DrawGeo
from numpy import *
from ngsolve import *
from ngsolve.webgui import Draw

a  = 50
a1 = 15
a2 = 35
b  = 40
b1 = 10
b2 = 30
c  = 5
c1 = 4
d1 = 0.5
rad = 1.2

InsRatio = 0.95
LaminNum = 10
ct = c/LaminNum*(1-InsRatio)
cth = c/LaminNum*InsRatio
ctt = array([c/LaminNum * i for i in range(LaminNum+1)])

wp = WorkPlane()
wp.MoveTo(0, 0).Rectangle(a, b)
geo = wp.Face()
for n in range(len(ctt)):
  wp.MoveTo(ctt[n], 0).LineTo(ctt[n], 2*c-ctt[n]-rad).Direction(0, 1).Arc(rad, -90).LineTo(3*c-ctt[n]-rad, 2*c-ctt[n]).Direction(1,0).Arc(rad, -90).LineTo(3*c-ctt[n], 0).Close()
  geo = Glue([geo,wp.Face()])
for n in range(1,len(ctt)):
  wp.MoveTo(ctt[n]-ct, 0).LineTo(ctt[n]-ct, 2*c-ctt[n]+ct-rad).Direction(0, 1).Arc(rad, -90).LineTo(3*c-ctt[n]+ct-rad, 2*c-ctt[n]+ct).Direction(1,0).Arc(rad, -90).LineTo(3*c-ctt[n]+ct, 0).Close()
  geo = Glue([geo,wp.Face()])
wp.MoveTo(c+d1, c1+d1).Rectangle(c1, c1)
geo = Glue([geo,wp.Face()])
DrawGeo(geo)

I have changed the order of generating faces.
Then faces are generated, however the mesh is not generated.

---------------------------------------------------------------------------
NgException                               Traceback (most recent call last)
Cell In[7], line 1
----> 1 mesh = Mesh(OCCGeometry(geo).GenerateMesh(maxh=1)).Curve(1)
      2 Draw(mesh)

NgException: OCC-Triangulation could not be built

case2

from netgen.occ import *
from netgen.webgui import Draw as DrawGeo
from numpy import *
from ngsolve import *
from ngsolve.webgui import Draw

a  = 50
b  = 40
c  = 5
c1 = 4
d1 = 0.5
rad = 1.2

InsRatio = 0.95
LaminNum = 10
ct = c/LaminNum*(1-InsRatio)
cth = c/LaminNum*InsRatio
ctt = array([c/LaminNum * i for i in range(LaminNum+1)])

wp = WorkPlane()
wp.MoveTo(0, 0).Rectangle(a, b)
geo = wp.Face()

wp.MoveTo(c+d1, d1).Rectangle(c1, c1)
geo = Glue([geo,wp.Face()])

for n in range(len(ctt)-1,-1,-1):
  wp.MoveTo(ctt[n], 0).LineTo(ctt[n], 2*c-ctt[n]-rad).Direction(0, 1).Arc(rad, -90).LineTo(3*c-ctt[n]-rad, 2*c-ctt[n]).Direction(1,0).Arc(rad, -90).LineTo(3*c-ctt[n], 0).Close()
  geo = Glue([geo, wp.Face()])
for n in range(len(ctt)-1,0,-1):
  wp.MoveTo(ctt[n]-ct, 0).LineTo(ctt[n]-ct, 2*c-ctt[n]+ct-rad).Direction(0, 1).Arc(rad, -90).LineTo(3*c-ctt[n]+ct-rad, 2*c-ctt[n]+ct).Direction(1,0).Arc(rad, -90).LineTo(3*c-ctt[n]+ct, 0).Close()
  geo = Glue([geo, wp.Face()])

DrawGeo(geo)
mesh = Mesh(OCCGeometry(geo).GenerateMesh(maxh=1)).Curve(1)
Draw(mesh)

The following example worked perfecly, I do not understand the diferences.

case3

‘’’
from netgen.occ import *
from netgen.webgui import Draw as DrawGeo
from numpy import *
from ngsolve import *
from ngsolve.webgui import Draw

for n in range(3,10):
wp = WorkPlane()
wp.MoveTo(0,0.2).Direction(0,-1).Arc(0.2,90).Direction(1,0).Line(n-0.4).Arc(0.2,90).Direction(0,1).Line(n-0.4).Arc(0.2,90).Direction(-1,0).Line(n-0.4).Arc(0.2,90).Close()
if n==3:
geo = wp.Face()
else:
geo = Glue([geo,wp.Face()])
mesh = Mesh(OCCGeometry(geo).GenerateMesh(maxh=0.15)).Curve(1)
Draw(mesh)
‘’’

Now I figured out the problem. I have to draw lines in counter-clockwise in the WorkPlane.

from netgen.occ import *
from netgen.webgui import Draw as DrawGeo
from numpy import *
from ngsolve import *
from ngsolve.webgui import Draw
a  = 50/3
b  = 40/3
c  = 5
c1 = 4
d1 = 0.5
rad = 1.2

InsRatio = 0.95
LaminNum = 10
ct = c/LaminNum*(1-InsRatio)
cth = c/LaminNum*InsRatio
ctt = array([c/LaminNum * i for i in range(LaminNum+1)])

wp = WorkPlane()
wp.MoveTo(0, 0).Rectangle(a, b)
geo = wp.Face()

for n in range(0,len(ctt)):
  wp.MoveTo(ctt[n],0).LineTo(3*c-ctt[n], 0).Direction(0,1).LineTo(3*c-ctt[n], 2*c-ctt[n]-rad).Arc(rad, 90).LineTo(ctt[n]+rad,2*c-ctt[n]).Arc(rad, 90).Close()
  geo = Glue([geo, wp.Face()])

for n in range(1,len(ctt)-1):
  wp.MoveTo(ctt[n]-ct,0).LineTo(3*c-ctt[n]+ct, 0).Direction(0,1).LineTo(3*c-ctt[n]+ct, 2*c-ctt[n]+ct-rad).Arc(rad, 90).LineTo(ctt[n]-ct+rad,2*c-ctt[n]).Arc(rad, 90).Close()
  geo = Glue([geo, wp.Face()])

wp.MoveTo(c+d1, d1).Direction(1,0).Rectangle(c1, c1)
geo = Glue([geo, wp.Face()])
DrawGeo(geo)

mesh = Mesh(OCCGeometry(geo).GenerateMesh(maxh=0.2)).Curve(1)
Draw(mesh)