Salome HOME
Porting GUI documentation on Doxygen tool.
[modules/smesh.git] / doc / salome / gui / SMESH / input / introduction_to_mesh_python.doc
1 /*!
2
3 \page introduction_to_mesh_python_page Introduction to MESH module python interface
4
5 \n Package smesh provides a standard API for creation and edition of meshes. 
6 \n Below you can see an example of usage of the package smesh for 3d mesh generation. 
7
8 <h2>Example of 3d mesh generation with NETGEN:</h2>
9
10 \n from geompy import * 
11 \n import smesh 
12
13 <b># Geometry</b>
14 \n <b># an assembly of a box, a cylinder and a truncated cone meshed with tetrahedral</b>. 
15
16 <b># Define values</b>
17 \n name = "ex21_lamp" 
18 \n cote = 60 
19 \n section = 20 
20 \n size = 200 
21 \n radius_1 = 80 
22 \n radius_2 = 40 
23 \n height = 100 
24
25 <b># Build a box</b>
26 \n box = MakeBox(-cote, -cote, -cote, +cote, +cote, +cote) 
27
28 <b># Build a cylinder</b>
29 \n pt1 = MakeVertex(0, 0, cote/3) 
30 \n di1 = MakeVectorDXDYDZ(0, 0, 1) 
31 \n cyl = MakeCylinder(pt1, di1, section, size) 
32
33 <b># Build a truncated cone</b>
34 \n pt2 = MakeVertex(0, 0, size) 
35 \n cone = MakeCone(pt2, di1, radius_1, radius_2, height) 
36
37 <b># Fuse </b>
38 \n box_cyl = MakeFuse(box, cyl) 
39 \n piece = MakeFuse(box_cyl, cone) 
40
41 <b># Add in study</b>
42 \n addToStudy(piece, name) 
43
44 <b># Create a group of faces</b>
45 \n group = CreateGroup(piece, ShapeType["FACE"]) 
46 \n group_name = name + "_grp" 
47 \n addToStudy(group, group_name) 
48 \n group.SetName(group_name) 
49
50 <b># Add faces in the group</b>
51 \n faces = SubShapeAllIDs(piece, ShapeType["FACE"]) 
52 \n UnionIDs(group, faces) 
53
54 <b># Create a mesh</b>
55
56 <b># Define a mesh on a geometry</b>
57 \n tetra = smesh.Mesh(piece, name) 
58
59 <b># Define 1D hypothesis</b>
60 \n algo1d = tetra.Segment() 
61 \n algo1d.LocalLength(10) 
62
63 <b># Define 2D hypothesis</b>
64 \n algo2d = tetra.Triangle() 
65 \n algo2d.LengthFromEdges() 
66
67 <b># Define 3D hypothesis</b>
68 \n algo3d = tetra.Tetrahedron(smesh.NETGEN) 
69 \n algo3d.MaxElementVolume(100) 
70
71 <b># Compute the mesh</b>
72 \n tetra.Compute() 
73
74 <b># Create a groupe of faces</b>
75 \n tetra.Group(group)
76
77 */