mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-15 10:08:34 +05:00
37 lines
995 B
Python
37 lines
995 B
Python
# Add Polygon
|
|
|
|
import salome
|
|
salome.salome_init()
|
|
|
|
import SMESH, SALOMEDS
|
|
from salome.smesh import smeshBuilder
|
|
smesh = smeshBuilder.New()
|
|
|
|
# create an empty mesh structure
|
|
mesh = smesh.Mesh()
|
|
|
|
# a method to build a polygonal mesh element with <nb_vert> angles:
|
|
def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert, smesh_builder):
|
|
import math
|
|
|
|
al = 2.0 * math.pi / nb_vert
|
|
node_ids = []
|
|
|
|
# Create nodes for a polygon
|
|
for ii in range(nb_vert):
|
|
nid = smesh_builder.AddNode(x0 + radius * math.cos(ii*al),
|
|
y0 + radius * math.sin(ii*al),
|
|
z0)
|
|
node_ids.append(nid)
|
|
pass
|
|
|
|
# Create a polygon
|
|
return smesh_builder.AddPolygonalFace(node_ids)
|
|
|
|
# Create three polygons
|
|
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)
|
|
|
|
salome.sg.updateObjBrowser()
|