Salome HOME
Check that meshing passes OK
[plugins/hexoticplugin.git] / doc / salome / examples / hexoticdemo.py
1 import salome
2 salome.salome_init()
3
4 from salome.geom import geomBuilder
5 geompy = geomBuilder.New()
6
7 from salome.smesh import smeshBuilder
8 smesh =  smeshBuilder.New()
9
10
11 # create a sphere
12 sphere = geompy.MakeSphereR(100.)
13 geompy.addToStudy(sphere, "sphere")
14
15 # create a mesh on the sphere
16 mghexaMesh = smesh.Mesh(sphere,"sphere: MG-CADSurf and MG-Hexa mesh")
17
18 # create a MG-CADSurf algorithm for faces
19 MG_CADSurf = mghexaMesh.Triangle(algo=smeshBuilder.MG_CADSurf)
20 MG_CADSurf.SetGeometricMesh( 1 )
21
22 # create a MG-Hexa algorithm for volumes
23 MG_Hexa = mghexaMesh.Hexahedron(algo=smeshBuilder.MG_Hexa)
24
25 ## compute the mesh
26 #mghexaMesh.Compute()
27
28 # Change the level of subdivision
29 MG_Hexa.SetMinMaxHexes(4, 8)
30
31 ## compute the mesh
32 #mghexaMesh.Compute()
33
34 # Local size
35
36 # Get the sphere skin
37 faces = geompy.SubShapeAll(sphere, geompy.ShapeType["FACE"])
38
39 # Set a local size on the face
40 MG_Hexa.SetMinMaxSize(10, 20)
41 MG_Hexa.SetSizeMap(faces[0], 10)
42
43 # compute the mesh
44 assert mghexaMesh.Compute(), "Meshing fails"
45
46 # End of script