3 \page smeshpy_interface_page Python interface
5 Python API for SALOME %Mesh module defines several classes that can
6 be used for easy mesh creation and edition.
8 Documentation for SALOME %Mesh module Python API is available in two forms:
9 - <a href="smeshpy_doc/modules.html">Structured documentation</a>, where all methods and
10 classes are grouped by their functionality, like it is done in the GUI documentation
11 - <a href="smeshpy_doc/namespaces.html">Linear documentation</a> grouped only by classes, declared
12 in the \ref smesh and StdMeshersDC Python packages.
14 Python package \ref smesh provides an interface to create and handle
15 meshes. It can be used to create an empty mesh or to import mesh from the data file.
17 As soon as mesh is created, it is possible to manage it via its own
18 methods, described in \ref smesh.Mesh "class Mesh" documentation.
20 Class \ref smesh.Mesh "Mesh" allows assigning algorithms to a mesh.
21 Please note that some algorithms, included in the standard SALOME
22 distribution are always available. Python package \ref StdMeshersDC
23 provides an interface for standard meshing algorithms included into
24 the SALOME %Mesh module distribution, like:
32 To add meshing hypotheses, it is possible to use the functions provided by the
33 algorithms interfaces.
35 An example below demonstrates usage of the Python API for 3d mesh generation.
37 \anchor example_3d_mesh
38 <h2>Example of 3d mesh generation:</h2>
45 # Geometry: an assembly of a box, a cylinder and a truncated cone
46 # meshed with tetrahedral
59 box = MakeBox(-cote, -cote, -cote, +cote, +cote, +cote)
62 pt1 = MakeVertex(0, 0, cote/3)
63 di1 = MakeVectorDXDYDZ(0, 0, 1)
64 cyl = MakeCylinder(pt1, di1, section, size)
66 # Build a truncated cone
67 pt2 = MakeVertex(0, 0, size)
68 cone = MakeCone(pt2, di1, radius_1, radius_2, height)
71 box_cyl = MakeFuse(box, cyl)
72 piece = MakeFuse(box_cyl, cone)
75 addToStudy(piece, name)
77 # Create a group of faces
78 group = CreateGroup(piece, ShapeType["FACE"])
79 group_name = name + "_grp"
80 addToStudy(group, group_name)
81 group.SetName(group_name)
83 # Add faces to the group
84 faces = SubShapeAllIDs(piece, ShapeType["FACE"])
85 UnionIDs(group, faces)
91 # Define a mesh on a geometry
92 tetra = smesh.Mesh(piece, name)
94 # Define 1D hypothesis
95 algo1d = tetra.Segment()
96 algo1d.LocalLength(10)
98 # Define 2D hypothesis
99 algo2d = tetra.Triangle()
100 algo2d.LengthFromEdges()
102 # Define 3D hypothesis
103 algo3d = tetra.Tetrahedron()
104 algo3d.MaxElementVolume(100)
109 # Create a groupe of faces
114 Examples of Python scripts for Mesh operations are available by
117 - \subpage tui_creating_meshes_page
118 - \subpage tui_cartesian_algo
119 - \subpage tui_viewing_meshes_page
120 - \subpage tui_defining_hypotheses_page
121 - \subpage tui_quality_controls_page
122 - \subpage tui_filters_page
123 - \subpage tui_grouping_elements_page
124 - \subpage tui_modifying_meshes_page
125 - \subpage tui_transforming_meshes_page
126 - \subpage tui_notebook_smesh_page
127 - \subpage tui_measurements_page
128 - \subpage tui_generate_flat_elements_page
129 - \subpage tui_work_on_objects_from_gui