Salome HOME
PR: synchro V6_main tag mergeto_V7_main_11Feb13
[modules/smesh.git] / doc / salome / examples / quality_controls_ex03.py
1 # Length 1D
2
3 import salome
4 import geompy
5
6 import smesh
7
8 # create open shell: a box without one plane
9 box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
10 FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
11 FaceList.remove(FaceList[5])
12 box = geompy.MakeShell(FaceList)
13 idbox = geompy.addToStudy(box, "box")
14
15 # create a mesh
16 mesh = smesh.Mesh(box, "Mesh_Length_1D")
17 algo = mesh.Segment()
18 algo.NumberOfSegments(5)
19 algo = mesh.Triangle()
20 algo.MaxElementArea(20.)
21 mesh.Compute() 
22
23 # Criterion : Length > 3.
24 length_margin = 3.
25
26 aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, length_margin)
27 anIds = mesh.GetIdsFromFilter(aFilter) 
28
29 # print the result
30 print "Criterion: Edges length > ", length_margin, " Nb = ", len(anIds)
31 j = 1
32 for i in range(len(anIds)):
33   if j > 20: j = 1; print ""
34   print anIds[i],
35   j = j + 1
36   pass
37 print ""
38
39 # create a group
40 aGroup = mesh.CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`)
41 aGroup.Add(anIds)
42
43 salome.sg.updateObjBrowser(1)