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