Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESH_SWIG / SMESH_reg.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_reg.py
24 #  Module : SMESH
25 #
26 import salome
27 import geompy
28 import smesh
29
30 import StdMeshers
31
32
33 # ---- define a box
34 print "Define box"
35 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
36 idbox = geompy.addToStudy(box, "box")
37
38 # ---- add faces of box to study
39 print "Add faces to study"
40 idface = []
41 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
42 for f in subShapeList:
43   name = geompy.SubShapeName(f, box)
44   print name
45   idface.append( geompy.addToStudyInFather(box, f, name) )
46
47 # ---- add edges of box to study
48 print "Add edges to study"
49 idedge = []
50 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
51 for f in subShapeList:
52   name = geompy.SubShapeName(f, box)
53   print name
54   idedge.append( geompy.addToStudyInFather(box, f, name) )
55
56 salome.sg.updateObjBrowser(1);
57
58 # ---- launch SMESH
59 smeshgui = salome.ImportComponentGUI("SMESH")
60 smeshgui.Init(salome.myStudyId)
61
62
63 # ---- Creating meshes
64
65 box = salome.IDToObject(idbox)
66 names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ]
67
68
69 print "-------------------------- Create ", names[0], " mesh"
70 mesh = smesh.Mesh(box, names[0])
71 algo = mesh.Segment()
72 hyp = algo.NumberOfSegments(7)
73 hyp.SetDistrType(0)
74 smesh.SetName(hyp, "NumberOfSegmentsReg")
75 algo = mesh.Triangle()
76 algo.MaxElementArea(2500)
77
78 print "-------------------------- Create ", names[1], " mesh"
79 mesh = smesh.Mesh(box, names[1])
80 algo = mesh.Segment()
81 hyp = algo.NumberOfSegments(7)
82 hyp.SetDistrType(1)
83 hyp.SetScaleFactor(2)
84 smesh.SetName(hyp, "NumberOfSegmentsScale")
85 algo = mesh.Triangle()
86 algo.MaxElementArea(2500)
87
88 print "-------------------------- Create ", names[2], " mesh"
89 mesh = smesh.Mesh(box,names[2])
90 algo = mesh.Segment()
91 hyp = algo.NumberOfSegments(7)
92 hyp.SetDistrType(2)
93 hyp.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] )
94 hyp.SetConversionMode(0)
95 smesh.SetName(hyp, "NumberOfSegmentsTable")
96 algo = mesh.Triangle()
97 algo.MaxElementArea(2500)
98
99 print "-------------------------- Create ", names[3], " mesh"
100 mesh = smesh.Mesh(box, names[3])
101 algo = mesh.Segment()
102 hyp = algo.NumberOfSegments(10)
103 hyp.SetDistrType(3)
104 hyp.SetExpressionFunction("sin(3*t)")
105 hyp.SetConversionMode(1)
106 smesh.SetName(hyp, "NumberOfSegmentsExpr")
107 algo = mesh.Triangle()
108 algo.MaxElementArea(2500)
109
110
111 salome.sg.updateObjBrowser(1);
112