6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
10 from salome.smesh import smeshBuilder
11 smesh = smeshBuilder.New(salome.myStudy)
14 box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.)
15 box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.)
17 EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
19 aComp = geompy.MakeCompound([box1, box2])
20 geompy.addToStudy(aComp, "Two boxes")
22 # create a mesh on two boxes
23 mesh = smesh.Mesh(aComp, "Sew Side Elements")
25 algo1D = mesh.Segment()
26 algo1D.NumberOfSegments(2)
27 algo2D = mesh.Quadrangle()
29 algo_local = mesh.Segment(EdgesList[8])
30 algo_local.NumberOfSegments(4)
31 algo_local.Propagation()
37 # find elements to sew
38 face1 = geompy.GetFaceNearPoint( aComp, geompy.MakeVertex( 5, 10, 5 ))
39 IDsOfSide1Elements = mesh.GetSubMeshElementsId( face1 )
40 print "side faces 1:",IDsOfSide1Elements
42 face1Translated = geompy.MakeTranslation( face1, 0,5,0 )
43 faceFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_BelongToGeom,'=', face1Translated )
44 IDsOfSide2Elements = mesh.GetIdsFromFilter( faceFilter )
45 print "side faces 2:",IDsOfSide2Elements
47 # find corresponding nodes on sides
48 edge1 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 10, 5 ))
49 segs1 = mesh.GetSubMeshElementsId( edge1 ) # mesh segments generated on edge1
50 NodeID1OfSide1ToMerge = mesh.GetElemNode( segs1[0], 0 )
51 NodeID2OfSide1ToMerge = mesh.GetElemNode( segs1[0], 1 )
52 print "nodes of side1:", [NodeID1OfSide1ToMerge,NodeID2OfSide1ToMerge]
54 edge2 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 15, 5 ))
55 segs2 = mesh.GetSubMeshElementsId( edge2 ) # mesh segments generated on edge2
56 NodeID1OfSide2ToMerge = mesh.GetElemNode( segs2[0], 0 )
57 NodeID2OfSide2ToMerge = mesh.GetElemNode( segs2[0], 1 )
58 print "nodes of side2:", [NodeID1OfSide2ToMerge,NodeID2OfSide2ToMerge]
60 res = mesh.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
61 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
62 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)