Salome HOME
Update mail address
[modules/smesh.git] / src / SMESH_SWIG / SMESH_test4.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 #
4 #  This library is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU Lesser General Public
6 #  License as published by the Free Software Foundation; either
7 #  version 2.1 of the License.
8 #
9 #  This library is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 #  Lesser General Public License for more details.
13 #
14 #  You should have received a copy of the GNU Lesser General Public
15 #  License along with this library; if not, write to the Free Software
16 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 import salome
21 import geompy
22 import SMESH
23 import StdMeshers
24
25 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
26 smesh.SetCurrentStudy(salome.myStudy)
27
28 box   = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
29 idbox = geompy.addToStudy(box, "box")
30
31 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
32 face   = subShapeList[0]
33 name   = geompy.SubShapeName(face, box)
34 idface = geompy.addToStudyInFather(box, face, name)
35
36 box  = salome.IDToObject(idbox)
37 face = salome.IDToObject(idface)
38
39 hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
40 hyp1.SetNumberOfSegments(10)
41 hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
42 hyp2.SetMaxElementArea(10)
43 hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
44 hyp3.SetMaxElementArea(100)
45
46 algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
47 algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
48
49 mesh = smesh.CreateMesh(box)
50 mesh.AddHypothesis(box,hyp1)
51 mesh.AddHypothesis(box,hyp2)
52 mesh.AddHypothesis(box,algo1)
53 mesh.AddHypothesis(box,algo2)
54
55 submesh = mesh.GetSubMesh(face, "SubMeshFace")
56 mesh.AddHypothesis(face,hyp1)
57 mesh.AddHypothesis(face,hyp3)
58 mesh.AddHypothesis(face,algo1)
59 mesh.AddHypothesis(face,algo2)
60
61 smesh.Compute(mesh,box)
62
63 faces = submesh.GetElementsByType(SMESH.FACE)
64 if len(faces) > 1:
65     print len(faces), len(faces)/2
66     group1 = mesh.CreateGroup(SMESH.FACE,"Group of faces")
67     group2 = mesh.CreateGroup(SMESH.FACE,"Another group of faces")
68     group1.Add(faces[:int(len(faces)/2)])
69     group2.Add(faces[int(len(faces)/2):])
70
71 salome.sg.updateObjBrowser(1)