Salome HOME
c6881c8250a232dca6f8ebd402aa473cb2d9a892
[modules/smesh.git] / src / SMESH_SWIG / SMESH_freebord.py
1 import salome
2 import geompy
3 import SMESH
4 import StdMeshers
5
6 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
7 smesh.SetCurrentStudy(salome.myStudy)
8
9 # Create box without one plane
10
11 box = geompy.MakeBox(0., 0., 0., 10., 20., 30.)
12 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
13
14 FaceList  = []
15 for i in range( 5 ):
16   FaceList.append( subShapeList[ i ] )
17
18 aComp = geompy.MakeCompound( FaceList )
19 aBox = geompy.Sew( aComp, 1. )
20 idbox = geompy.addToStudy( aBox, "box" )
21   
22 aBox  = salome.IDToObject( idbox )
23
24 # Create mesh
25
26 hyp1 = smesh.CreateHypothesis("NumberOfSegments", "StdMeshersEngine")
27 hyp1.SetNumberOfSegments(5)
28 hyp2 = smesh.CreateHypothesis("MaxElementArea", "StdMeshersEngine")
29 hyp2.SetMaxElementArea(20)
30 hyp3 = smesh.CreateHypothesis("MaxElementArea", "StdMeshersEngine")
31 hyp3.SetMaxElementArea(50)
32
33 algo1 = smesh.CreateHypothesis("Regular_1D", "StdMeshersEngine")
34 algo2 = smesh.CreateHypothesis("MEFISTO_2D", "StdMeshersEngine")
35
36 mesh = smesh.CreateMesh(aBox)
37 mesh.AddHypothesis(aBox,hyp1)
38 mesh.AddHypothesis(aBox,hyp2)
39 mesh.AddHypothesis(aBox,algo1)
40 mesh.AddHypothesis(aBox,algo2)
41
42 smesh.Compute(mesh,aBox)
43
44 smeshgui = salome.ImportComponentGUI("SMESH")
45 smeshgui.Init(salome.myStudyId);
46 smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh_freebord" );
47
48 # Criterion : Free edges
49 aFilterMgr = smesh.CreateFilterManager()
50 aPredicate = aFilterMgr.CreateFreeBorders()
51 aFilter = aFilterMgr.CreateFilter()
52 aFilter.SetPredicate( aPredicate )
53
54 anIds = aFilter.GetElementsId( mesh )
55
56 # print result
57 print "Criterion: Free edges Nb = ", len( anIds )
58 for i in range( len( anIds ) ):
59   print anIds[ i ]
60
61 # create group
62 aGroup = mesh.CreateGroup( SMESH.EDGE, "Free edges" )
63 aGroup.Add( anIds )
64
65
66 salome.sg.updateObjBrowser(1)