Salome HOME
Mesh redesine. New fields added to specify whether hypothesis is main or additional...
[modules/smesh.git] / src / SMESH_SWIG / SMESH_test4.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 box   = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
10 idbox = geompy.addToStudy(box, "box")
11
12 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
13 face   = subShapeList[0]
14 name   = geompy.SubShapeName(face, box)
15 idface = geompy.addToStudyInFather(box, face, name)
16
17 box  = salome.IDToObject(idbox)
18 face = salome.IDToObject(idface)
19
20 hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
21 hyp1.SetNumberOfSegments(10)
22 hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
23 hyp2.SetMaxElementArea(10)
24 hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
25 hyp3.SetMaxElementArea(100)
26
27 algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
28 algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
29
30 mesh = smesh.CreateMesh(box)
31 mesh.AddHypothesis(box,hyp1)
32 mesh.AddHypothesis(box,hyp2)
33 mesh.AddHypothesis(box,algo1)
34 mesh.AddHypothesis(box,algo2)
35
36 submesh = mesh.GetSubMesh(face, "SubMeshFace")
37 mesh.AddHypothesis(face,hyp1)
38 mesh.AddHypothesis(face,hyp3)
39 mesh.AddHypothesis(face,algo1)
40 mesh.AddHypothesis(face,algo2)
41
42 smesh.Compute(mesh,box)
43
44 faces = submesh.GetElementsByType(SMESH.FACE)
45 if len(faces) > 1:
46     print len(faces), len(faces)/2
47     group1 = mesh.CreateGroup(SMESH.FACE,"Group of faces")
48     group2 = mesh.CreateGroup(SMESH.FACE,"Another group of faces")
49     group1.Add(faces[:int(len(faces)/2)])
50     group2.Add(faces[int(len(faces)/2):])
51
52 salome.sg.updateObjBrowser(1)