To obtain a torus we define a circle around the point \( \texttt{(0,R)} \). This is done by defining a set of control points which are the used to define splines. These points and splines are then added to the SplineCurve2d using the functions AddPoint and AddSegment.

spline = SplineCurve2d() # create a 2d spline R = 1 # define the major radius r = 0.2 # define the minor radius eps = r*1e-2 # define the control points pnts = [ (0,R-r), (-r+eps,R-r+eps), (-r,R), (-r+eps,R+r-eps), (0,R+r), (r-eps,R+r-eps), (r,R), (r-eps,R-r+eps) ] # define the splines using the control points segs = [ (0,1,2), (2,3,4), (4,5,6), (6,7,0) ] # add the points and segments to the spline for pnt in pnts: spline.AddPoint (*pnt) for seg in segs: spline.AddSegment (*seg)

rev = Revolution ( Pnt(-1,0,0), Pnt(1,0,0), spline)

geo = CSGeometry() geo.Add (rev.col([1,0,0])) geo.Draw()

mesh = geo.GenerateMesh(maxh=0.5, optsteps2d=3)

mesh = Mesh(mesh) mesh.Curve(3)