3 \page hexoticplugin_python_interface_page Python Interface
5 Python package HexoticPLUGINDC defines several classes, destined for creation of the 3D meshes.
7 Hexotic meshing plugin dynamically adds several methods to the smesh.Mesh class to create meshing algorithms.
9 Below you can see an example of usage of the HexoticPlugin Python API for mesh generation:
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
20 \section tui_hexotic_basic Construction of Mesh using Hexotic algorithm
27 sphere = geompy.MakeSphereR(100.)
28 geompy.addToStudy(sphere, "sphere")
30 # create a mesh on the sphere
31 hexoticMesh = smesh.Mesh(sphere,"sphere: BLSurf and Hexotic mesh")
33 # create a BLSurf algorithm for faces
34 BLSURF = hexoticMesh.Triangle(algo=smesh.BLSURF)
35 BLSURF.SetGeometricMesh( 1 )
37 # create a Hexotic algorithm for volumes
38 HEXOTIC = hexoticMesh.Hexahedron(algo=smesh.Hexotic)
43 # Change the level of subdivision
44 HEXOTIC.SetMinMaxHexes(4, 8)
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
51 \ref tui_hexotic "Back to top"
53 \section tui_hexotic_sd_mode Effect of the sub-domain mode
55 This example illustrates the sub-domain mode of Hexotic.
57 \subsection tui_hexotic_sd_mode1 Sub-domain mode = 1
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' )
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)])
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")
90 # Create the 2D algo: BlSurf with geometrical mesh
91 Mesh_hexotic_sd1.Triangle(algo=smesh.BLSURF).Parameters().SetGeometricMesh( 1 )
93 # Create the 3D algo: Hexotic with:
97 Mesh_hexotic_sd1.Hexahedron(algo=smesh.Hexotic).SetMinMaxHexes(4, 8).SetHexoticSdMode( 1 )
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 ))
108 Mesh_hexotic_sd1.Compute()
113 \image html hexotic_sd_mode_1.png Hexotic mesh of a box cut by a holed sphere ( sd = 1 )
115 \ref tui_hexotic "Back to top"
117 \subsection tui_hexotic_sd_mode2 Sub-domain mode = 2
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")
125 # Create the 2D algo: BlSurf with geometrical mesh
126 Mesh_hexotic_sd2.Triangle(algo=smesh.BLSURF).Parameters().SetGeometricMesh( 1 )
128 # Create the 3D algo: Hexotic with:
132 Mesh_hexotic_sd2.Hexahedron(algo=smesh.Hexotic).SetMinMaxHexes(4, 8).SetHexoticSdMode( 2 )
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 ))
143 Mesh_hexotic_sd2.Compute()
148 \image html hexotic_sd_mode_2.png Hexotic mesh of a box cut by a holed sphere ( sd = 2 )
150 \ref tui_hexotic "Back to top"
152 \subsection tui_hexotic_sd_mode3 Sub-domain mode = 3
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")
160 # Create the 2D algo: BlSurf with geometrical mesh
161 Mesh_hexotic_sd3.Triangle(algo=smesh.BLSURF).Parameters().SetGeometricMesh( 1 )
163 # Create the 3D algo: Hexotic with:
167 Mesh_hexotic_sd3.Hexahedron(algo=smesh.Hexotic).SetMinMaxHexes(4, 8).SetHexoticSdMode( 3 )
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 ))
178 Mesh_hexotic_sd3.Compute()
183 \image html hexotic_sd_mode_3.png Hexotic mesh of a box cut by a holed sphere ( sd = 3 )
185 \ref tui_hexotic "Back to top"
187 \subsection tui_hexotic_sd_mode4 Sub-domain mode = 4
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' )
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 )
205 Mesh_hexotic_sd4.Compute()
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 )
212 \ref tui_hexotic "Back to top"