1 # Create 2D mesh from 3D elements
4 salome.salome_init_without_session()
7 from salome.geom import geomBuilder
8 from salome.smesh import smeshBuilder
10 geom_builder = geomBuilder.New()
11 smesh_builder = smeshBuilder.New()
13 box = geom_builder.MakeBoxDXDYDZ(100, 100, 100)
15 gFaces = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType["FACE"])
16 f1,f2 = gFaces[0],gFaces[1]
17 geom_builder.addToStudy(box,"box")
18 geom_builder.addToStudyInFather(box,f1,"face1")
19 geom_builder.addToStudyInFather(box,f2,"face2")
21 twoFaces = geom_builder.MakeCompound([f1,f2])
25 ## Create 2D from 3D elements
29 init_mesh = smesh_builder.Mesh(box, "box")
30 init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
33 mesh_1 = smesh_builder.CopyMesh(init_mesh, "Mesh_1")
34 #Return the number of created faces in the original mesh.
35 nb, new_mesh, new_group = mesh_1.MakeBoundaryOfEachElement()
37 if nb != 54: raise Exception("Error on MakeBoundaryOfEachElement call. The number of created elements does not match.")
38 if new_mesh.GetId() != mesh_1.GetId(): raise Exception("The mesh created from MakeBoundaryElements should be the same of the call")
39 if new_group: raise Exception("The group created from MakeBoundaryElements should be undefined")
41 mesh_2 = smesh_builder.CopyMesh(init_mesh, "Mesh_2")
43 #Return the number of created faces and a new_mesh and new_group
44 nb, new_mesh, new_group = mesh_2.MakeBoundaryOfEachElement("MyFacesElements", "Face_Mesh")
45 if nb != 54: raise Exception("Error on MakeBoundaryOfEachElement call. The number of created elements does not match.")
46 if new_mesh.GetId() == mesh_2.GetId(): raise Exception("The mesh created from MakeBoundaryElements should be the different of the call")
47 if not new_group: raise Exception("The group created from MakeBoundaryElements should be defined")