Salome HOME
Movement of examples to CVS EXAMPLES SAMPLES_SRC.
[modules/smesh.git] / src / SMESH_SWIG / PAL_MESH_043_2D.py
1 #  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 #
20 #
21 #
22 #  File        : SMESH_testExtrusion2D.py
23 #  Module      : SMESH
24 #  Description : Create meshes to test extrusion of mesh elements along path
25
26 import salome
27 import geompy
28 import SMESH
29 import StdMeshers
30
31 #----------------------------------GEOM
32
33 # create points
34 p1 = geompy.MakeVertex(100, 0, 0)
35 p2 = geompy.MakeVertex(100, 0, 100)
36 p3 = geompy.MakeVertex(0, 0, 0)
37 p4 = geompy.MakeVertex(0, 100, 0)
38
39
40 # create two vectors
41 vector1 = geompy.MakeVector(p1,p2)
42 vector2 = geompy.MakeVector(p3,p4)
43
44 # make two ellipses
45 ellipse1 = geompy.MakeEllipse(p1,vector1,50,25)
46 ellipse2 = geompy.MakeEllipse(p3,vector2,300,50)
47
48 # publish circular face and second circle
49 id_ellipse1 = geompy.addToStudy(ellipse1, "Ellips 1")
50 id_ellipse2 = geompy.addToStudy(ellipse2, "Ellips 2")
51
52
53 #---------------------------------SMESH
54 # get smesh engine
55 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
56 smesh.SetCurrentStudy(salome.myStudy)
57
58 # get SMESH GUI
59 smeshgui = salome.ImportComponentGUI("SMESH")
60 smeshgui.Init(salome.myStudyId)
61
62 # create hypoteses
63 hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
64 hypNbSeg1.SetNumberOfSegments(18)
65 id_hypNbSeg1 = salome.ObjectToID(hypNbSeg1) 
66 smeshgui.SetName(id_hypNbSeg1, "NumberOfSegments 1");
67
68 hypNbSeg2 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
69 hypNbSeg2.SetNumberOfSegments(34)
70 id_hypNbSeg2 = salome.ObjectToID(hypNbSeg2) 
71 smeshgui.SetName(id_hypNbSeg2, "NumberOfSegments 2");
72
73 # create algorithmes
74 algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
75 id_algoReg = salome.ObjectToID(algoReg)
76 smeshgui.SetName(id_algoReg, "Regular_1D");
77
78 # create the path mesh
79 mesh1 = smesh.CreateMesh(ellipse1)
80 id_mesh1 = salome.ObjectToID(mesh1)
81 smeshgui.SetName(id_mesh1, "Path Mesh");
82
83 # set hypotheses and algos
84 mesh1.AddHypothesis(ellipse1,algoReg)
85 mesh1.AddHypothesis(ellipse1,hypNbSeg1)
86
87 # create the tool mesh
88 mesh2 = smesh.CreateMesh(ellipse2)
89 id_mesh2 = salome.ObjectToID(mesh2)
90 smeshgui.SetName(id_mesh2, "Tool Mesh");
91
92 # set hypotheses and algos
93 mesh2.AddHypothesis(ellipse2,algoReg)
94 mesh2.AddHypothesis(ellipse2,hypNbSeg2)
95
96 # compute meshes
97 smesh.Compute(mesh1,ellipse1)
98 smesh.Compute(mesh2,ellipse2)
99
100
101 # ---- udate object browser
102 salome.sg.updateObjBrowser(1);