Salome HOME
Bug 0020072: GHS3DPRLPLUGIN update. Integrating the attached patch.
[modules/smesh.git] / src / SMESH_SWIG / SMESH_test4.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 import salome
23 import geompy
24 import smesh
25
26
27 # ---- GEOM
28
29 box   = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
30 idbox = geompy.addToStudy(box, "box")
31
32 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
33 face   = subShapeList[0]
34 name   = geompy.SubShapeName(face, box)
35 idface = geompy.addToStudyInFather(box, face, name)
36
37 box  = salome.IDToObject(idbox)
38 face = salome.IDToObject(idface)
39
40 # ---- SMESH
41
42 mesh = smesh.Mesh(box, "Meshbox")
43
44 # Set 1D algorithm/hypotheses to mesh
45 algo1 = mesh.Segment()
46 algo1.NumberOfSegments(10)
47
48 # Set 2D algorithm/hypotheses to mesh
49 algo2 = mesh.Triangle(smesh.MEFISTO)
50 algo2.MaxElementArea(10)
51
52 # Create submesh on face
53 algo3 = mesh.Segment(face)
54 algo3.NumberOfSegments(10)
55 algo4 = mesh.Triangle(smesh.MEFISTO, face)
56 algo4.MaxElementArea(100)
57 submesh = algo4.GetSubMesh()
58 smesh.SetName(submesh, "SubMeshFace")
59
60
61 mesh.Compute()
62
63 faces = submesh.GetElementsByType(smesh.FACE)
64 if len(faces) > 1:
65     print len(faces), len(faces)/2
66     group1 = mesh.CreateEmptyGroup(smesh.FACE,"Group of faces")
67     group2 = mesh.CreateEmptyGroup(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)