Salome HOME
ebf1347e2f0bdac414ec1ab8c9359cf5a14c02ec
[modules/smesh.git] / src / SMESH_SWIG / SMESH_test1.py
1 #! /usr/bin/python
2 #  -*- coding: iso-8859-1 -*-
3 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
5 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 #
8 #  This library is free software; you can redistribute it and/or
9 #  modify it under the terms of the GNU Lesser General Public
10 #  License as published by the Free Software Foundation; either
11 #  version 2.1 of the License.
12 #
13 #  This library is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 #  Lesser General Public License for more details.
17 #
18 #  You should have received a copy of the GNU Lesser General Public
19 #  License along with this library; if not, write to the Free Software
20 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21 #
22 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #
24 #  File   : SMESH_test1.py
25 #  Module : SMESH
26 #
27 import salome
28 import geompy
29 import smesh
30
31
32 # ---- define a box
33
34 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
35 idbox = geompy.addToStudy(box, "box")
36
37 # ---- add first face of box in study
38
39 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
40 face = subShapeList[0]
41 name = geompy.SubShapeName(face, box)
42 print name
43 idface = geompy.addToStudyInFather(box, face, name)
44
45 # ---- add shell from box  in study
46
47 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
48 shell = subShellList[0]
49 name = geompy.SubShapeName(shell, box)
50 print name
51 idshell = geompy.addToStudyInFather(box, shell, name)
52
53 # ---- add first edge of face in study
54
55 edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
56 edge = edgeList[0]
57 name = geompy.SubShapeName(edge, face)
58 print name
59 idedge = geompy.addToStudyInFather(face, edge, name)
60
61
62 # ---- SMESH
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);