6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
10 from salome.smesh import smeshBuilder
11 smesh = smeshBuilder.New(salome.myStudy)
14 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
15 idbox = geompy.addToStudy(box, "box")
18 tetra = smesh.Mesh(box, "MeshBox")
19 tetra.Segment().NumberOfSegments(7)
26 # export the mesh in a MED file
28 medFile = tempfile.NamedTemporaryFile(suffix=".med").name
29 tetra.ExportMED( medFile, 0 )
31 # export a group in a MED file
32 face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] # a box side
33 group = tetra.GroupOnGeom( face, "face group" ) # group of 2D elements on the <face>
34 tetra.ExportMED( medFile, meshPart=group )
36 # ========================
37 # autoDimension parameter
38 # ========================
40 face = geompy.MakeFaceHW( 10, 10, 1, "rectangle" )
41 mesh2D = smesh.Mesh( face, "mesh2D" )
42 mesh2D.AutomaticHexahedralization(0)
46 # exported mesh is in 2D space because it is a planar mesh lying
47 # on XOY plane, and autoDimension=True by default
48 mesh2D.ExportMED( medFile )
49 medMesh = MEDLoader.MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0)
50 print "autoDimension==True, exported mesh is in %sD"%medMesh.getSpaceDimension()
52 # exported mesh is in 3D space, same as in Mesh module,
53 # thanks to autoDimension=False
54 mesh2D.ExportMED( medFile, autoDimension=False )
55 medMesh = MEDLoader.MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0)
56 print "autoDimension==False, exported mesh is in %sD"%medMesh.getSpaceDimension()