Salome HOME
a76e8d175fafa5fee68ac452c9201ed03327728f
[modules/smesh.git] / doc / salome / examples / creating_meshes_ex08.py
1 # Mesh Copying
2
3 from smesh import *
4 SetCurrentStudy(salome.myStudy)
5
6 # make geometry of a box
7 box = geompy.MakeBoxDXDYDZ(100,100,100)
8 face = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0]
9
10 # generate 3D mesh
11 mesh = Mesh(box)
12 localAlgo = mesh.Triangle(face)
13 mesh.AutomaticHexahedralization()
14
15 # objects to copy
16 fGroup = mesh.GroupOnGeom( face, "2D on face")
17 nGroup = mesh.GroupOnGeom( face, "nodes on face", NODE)
18 subMesh = localAlgo.GetSubMesh()
19
20 # make a new mesh by copying different parts of the mesh
21
22 # 1. copy the whole mesh
23 newMesh = CopyMesh( mesh, "whole mesh copy")
24
25 # 2. copy a group of 2D elements along with groups
26 newMesh = CopyMesh( fGroup,  "face group copy with groups",toCopyGroups=True)
27
28 # 3. copy a group of nodes with preseving their ids
29 newMesh = CopyMesh( nGroup, "node group copy", toKeepIDs=True)
30
31 # 4. copy some faces
32 faceIds = fGroup.GetIDs()[-10:]
33 newMesh = CopyMesh( mesh.GetIDSource( faceIds, FACE ), "some faces copy")
34
35 # 5. copy some nodes
36 nodeIds = nGroup.GetIDs()[-10:]
37 newMesh = CopyMesh( mesh.GetIDSource( nodeIds, NODE), "some nodes copy")
38
39 # 6. copy a sub-mesh
40 newMesh = CopyMesh( subMesh, "submesh copy" )