Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/smesh.git] / src / SMESH_SWIG / SMESH_box.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 #
4 #  This library is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU Lesser General Public
6 #  License as published by the Free Software Foundation; either
7 #  version 2.1 of the License.
8 #
9 #  This library is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 #  Lesser General Public License for more details.
13 #
14 #  You should have received a copy of the GNU Lesser General Public
15 #  License along with this library; if not, write to the Free Software
16 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 #==============================================================================
21 #  Info.
22 #  Bug (from script, bug)   : box.py, PAL5223
23 #  Modified                 : 25/11/2004
24 #  Author                   : Kovaltchuk Alexey
25 #  Project                  : PAL/SALOME
26 #==============================================================================
27 #
28 # Salome geometry and meshing for a box
29 #
30 import salome
31 from salome import sg
32 import geompy
33
34 import StdMeshers
35
36 # ---- launch GEOM
37
38 geom          = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
39 meshgenerator = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
40
41 ###geom.GetCurrentStudy(salome.myStudy._get_StudyId())
42 meshgenerator.SetCurrentStudy(salome.myStudy)
43
44 # Plate
45
46 box    = geompy.MakeBox(0.,0.,0.,1.,1.,1.)
47 boxId  = geompy.addToStudy(box,"box")
48
49 # ---- launch SMESH
50
51 smeshgui = salome.ImportComponentGUI("SMESH")
52 smeshgui.Init(salome.myStudyId)
53 # meshgenerator=smeshpy.smeshpy()
54
55
56 # Hypothesis
57
58 hypL1=meshgenerator.CreateHypothesis("LocalLength","libStdMeshersEngine.so")
59 hypL1.SetLength(0.25)
60 hypL1Id = salome.ObjectToID(hypL1) 
61 smeshgui.SetName(hypL1Id, "LocalLength")
62
63 # Algorithm
64
65 alg1D=meshgenerator.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
66 alg1DId = salome.ObjectToID(alg1D) 
67 smeshgui.SetName(alg1DId, "algo1D")
68
69 alg2D=meshgenerator.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
70 alg2DId = salome.ObjectToID(alg2D) 
71 smeshgui.SetName(alg2DId, "algo2D")
72
73 alg3D=meshgenerator.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
74 alg3DId = salome.ObjectToID(alg3D) 
75 smeshgui.SetName(alg3DId, "algo3D")
76  
77 # ---- init a Mesh
78
79 box_mesh=meshgenerator.CreateMesh(box)
80 box_meshId = salome.ObjectToID(box_mesh)
81 smeshgui.SetName(box_meshId, "box_mesh")
82
83 # ---- set Hypothesis & Algorithm
84
85 box_mesh.AddHypothesis(box,alg1D)
86 box_mesh.AddHypothesis(box,alg2D)
87 box_mesh.AddHypothesis(box,alg3D)
88 box_mesh.AddHypothesis(box,hypL1)
89
90 meshgenerator.Compute(box_mesh,box)
91
92 sg.updateObjBrowser(1)