Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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
24
25 # ---- GEOM
26
27 box   = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
28 idbox = geompy.addToStudy(box, "box")
29
30 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
31 face   = subShapeList[0]
32 name   = geompy.SubShapeName(face, box)
33 idface = geompy.addToStudyInFather(box, face, name)
34
35 box  = salome.IDToObject(idbox)
36 face = salome.IDToObject(idface)
37
38 # ---- SMESH
39
40 mesh = smesh.Mesh(box, "Meshbox")
41
42 # Set 1D algorithm/hypotheses to mesh
43 algo1 = mesh.Segment()
44 algo1.NumberOfSegments(10)
45
46 # Set 2D algorithm/hypotheses to mesh
47 algo2 = mesh.Triangle(smesh.MEFISTO)
48 algo2.MaxElementArea(10)
49
50 # Create submesh on face
51 algo3 = mesh.Segment(face)
52 algo3.NumberOfSegments(10)
53 algo4 = mesh.Triangle(smesh.MEFISTO, face)
54 algo4.MaxElementArea(100)
55 submesh = algo4.GetSubMesh()
56 smesh.SetName(submesh, "SubMeshFace")
57
58
59 mesh.Compute()
60
61 faces = submesh.GetElementsByType(smesh.FACE)
62 if len(faces) > 1:
63     print len(faces), len(faces)/2
64     group1 = mesh.CreateEmptyGroup(smesh.FACE,"Group of faces")
65     group2 = mesh.CreateEmptyGroup(smesh.FACE,"Another group of faces")
66     group1.Add(faces[:int(len(faces)/2)])
67     group2.Add(faces[int(len(faces)/2):])
68
69 salome.sg.updateObjBrowser(1)