2013-02-12 20:37:44 +06:00
|
|
|
# Mesh Copying
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
|
|
|
salome.salome_init()
|
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
2017-06-13 15:01:10 +05:00
|
|
|
geompy = geomBuilder.New()
|
2013-04-04 13:08:19 +06:00
|
|
|
|
|
|
|
import SMESH, SALOMEDS
|
|
|
|
from salome.smesh import smeshBuilder
|
2017-06-13 15:01:10 +05:00
|
|
|
smesh = smeshBuilder.New()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# make geometry of a box
|
|
|
|
box = geompy.MakeBoxDXDYDZ(100,100,100)
|
|
|
|
face = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0]
|
|
|
|
|
2016-03-17 21:21:24 +05:00
|
|
|
# generate a prismatic 3D mesh
|
2018-10-12 19:25:16 +05:00
|
|
|
mesh = smesh.Mesh(box, "box")
|
2013-02-12 20:37:44 +06:00
|
|
|
localAlgo = mesh.Triangle(face)
|
2018-10-12 19:25:16 +05:00
|
|
|
mesh.Segment().NumberOfSegments( 3 )
|
|
|
|
mesh.Quadrangle()
|
|
|
|
mesh.Prism()
|
|
|
|
mesh.Compute()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# objects to copy
|
|
|
|
fGroup = mesh.GroupOnGeom( face, "2D on face")
|
2013-04-04 13:08:19 +06:00
|
|
|
nGroup = mesh.GroupOnGeom( face, "nodes on face", SMESH.NODE)
|
2013-02-12 20:37:44 +06:00
|
|
|
subMesh = localAlgo.GetSubMesh()
|
|
|
|
|
|
|
|
# make a new mesh by copying different parts of the mesh
|
|
|
|
|
|
|
|
# 1. copy the whole mesh
|
2013-04-04 13:08:19 +06:00
|
|
|
newMesh = smesh.CopyMesh( mesh, "whole mesh copy")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# 2. copy a group of 2D elements along with groups
|
2013-04-04 13:08:19 +06:00
|
|
|
newMesh = smesh.CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2014-10-22 19:21:15 +06:00
|
|
|
# 3. copy a group of nodes
|
|
|
|
newMesh = smesh.CopyMesh( nGroup, "node group copy")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# 4. copy some faces
|
|
|
|
faceIds = fGroup.GetIDs()[-10:]
|
2013-04-04 13:08:19 +06:00
|
|
|
newMesh = smesh.CopyMesh( mesh.GetIDSource( faceIds, SMESH.FACE ), "some faces copy")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# 5. copy some nodes
|
|
|
|
nodeIds = nGroup.GetIDs()[-10:]
|
2013-04-04 13:08:19 +06:00
|
|
|
newMesh = smesh.CopyMesh( mesh.GetIDSource( nodeIds, SMESH.NODE), "some nodes copy")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# 6. copy a sub-mesh
|
2016-03-17 21:21:24 +05:00
|
|
|
newMesh = smesh.CopyMesh( subMesh, "sub-mesh copy" )
|
2018-10-12 19:25:16 +05:00
|
|
|
|
|
|
|
|
|
|
|
# make a new mesh with same hypotheses on a modified geometry
|
|
|
|
|
|
|
|
smallBox = geompy.MakeScaleAlongAxes( box, None, 1, 0.5, 0.5 )
|
|
|
|
cutBox = geompy.MakeCut( box, smallBox, theName="box - smallBox" )
|
|
|
|
|
|
|
|
ok, newMesh, groups, submehses, hyps, invIDs = smesh.CopyMeshWithGeom( mesh, cutBox, "cutBox" )
|
|
|
|
newMesh.Compute()
|