2013-02-12 20:37:44 +06:00
|
|
|
# Sew Free Borders
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
2021-08-12 14:38:10 +05:00
|
|
|
salome.salome_init_without_session()
|
2013-04-04 13:08:19 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
from salome.geom import geomBuilder
|
2013-04-04 13:08:19 +06:00
|
|
|
from salome.smesh import smeshBuilder
|
2022-04-11 18:28:01 +05:00
|
|
|
|
|
|
|
geom_builder = geomBuilder.New()
|
|
|
|
smesh_builder = smeshBuilder.New()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2015-07-16 22:52:26 +05:00
|
|
|
# make two not sewed quadranges
|
2022-04-11 18:28:01 +05:00
|
|
|
OY0 = geom_builder.MakeVectorDXDYDZ(0, 1, 0)
|
|
|
|
OY1 = geom_builder.MakeTranslation( OY0, 1, 0, 0, theName="OY1" )
|
|
|
|
OY2 = geom_builder.MakeTranslation( OY0, 1.01, 0, 0, theName="OY2" )
|
|
|
|
OY3 = geom_builder.MakeTranslation( OY0, 2, 0, 0 )
|
|
|
|
q1 = geom_builder.MakeQuad2Edges( OY0, OY1 )
|
|
|
|
q2 = geom_builder.MakeQuad2Edges( OY2, OY3 )
|
2015-07-16 22:52:26 +05:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
shape = geom_builder.MakeCompound( [q1,q2], theName='shape' )
|
2015-07-16 22:52:26 +05:00
|
|
|
|
|
|
|
# make a non-uniform quadrangle mesh on two faces
|
2022-04-11 18:28:01 +05:00
|
|
|
mesh = smesh_builder.Mesh(shape, "Two faces : quadrangle mesh")
|
2015-07-16 22:52:26 +05:00
|
|
|
mesh.Segment().Arithmetic1D( 0.1, 0.4 )
|
|
|
|
mesh.Segment(q1).NumberOfSegments( 5 )
|
|
|
|
mesh.Quadrangle()
|
2023-02-21 18:59:44 +05:00
|
|
|
if not mesh.Compute(): raise Exception("Error when computing Mesh")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2015-07-16 22:52:26 +05:00
|
|
|
# sew free borders
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2015-07-16 22:52:26 +05:00
|
|
|
segs1 = mesh.GetSubMeshElementsId( OY1 ) # mesh segments generated on borders
|
|
|
|
segs2 = mesh.GetSubMeshElementsId( OY2 )
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2015-07-16 22:52:26 +05:00
|
|
|
FirstNodeID1 = mesh.GetElemNode( segs1[0], 0 )
|
|
|
|
SecondNodeID1 = mesh.GetElemNode( segs1[0], 1 )
|
|
|
|
LastNodeID1 = mesh.GetElemNode( segs1[-1], 1 )
|
|
|
|
FirstNodeID2 = mesh.GetElemNode( segs2[0], 0 )
|
|
|
|
SecondNodeID2 = mesh.GetElemNode( segs2[0], 1 )
|
|
|
|
LastNodeID2 = mesh.GetElemNode( segs2[-1], 1 )
|
|
|
|
CreatePolygons = True
|
|
|
|
CreatePolyedrs = False
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2015-07-16 22:52:26 +05:00
|
|
|
res = mesh.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
|
|
|
|
FirstNodeID2, SecondNodeID2, LastNodeID2,
|
|
|
|
CreatePolygons, CreatePolyedrs )
|
2017-03-20 17:27:30 +05:00
|
|
|
print(res)
|
|
|
|
print("nb polygons:", mesh.NbPolygons())
|