Salome HOME
Revert last modification
[modules/smesh.git] / src / SMESH_SWIG / SMESH_test1.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 #  This library is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU Lesser General Public
9 #  License as published by the Free Software Foundation; either
10 #  version 2.1 of the License.
11 #
12 #  This library is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #  Lesser General Public License for more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public
18 #  License along with this library; if not, write to the Free Software
19 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 #  File   : SMESH_test1.py
24 #  Module : SMESH
25 #
26 import salome
27 import geompy
28 import smesh
29
30 # ---- define a box
31
32 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
33 idbox = geompy.addToStudy(box, "box")
34
35 # ---- add first face of box in study
36
37 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
38 face = subShapeList[0]
39 name = geompy.SubShapeName(face, box)
40 print name
41 idface = geompy.addToStudyInFather(box, face, name)
42
43 # ---- add shell from box  in study
44
45 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
46 shell = subShellList[0]
47 name = geompy.SubShapeName(shell, box)
48 print name
49 idshell = geompy.addToStudyInFather(box, shell, name)
50
51 # ---- add first edge of face in study
52
53 edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
54 edge = edgeList[0]
55 name = geompy.SubShapeName(edge, face)
56 print name
57 idedge = geompy.addToStudyInFather(face, edge, name)
58
59
60 # ---- SMESH
61
62 smesh.SetCurrentStudy(salome.myStudy)
63
64 # ---- Init a Mesh with the box
65
66 mesh = smesh.Mesh(box, "Meshbox")
67
68 print "-------------------------- add hypothesis to box"
69 algoReg1 = mesh.Segment()
70 hypNbSeg1 = algoReg1.NumberOfSegments(7)
71 print hypNbSeg1.GetName()
72 print hypNbSeg1.GetId()
73 print hypNbSeg1.GetNumberOfSegments()
74 smesh.SetName(hypNbSeg1, "NumberOfSegments_7")
75
76 algoMef1 = mesh.Triangle()
77 hypArea1 = algoMef1.MaxElementArea(2500)
78 print hypArea1.GetName()
79 print hypArea1.GetId()
80 print hypArea1.GetMaxElementArea()
81 smesh.SetName(hypArea1, "MaxElementArea_2500")
82
83 # ---- add hypothesis to edge
84 print "-------------------------- add hypothesis to edge"
85 edge = salome.IDToObject(idedge)
86
87 algoReg2 = mesh.Segment(edge)
88 hypLen1 = algoReg2.LocalLength(100)
89 smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge")
90 print hypLen1.GetName()
91 print hypLen1.GetId()
92 print hypLen1.GetLength()
93 smesh.SetName(hypLen1, "Local_Length_100")
94
95 # ---- add hypothesis to face
96 print "-------------------------- add hypothesis to face"
97 face = salome.IDToObject(idface)
98
99 algoMef2 = mesh.Triangle(face)
100 hypArea2 = algoMef2.MaxElementArea(500)
101 smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace")
102 print hypArea2.GetName()
103 print hypArea2.GetId()
104 print hypArea2.GetMaxElementArea()
105 smesh.SetName(hypArea2, "MaxElementArea_500")
106
107
108 salome.sg.updateObjBrowser(1);