Salome HOME
Merge from V6_main 28/02/2013
[modules/smesh.git] / doc / salome / examples / modifying_meshes_ex09.py
1 # Add Polygon
2
3 import math
4 import salome
5
6 import smesh
7
8 # create an empty mesh structure
9 mesh = smesh.Mesh() 
10
11 # a method to build a polygonal mesh element with <nb_vert> angles:
12 def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert):
13     al = 2.0 * math.pi / nb_vert
14     node_ids = []
15
16     # Create nodes for a polygon
17     for ii in range(nb_vert):
18         nid = mesh.AddNode(x0 + radius * math.cos(ii*al),
19                            y0 + radius * math.sin(ii*al),
20                                                      z0)
21         node_ids.append(nid)
22         pass
23
24     # Create a polygon
25     return mesh.AddPolygonalFace(node_ids)
26
27 # Create three polygons
28 f1 = MakePolygon(mesh, 0, 0,  0, 30, 13)
29 f2 = MakePolygon(mesh, 0, 0, 10, 21,  9)
30 f3 = MakePolygon(mesh, 0, 0, 20, 13,  6)
31
32 salome.sg.updateObjBrowser(1)