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