Salome HOME
53103: Mesh visualization performance problem
[modules/smesh.git] / doc / salome / gui / SMESH / input / smeshpy_interface.doc
1 /*!
2
3 \page smeshpy_interface_page Python interface
4
5 Python API for SALOME %Mesh module defines several classes that can
6 be used for easy mesh creation and edition.
7
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.
11 - <a href="smeshpy_doc/namespaces.html">Linear documentation</a> grouped only by classes, declared
12 in the \ref smeshBuilder and \ref StdMeshersBuilder Python packages.
13
14 \n With SALOME 7.2, the Python interface for %Mesh has been slightly modified to offer new functionality.
15 \n You may have to modify your scripts generated with SALOME 6 or older versions.
16 \n Please see \ref smesh_migration_page.
17
18 Class \ref smeshBuilder.smeshBuilder "smeshBuilder" provides an interface to create and handle
19 meshes. It can be used to create an empty mesh or to import mesh from the data file.
20
21 As soon as mesh is created, it is possible to manage it via its own
22 methods, described in class \ref smeshBuilder.Mesh "Mesh" documentation.
23
24 Class \ref smeshstudytools.SMeshStudyTools "SMeshStudyTools" provides several methods to manipulate mesh objects in Salome study. 
25
26 A usual workflow to generate a mesh on geometry is following:
27 <ol>
28   <li>Create an instance of \ref smeshBuilder.smeshBuilder "smeshBuilder":
29     <pre>
30       from salome.smesh import smeshBuilder
31       smesh = smeshBuilder.New( salome.myStudy )
32     </pre></li>
33   <li>Create a \ref smeshBuilder.Mesh "mesh" object:
34     <pre>
35       mesh = \ref smeshBuilder.smeshBuilder.Mesh "smesh.Mesh( geometry )" 
36     </pre></li>
37   <li> Create and assign \ref basic_meshing_algos_page "algorithms" by
38   calling corresponding methods of the mesh. If a sub-shape is
39   provided as an argument, a \ref constructing_submeshes_page "sub-mesh"
40   is implicitly created on this sub-shape:
41     <pre>
42       regular1D = \ref smeshBuilder.Mesh.Segment "mesh.Segment"()
43       mefisto   = \ref smeshBuilder.Mesh.Triangle "mesh.Triangle"( smeshBuilder.MEFISTO )
44       # use other triangle algorithm on a face -- a sub-mesh appears in the mesh
45       netgen    = \ref smeshBuilder.Mesh.Triangle "mesh.Triangle"( smeshBuilder.NETGEN_1D2D, face )
46     </pre></li>
47   <li> Create and assign \ref about_hypo_page "hypotheses" by calling
48   corresponding methods of algorithms:
49     <pre>
50       segLen10 = \ref StdMeshersBuilder.StdMeshersBuilder_Segment.LocalLength "regular1D.LocalLength"( 10. )
51       maxArea  = \ref StdMeshersBuilder.StdMeshersBuilder_Segment.LocalLength "mefisto.MaxElementArea"( 100. )
52       netgen.SetMaxSize( 20. )
53       netgen.SetFineness( smeshBuilder.VeryCoarse )
54     </pre>
55   </li>
56   <li> \ref compute_anchor "Compute" the mesh (generate mesh nodes and elements):
57     <pre>
58       \ref Mesh.Compute "mesh.Compute"()
59     </pre>
60     </li>
61 </ol>
62
63 An easiest way to start with Python scripting is to do something in
64 GUI and then to get a corresponding Python script via 
65 <b> File > Dump Study </b> menu item. Don't forget that you can get
66 all methods of any object in hand (e.g. a mesh group or a hypothesis)
67 by calling \a dir() Python built-in function.
68
69 All methods of the Mesh Group can be found in \ref tui_create_standalone_group sample script.
70
71 An example below demonstrates usage of the Python API for 3d mesh generation. 
72
73 \anchor example_3d_mesh
74 <h2>Example of 3d mesh generation:</h2>
75 \tui_script{3dmesh.py}
76
77 Examples of Python scripts for Mesh operations are available by
78 the following links:
79
80 - \subpage tui_creating_meshes_page
81 - \subpage tui_defining_hypotheses_page
82 - \subpage tui_grouping_elements_page
83 - \subpage tui_filters_page
84 - \subpage tui_modifying_meshes_page
85 - \subpage tui_transforming_meshes_page
86 - \subpage tui_viewing_meshes_page
87 - \subpage tui_quality_controls_page
88 - \subpage tui_measurements_page
89 - \subpage tui_work_on_objects_from_gui
90 - \subpage tui_notebook_smesh_page
91 - \subpage tui_cartesian_algo
92 - \subpage tui_use_existing_faces
93 - \subpage tui_prism_3d_algo
94 - \subpage tui_generate_flat_elements_page
95
96 */