Featured

## Rotationally symmetric geometries

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:

for seg in segs:

The torus is then generated by rotating the two dimensional spline around the axis defined by the points $$\texttt{(-1,0,0)}$$ and $$\texttt{(1,0,0)}$$.
rev = Revolution ( Pnt(-1,0,0), Pnt(1,0,0), spline)

Finally we have to generate a CSG object and add the just defined torus.
geo = CSGeometry()

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

mesh = Mesh(mesh)