2013-02-12 20:37:44 +06:00
|
|
|
# Add Polygon
|
|
|
|
|
|
|
|
import salome
|
2021-08-12 14:38:10 +05:00
|
|
|
salome.salome_init_without_session()
|
2013-04-04 13:08:19 +06:00
|
|
|
|
|
|
|
from salome.smesh import smeshBuilder
|
2022-04-11 18:28:01 +05:00
|
|
|
|
|
|
|
smesh_builder = smeshBuilder.New()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# create an empty mesh structure
|
2022-04-11 18:28:01 +05:00
|
|
|
mesh = smesh_builder.Mesh()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# a method to build a polygonal mesh element with <nb_vert> angles:
|
2018-10-31 16:48:24 +05:00
|
|
|
def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert, smesh_builder):
|
|
|
|
import math
|
|
|
|
|
2013-02-12 20:37:44 +06:00
|
|
|
al = 2.0 * math.pi / nb_vert
|
|
|
|
node_ids = []
|
|
|
|
|
|
|
|
# Create nodes for a polygon
|
|
|
|
for ii in range(nb_vert):
|
2018-10-31 16:48:24 +05:00
|
|
|
nid = smesh_builder.AddNode(x0 + radius * math.cos(ii*al),
|
|
|
|
y0 + radius * math.sin(ii*al),
|
|
|
|
z0)
|
2013-02-12 20:37:44 +06:00
|
|
|
node_ids.append(nid)
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Create a polygon
|
2018-10-31 16:48:24 +05:00
|
|
|
return smesh_builder.AddPolygonalFace(node_ids)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Create three polygons
|
2018-10-31 16:48:24 +05:00
|
|
|
f1 = MakePolygon(mesh, 0, 0, 0, 30, 13, smesh_builder=mesh)
|
|
|
|
f2 = MakePolygon(mesh, 0, 0, 10, 21, 9, smesh_builder=mesh)
|
|
|
|
f3 = MakePolygon(mesh, 0, 0, 20, 13, 6, smesh_builder=mesh)
|