2013-02-19 02:50:33 +06:00
|
|
|
# Add Polygon
|
|
|
|
|
|
|
|
import math
|
2013-03-21 22:50:22 +06:00
|
|
|
|
2013-02-19 02:50:33 +06:00
|
|
|
import salome
|
2013-03-21 22:50:22 +06:00
|
|
|
salome.salome_init()
|
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
|
|
|
geompy = geomBuilder.New(salome.myStudy)
|
|
|
|
|
|
|
|
import SMESH, SALOMEDS
|
|
|
|
from salome.smesh import smeshBuilder
|
|
|
|
smesh = smeshBuilder.New(salome.myStudy)
|
|
|
|
import salome_notebook
|
2013-02-19 02:50:33 +06:00
|
|
|
|
|
|
|
|
|
|
|
# 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):
|
|
|
|
al = 2.0 * math.pi / nb_vert
|
|
|
|
node_ids = []
|
|
|
|
|
|
|
|
# Create nodes for a polygon
|
|
|
|
for ii in range(nb_vert):
|
|
|
|
nid = mesh.AddNode(x0 + radius * math.cos(ii*al),
|
|
|
|
y0 + radius * math.sin(ii*al),
|
|
|
|
z0)
|
|
|
|
node_ids.append(nid)
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Create a polygon
|
|
|
|
return mesh.AddPolygonalFace(node_ids)
|
|
|
|
|
|
|
|
# Create three polygons
|
|
|
|
f1 = MakePolygon(mesh, 0, 0, 0, 30, 13)
|
|
|
|
f2 = MakePolygon(mesh, 0, 0, 10, 21, 9)
|
|
|
|
f3 = MakePolygon(mesh, 0, 0, 20, 13, 6)
|
|
|
|
|
|
|
|
salome.sg.updateObjBrowser(1)
|