Salome HOME
Merge from V6_main (04/10/2012)
[plugins/hexoticplugin.git] / doc / salome / gui / HexoticPLUGIN / input / hexoticplugin_python_interface.doc
1 /*!
2
3 \page hexoticplugin_python_interface_page Python Interface
4
5 Python package HexoticPLUGINDC defines several classes, destined for creation of the 3D meshes.
6
7 Hexotic meshing plugin dynamically adds several methods to the smesh.Mesh class to create meshing algorithms.
8
9 Below you can see an example of usage of the HexoticPlugin Python API for mesh generation:
10
11 \anchor tui_hexotic
12
13 -# \ref tui_hexotic_basic
14 -# \ref tui_hexotic_sd_mode
15   -# \ref tui_hexotic_sd_mode1
16   -# \ref tui_hexotic_sd_mode2
17   -# \ref tui_hexotic_sd_mode3
18   -# \ref tui_hexotic_sd_mode4
19
20 \section tui_hexotic_basic Construction of Mesh using Hexotic algorithm
21
22 \code
23 import geompy
24 import smesh
25
26 # create a sphere
27 sphere = geompy.MakeSphereR(100.)
28 geompy.addToStudy(sphere, "sphere")
29
30 # create a mesh on the sphere
31 hexoticMesh = smesh.Mesh(sphere,"sphere: BLSurf and Hexotic mesh")
32
33 # create a BLSurf algorithm for faces
34 BLSURF = hexoticMesh.Triangle(algo=smesh.BLSURF)
35 BLSURF.SetGeometricMesh( 1 )
36
37 # create a Hexotic algorithm for volumes
38 HEXOTIC = hexoticMesh.Hexahedron(algo=smesh.Hexotic)
39
40 # compute the mesh
41 hexoticMesh.Compute()
42
43 # Change the level of subdivision
44 HEXOTIC.SetMinMaxHexes(4, 8)
45
46 # End of script
47 \endcode
48
49 \image html hexotic_basic_subdivisions_4_8.png Left: Hexotic mesh without hypothesis, right: Hexotic mesh with an hypothesis defined by minl=4 and maxl=8
50
51 \ref tui_hexotic "Back to top"
52
53 \section tui_hexotic_sd_mode Effect of the sub-domain mode
54
55 This example illustrates the sub-domain mode of Hexotic.
56
57 \subsection tui_hexotic_sd_mode1 Sub-domain mode = 1
58
59 \code
60 import SALOMEDS
61 import geompy
62 import smesh
63
64 # Create geometry: a box cut by a holed sphere
65 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
66 Sphere_1 = geompy.MakeSphereR(75)
67 Sphere_2 = geompy.MakeSphereR(25)
68 geompy.TranslateDXDYDZ(Box_1, -100, -100, -100)
69 Cut_1 = geompy.MakeCut(Sphere_1, Sphere_2)
70 Cut_2 = geompy.MakeCut(Box_1, Cut_1)
71 geompy.addToStudy( Box_1, 'Box_1' )
72 geompy.addToStudy( Sphere_1, 'Sphere_1' )
73 geompy.addToStudy( Sphere_2, 'Sphere_2' )
74 geompy.addToStudy( Cut_1, 'Cut_1' )
75 geompy.addToStudy( Cut_2, 'Cut_2' )
76
77 # Create filters
78 # aFilter1: elements inside small sphere
79 aFilter1 = smesh.GetFilterFromCriteria([smesh.GetCriterion(smesh.VOLUME,smesh.FT_BelongToGeom,smesh.FT_Undefined,Sphere_2)])
80 # aFilter2: elements inside big sphere and not inside small sphere
81 aFilter2 = smesh.GetFilterFromCriteria([smesh.GetCriterion(smesh.VOLUME,smesh.FT_BelongToGeom,smesh.FT_Undefined,Sphere_1, smesh.FT_LogicalAND),
82                                         smesh.GetCriterion(smesh.VOLUME,smesh.FT_BelongToGeom,smesh.FT_Undefined,Sphere_2, smesh.FT_LogicalNOT)])
83 # aFilter3: elements not inside big sphere
84 aFilter3 = smesh.GetFilterFromCriteria([smesh.GetCriterion(smesh.VOLUME,smesh.FT_BelongToGeom,smesh.FT_Undefined,Sphere_1, smesh.FT_LogicalNOT)])
85
86 # Create mesh of Cut_2 with sd mode 1
87 print "Create mesh of Cut_2 with sd mode 1"
88 Mesh_hexotic_sd1 = smesh.Mesh(Cut_2, "Mesh_hexotic_sd1")
89
90 # Create the 2D algo: BlSurf with geometrical mesh
91 Mesh_hexotic_sd1.Triangle(algo=smesh.BLSURF).Parameters().SetGeometricMesh( 1 )
92
93 # Create the 3D algo: Hexotic with:
94 # - minl = 4
95 # - maxl = 8
96 # - sd = 1
97 Mesh_hexotic_sd1.Hexahedron(algo=smesh.Hexotic).SetMinMaxHexes(4, 8).SetHexoticSdMode( 1 )
98
99 # Create the groups on filters
100 g1 = Mesh_hexotic_sd1.GroupOnFilter(smesh.VOLUME, 'small sphere', aFilter1 )
101 g1.SetColor( SALOMEDS.Color( 1, 0, 0 ))
102 g2 = Mesh_hexotic_sd1.GroupOnFilter(smesh.VOLUME, 'big sphere - small sphere', aFilter2 )
103 g2.SetColor( SALOMEDS.Color( 0, 1, 0 ))
104 g3 = Mesh_hexotic_sd1.GroupOnFilter(smesh.VOLUME, 'box - big sphere', aFilter3 )
105 g3.SetColor( SALOMEDS.Color( 0, 0, 1 ))
106
107 # Compute
108 Mesh_hexotic_sd1.Compute()
109
110 # End of script
111 \endcode
112
113 \image html hexotic_sd_mode_1.png Hexotic mesh of a box cut by a holed sphere ( sd = 1 )
114
115 \ref tui_hexotic "Back to top"
116
117 \subsection tui_hexotic_sd_mode2 Sub-domain mode = 2
118
119 \code
120
121 # Create mesh of Cut_2 with sd mode 2
122 print "Create mesh of Cut_2 with sd mode 2"
123 Mesh_hexotic_sd2 = smesh.Mesh(Cut_2, "Mesh_hexotic_sd2")
124
125 # Create the 2D algo: BlSurf with geometrical mesh
126 Mesh_hexotic_sd2.Triangle(algo=smesh.BLSURF).Parameters().SetGeometricMesh( 1 )
127
128 # Create the 3D algo: Hexotic with:
129 # - minl = 4
130 # - maxl = 8
131 # - sd = 2
132 Mesh_hexotic_sd2.Hexahedron(algo=smesh.Hexotic).SetMinMaxHexes(4, 8).SetHexoticSdMode( 2 )
133
134 # Create the groups on filters
135 g1 = Mesh_hexotic_sd2.GroupOnFilter(smesh.VOLUME, 'small sphere', aFilter1 )
136 g1.SetColor( SALOMEDS.Color( 1, 0, 0 ))
137 g2 = Mesh_hexotic_sd2.GroupOnFilter(smesh.VOLUME, 'big sphere - small sphere', aFilter2 )
138 g2.SetColor( SALOMEDS.Color( 0, 1, 0 ))
139 g3 = Mesh_hexotic_sd2.GroupOnFilter(smesh.VOLUME, 'box - big sphere', aFilter3 )
140 g3.SetColor( SALOMEDS.Color( 0, 0, 1 ))
141
142 # Compute
143 Mesh_hexotic_sd2.Compute()
144
145 # End of script
146 \endcode
147
148 \image html hexotic_sd_mode_2.png Hexotic mesh of a box cut by a holed sphere ( sd = 2 )
149
150 \ref tui_hexotic "Back to top"
151
152 \subsection tui_hexotic_sd_mode3 Sub-domain mode = 3
153
154 \code
155
156 # Create mesh of Cut_2 with sd mode 3
157 print "Create mesh of Cut_2 with sd mode 3"
158 Mesh_hexotic_sd3 = smesh.Mesh(Cut_2, "Mesh_hexotic_sd3")
159
160 # Create the 2D algo: BlSurf with geometrical mesh
161 Mesh_hexotic_sd3.Triangle(algo=smesh.BLSURF).Parameters().SetGeometricMesh( 1 )
162
163 # Create the 3D algo: Hexotic with:
164 # - minl = 4
165 # - maxl = 8
166 # - sd = 3
167 Mesh_hexotic_sd3.Hexahedron(algo=smesh.Hexotic).SetMinMaxHexes(4, 8).SetHexoticSdMode( 3 )
168
169 # Create the groups on filters
170 g1 = Mesh_hexotic_sd3.GroupOnFilter(smesh.VOLUME, 'small sphere', aFilter1 )
171 g1.SetColor( SALOMEDS.Color( 1, 0, 0 ))
172 g2 = Mesh_hexotic_sd3.GroupOnFilter(smesh.VOLUME, 'big sphere - small sphere', aFilter2 )
173 g2.SetColor( SALOMEDS.Color( 0, 1, 0 ))
174 g3 = Mesh_hexotic_sd3.GroupOnFilter(smesh.VOLUME, 'box - big sphere', aFilter3 )
175 g3.SetColor( SALOMEDS.Color( 0, 0, 1 ))
176
177 # Compute
178 Mesh_hexotic_sd3.Compute()
179
180 # End of script
181 \endcode
182
183 \image html hexotic_sd_mode_3.png Hexotic mesh of a box cut by a holed sphere ( sd = 3 )
184
185 \ref tui_hexotic "Back to top"
186
187 \subsection tui_hexotic_sd_mode4 Sub-domain mode = 4
188
189 \code
190
191 # Create geometry: a box cut by a plane
192 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
193 Translation_1 = geompy.MakeTranslation(Box_1, 0, 200, 0)
194 Partition_1 = geompy.MakePartition([Box_1, Translation_1], [], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
195 geompy.addToStudy( Box_1, 'Box_1' )
196 geompy.addToStudy( Translation_1, 'Translation_1' )
197 geompy.addToStudy( Partition_1, 'Partition_1' )
198
199 # Create mesh of Partition_1 with sd mode 4 (default sd mode in SALOME)
200 Mesh_hexotic_sd4 = smesh.Mesh(Partition_1, "Mesh_hexotic_sd4")
201 Mesh_hexotic_sd4.Triangle(algo=smesh.BLSURF)
202 Mesh_hexotic_sd4.Hexahedron(algo=smesh.Hexotic).SetMinMaxHexes(4, 8).SetHexoticSdMode( 4 )
203
204 # Compute
205 Mesh_hexotic_sd4.Compute()
206
207 # End of script
208 \endcode
209
210 \image html hexotic_sd_mode_4.png Hexotic mesh of a box cut by a plane ( On the left, sd = 3: the internal surface is ignored ; on the right sd = 4: all sub-domains are meshed )
211
212 \ref tui_hexotic "Back to top"
213
214 */