Salome HOME
0023591: [EDF] Add test to check meshing plug-ins to SMESH module
[modules/smesh.git] / doc / salome / examples / quality_controls_defl.py
1 # Deflection 2D
2
3
4 import salome
5 salome.salome_init()
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
8
9 import SMESH
10 from salome.smesh import smeshBuilder
11 smesh =  smeshBuilder.New()
12
13 # fuse a box and a sphere
14 Sphere_1 = geompy.MakeSphereR(100)
15 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
16 Fuse = geompy.MakeFuse( Sphere_1, Box_1, theName="box + sphere" )
17
18 # create a mesh
19 mesh = smesh.Mesh( Fuse, "Deflection_2D")
20 algo = mesh.Segment()
21 algo.LocalLength(35)
22 algo = mesh.Triangle()
23 mesh.Compute()
24
25 # get min and max deflection
26 minMax = mesh.GetMinMax( SMESH.FT_Deflection2D )
27 print("min and max deflection: ", minMax)
28
29 # get deflection of a certain face
30 faceID = mesh.NbEdges() + mesh.NbFaces()
31 defl = mesh.FunctorValue( SMESH.FT_Deflection2D, faceID )
32 print("deflection of face %s = %s" % ( faceID, defl ))
33
34 margin = minMax[1] / 2
35
36 # get all faces with deflection LESS than the margin
37 aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Deflection2D, '<', margin, mesh=mesh)
38 anIds = aFilter.GetIDs()
39 print("%s faces have deflection less than %s" %( len(anIds), margin ))
40
41 # create a group of faces with deflection MORE than the margin
42 aGroup = mesh.MakeGroup("Deflection > " + repr(margin), SMESH.FACE, SMESH.FT_Deflection2D,'>',margin)
43 print("%s faces have deflection more than %s: %s ..." %( aGroup.Size(), margin, aGroup.GetIDs()[:10] ))
44
45 salome.sg.updateObjBrowser()