1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
30 from salome.geom import geomBuilder
31 geompy = geomBuilder.New(salome.myStudy)
33 import SMESH, SALOMEDS
34 from salome.smesh import smeshBuilder
35 smesh = smeshBuilder.New(salome.myStudy)
37 from salome.StdMeshers import StdMeshersBuilder
42 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
43 idbox = geompy.addToStudy(box, "box")
45 # ---- add faces of box to study
46 print "Add faces to study"
48 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
49 for f in subShapeList:
50 name = geompy.SubShapeName(f, box)
52 idface.append( geompy.addToStudyInFather(box, f, name) )
54 # ---- add edges of box to study
55 print "Add edges to study"
57 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
58 for f in subShapeList:
59 name = geompy.SubShapeName(f, box)
61 idedge.append( geompy.addToStudyInFather(box, f, name) )
63 salome.sg.updateObjBrowser(1);
66 smeshgui = salome.ImportComponentGUI("SMESH")
67 smeshgui.Init(salome.myStudyId)
68 smesh.SetCurrentStudy(salome.myStudy)
70 # ---- Creating meshes
72 box = salome.IDToObject(idbox)
73 names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ]
76 print "-------------------------- Create ", names[0], " mesh"
77 mesh = smesh.Mesh(box, names[0])
79 hyp = algo.NumberOfSegments(7)
81 smesh.SetName(hyp, "NumberOfSegmentsReg")
82 algo = mesh.Triangle()
83 algo.MaxElementArea(2500)
85 print "-------------------------- Create ", names[1], " mesh"
86 mesh = smesh.Mesh(box, names[1])
88 hyp = algo.NumberOfSegments(7)
91 smesh.SetName(hyp, "NumberOfSegmentsScale")
92 algo = mesh.Triangle()
93 algo.MaxElementArea(2500)
95 print "-------------------------- Create ", names[2], " mesh"
96 mesh = smesh.Mesh(box,names[2])
98 hyp = algo.NumberOfSegments(7)
100 hyp.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] )
101 hyp.SetConversionMode(0)
102 smesh.SetName(hyp, "NumberOfSegmentsTable")
103 algo = mesh.Triangle()
104 algo.MaxElementArea(2500)
106 print "-------------------------- Create ", names[3], " mesh"
107 mesh = smesh.Mesh(box, names[3])
108 algo = mesh.Segment()
109 hyp = algo.NumberOfSegments(10)
111 hyp.SetExpressionFunction("sin(3*t)")
112 hyp.SetConversionMode(1)
113 smesh.SetName(hyp, "NumberOfSegmentsExpr")
114 algo = mesh.Triangle()
115 algo.MaxElementArea(2500)
118 salome.sg.updateObjBrowser(1);