Salome HOME
52976: Find Elements by Point - All does not find Ball element
[modules/smesh.git] / doc / salome / examples / creating_meshes_ex08.py
1 # Mesh Copying
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8
9 import SMESH, SALOMEDS
10 from salome.smesh import smeshBuilder
11 smesh =  smeshBuilder.New(salome.myStudy)
12
13 # make geometry of a box
14 box = geompy.MakeBoxDXDYDZ(100,100,100)
15 face = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0]
16
17 # generate a prismatic 3D mesh
18 mesh = smesh.Mesh(box)
19 localAlgo = mesh.Triangle(face)
20 mesh.AutomaticHexahedralization()
21
22 # objects to copy
23 fGroup = mesh.GroupOnGeom( face, "2D on face")
24 nGroup = mesh.GroupOnGeom( face, "nodes on face", SMESH.NODE)
25 subMesh = localAlgo.GetSubMesh()
26
27 # make a new mesh by copying different parts of the mesh
28
29 # 1. copy the whole mesh
30 newMesh = smesh.CopyMesh( mesh, "whole mesh copy")
31
32 # 2. copy a group of 2D elements along with groups
33 newMesh = smesh.CopyMesh( fGroup,  "face group copy with groups",toCopyGroups=True)
34
35 # 3. copy a group of nodes
36 newMesh = smesh.CopyMesh( nGroup, "node group copy")
37
38 # 4. copy some faces
39 faceIds = fGroup.GetIDs()[-10:]
40 newMesh = smesh.CopyMesh( mesh.GetIDSource( faceIds, SMESH.FACE ), "some faces copy")
41
42 # 5. copy some nodes
43 nodeIds = nGroup.GetIDs()[-10:]
44 newMesh = smesh.CopyMesh( mesh.GetIDSource( nodeIds, SMESH.NODE), "some nodes copy")
45
46 # 6. copy a sub-mesh
47 newMesh = smesh.CopyMesh( subMesh, "sub-mesh copy" )