X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=doc%2Fexamples%2Fquality_controls_defl.py;fp=doc%2Fexamples%2Fquality_controls_defl.py;h=42c04a3151c1765e9686765f68f5b11d945b1a0b;hb=4cf07a14111e98e8889620ee7e6371574c31a50c;hp=0000000000000000000000000000000000000000;hpb=d9f4b53e489dd5857db264ede6acded7b076c9f1;p=modules%2Fsmesh.git diff --git a/doc/examples/quality_controls_defl.py b/doc/examples/quality_controls_defl.py new file mode 100644 index 000000000..42c04a315 --- /dev/null +++ b/doc/examples/quality_controls_defl.py @@ -0,0 +1,43 @@ +# Deflection 2D + +import salome +salome.salome_init_without_session() + +import SMESH +from salome.geom import geomBuilder +from salome.smesh import smeshBuilder + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +# fuse a box and a sphere +Sphere_1 = geom_builder.MakeSphereR(100) +Box_1 = geom_builder.MakeBoxDXDYDZ(200, 200, 200) +Fuse = geom_builder.MakeFuse( Sphere_1, Box_1, theName="box + sphere" ) + +# create a mesh +mesh = smesh_builder.Mesh( Fuse, "Deflection_2D") +algo = mesh.Segment() +algo.LocalLength(35) +algo = mesh.Triangle() +mesh.Compute() + +# get min and max deflection +minMax = mesh.GetMinMax( SMESH.FT_Deflection2D ) +print("min and max deflection: ", minMax) + +# get deflection of a certain face +faceID = mesh.NbEdges() + mesh.NbFaces() +defl = mesh.FunctorValue( SMESH.FT_Deflection2D, faceID ) +print("deflection of face %s = %s" % ( faceID, defl )) + +margin = minMax[1] / 2 + +# get all faces with deflection LESS than the margin +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Deflection2D, '<', margin, mesh=mesh) +anIds = aFilter.GetIDs() +print("%s faces have deflection less than %s" %( len(anIds), margin )) + +# create a group of faces with deflection MORE than the margin +aGroup = mesh.MakeGroup("Deflection > " + repr(margin), SMESH.FACE, SMESH.FT_Deflection2D,'>',margin) +print("%s faces have deflection more than %s: %s ..." %( aGroup.Size(), margin, aGroup.GetIDs()[:10] ))