2014-03-18 19:28:37 +06:00
|
|
|
# "Import 2D Elements from Another Mesh" example
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
|
|
|
salome.salome_init()
|
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
|
|
|
geompy = geomBuilder.New(salome.myStudy)
|
|
|
|
|
|
|
|
import SMESH, SALOMEDS
|
|
|
|
from salome.smesh import smeshBuilder
|
|
|
|
smesh = smeshBuilder.New(salome.myStudy)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Make a patritioned box
|
|
|
|
|
|
|
|
box = geompy.MakeBoxDXDYDZ(100,100,100)
|
|
|
|
|
|
|
|
N = geompy.MakeVectorDXDYDZ( 1,0,0 )
|
|
|
|
O = geompy.MakeVertex( 50,0,0 )
|
|
|
|
plane = geompy.MakePlane( O, N, 200 ) # plane YOZ
|
|
|
|
|
|
|
|
shape2boxes = geompy.MakeHalfPartition( box, plane )
|
|
|
|
boxes = geompy.SubShapeAllSorted(shape2boxes, geompy.ShapeType["SOLID"])
|
|
|
|
|
|
|
|
geompy.addToStudy( boxes[0], "boxes[0]")
|
|
|
|
geompy.addToStudy( boxes[1], "boxes[1]")
|
|
|
|
midFace0 = geompy.SubShapeAllSorted(boxes[0], geompy.ShapeType["FACE"])[5]
|
|
|
|
geompy.addToStudyInFather( boxes[0], midFace0, "middle Face")
|
|
|
|
midFace1 = geompy.SubShapeAllSorted(boxes[1], geompy.ShapeType["FACE"])[0]
|
|
|
|
geompy.addToStudyInFather( boxes[1], midFace1, "middle Face")
|
|
|
|
|
|
|
|
# Mesh one of boxes with quadrangles. It is a source mesh
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
srcMesh = smesh.Mesh(boxes[0], "source mesh") # box coloser to CS origin
|
2013-02-12 20:37:44 +06:00
|
|
|
nSeg1 = srcMesh.Segment().NumberOfSegments(4)
|
|
|
|
srcMesh.Quadrangle()
|
|
|
|
srcMesh.Compute()
|
2013-04-04 13:08:19 +06:00
|
|
|
srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", SMESH.FACE )
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Import faces from midFace0 to the target mesh
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
tgtMesh = smesh.Mesh(boxes[1], "target mesh")
|
2013-02-12 20:37:44 +06:00
|
|
|
importAlgo = tgtMesh.UseExisting2DElements(midFace1)
|
|
|
|
import2hyp = importAlgo.SourceFaces( [srcFaceGroup] )
|
|
|
|
tgtMesh.Segment().NumberOfSegments(3)
|
|
|
|
tgtMesh.Quadrangle()
|
|
|
|
tgtMesh.Compute()
|
|
|
|
|
|
|
|
# Import the whole source mesh with groups
|
|
|
|
import2hyp.SetCopySourceMesh(True,True)
|
|
|
|
tgtMesh.Compute()
|