Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / doc / salome / gui / SMESH / input / smeshpy_interface.doc
1 /*!
2
3 \page smeshpy_interface_page Python interface
4
5 \n Python package smesh defines several classes, destined for easy and
6 clear mesh creation and edition.
7
8 \n Documentation for smesh package is available in two forms:
9
10 \n The <a href="smeshpy_doc/modules.html"> structured
11    documentation for smesh package</a>, where all methods and
12    classes are grouped by their functionality, like it is done in the GUI documentation
13 \n and the \ref smeshDC "linear documentation for smesh package"
14    grouped only by classes, declared in the smesh.py file.
15
16 \n The main page of the \ref smeshDC "linear documentation for smesh package"
17    contains a list of data structures and a list of
18    functions, provided by the package smesh.py. The first item in
19    the list of data structures (\ref smeshDC::smeshDC "class smesh")
20    also represents documentation for the methods of the package smesh.py itself.
21
22 \n The package smesh.py provides an interface to create and handle
23    meshes. Use it to create an empty mesh or to import it from the data file.
24
25 \n Once a mesh has been created, it is possible to  manage it via its own
26    methods, described at \ref smeshDC::Mesh "class Mesh" documentation
27    (it is also accessible by the second item "class Mesh" in the list of data structures).
28
29 \n Class Mesh allows assigning algorithms to a mesh.
30 \n Please note, that some algorithms,
31    included in the standard Salome installation are always available:
32       - REGULAR(1D), COMPOSITE(1D), MEFISTO(2D), Quadrangle(2D), Hexa(3D), etc.
33
34 \n There are also some algorithms, which can be installed optionally,
35 \n some of them are based on open-source meshers:
36          - NETGEN(1D-2D,2D,1D-2D-3D,3D),
37
38 \n others are based on commercial meshers:
39          - GHS3D(3D), BLSURF(2D).
40
41 \n    To add hypotheses, use the interfaces, provided by the assigned
42 algorithms.
43
44 \n Below you can see an example of usage of the package smesh for 3d mesh generation. 
45
46 <h2>Example of 3d mesh generation with NETGEN:</h2>
47
48 \n from geompy import * 
49 \n import smesh 
50
51 <b># Geometry</b>
52 \n <b># an assembly of a box, a cylinder and a truncated cone meshed with tetrahedral</b>. 
53
54 <b># Define values</b>
55 \n name = "ex21_lamp" 
56 \n cote = 60 
57 \n section = 20 
58 \n size = 200 
59 \n radius_1 = 80 
60 \n radius_2 = 40 
61 \n height = 100 
62
63 <b># Build a box</b>
64 \n box = MakeBox(-cote, -cote, -cote, +cote, +cote, +cote) 
65
66 <b># Build a cylinder</b>
67 \n pt1 = MakeVertex(0, 0, cote/3) 
68 \n di1 = MakeVectorDXDYDZ(0, 0, 1) 
69 \n cyl = MakeCylinder(pt1, di1, section, size) 
70
71 <b># Build a truncated cone</b>
72 \n pt2 = MakeVertex(0, 0, size) 
73 \n cone = MakeCone(pt2, di1, radius_1, radius_2, height) 
74
75 <b># Fuse </b>
76 \n box_cyl = MakeFuse(box, cyl) 
77 \n piece = MakeFuse(box_cyl, cone) 
78
79 <b># Add in study</b>
80 \n addToStudy(piece, name) 
81
82 <b># Create a group of faces</b>
83 \n group = CreateGroup(piece, ShapeType["FACE"]) 
84 \n group_name = name + "_grp" 
85 \n addToStudy(group, group_name) 
86 \n group.SetName(group_name) 
87
88 <b># Add faces in the group</b>
89 \n faces = SubShapeAllIDs(piece, ShapeType["FACE"]) 
90 \n UnionIDs(group, faces) 
91
92 <b># Create a mesh</b>
93
94 <b># Define a mesh on a geometry</b>
95 \n tetra = smesh.Mesh(piece, name) 
96
97 <b># Define 1D hypothesis</b>
98 \n algo1d = tetra.Segment() 
99 \n algo1d.LocalLength(10) 
100
101 <b># Define 2D hypothesis</b>
102 \n algo2d = tetra.Triangle() 
103 \n algo2d.LengthFromEdges() 
104
105 <b># Define 3D hypothesis</b>
106 \n algo3d = tetra.Tetrahedron(smesh.NETGEN) 
107 \n algo3d.MaxElementVolume(100) 
108
109 <b># Compute the mesh</b>
110 \n tetra.Compute() 
111
112 <b># Create a groupe of faces</b>
113 \n tetra.Group(group)
114
115 \n Examples of Python scripts for all Mesh operations are available by
116 the following links:
117
118 <ul>
119 <li>\subpage tui_creating_meshes_page</li>
120 <li>\subpage tui_viewing_meshes_page</li>
121 <li>\subpage tui_defining_hypotheses_page</li>
122 <li>\subpage tui_quality_controls_page</li>
123 <li>\subpage tui_grouping_elements_page</li>
124 <li>\subpage tui_modifying_meshes_page</li>
125 <li>\subpage tui_transforming_meshes_page</li>
126 </ul>
127
128
129 */