Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESH_SWIG / PAL_MESH_041_mesh.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 import salome
23 import geompy
24 import smesh
25
26
27 #-----------------------------GEOM----------------------------------------
28
29 #----------Vertexes------------
30 p1 = geompy.MakeVertex(20.0,30.0,40.0)
31 p2 = geompy.MakeVertex(90.0,80.0,0.0)
32 p3 = geompy.MakeVertex(30.0,80.0,200.0)
33
34 #----------Edges---------------
35 e1 = geompy.MakeEdge(p1,p2)
36 e2 = geompy.MakeEdge(p2,p3)
37 e3 = geompy.MakeEdge(p3,p1)
38
39 #----------Wire----------------
40 ListOfEdges = []
41 ListOfEdges.append(e3)
42 ListOfEdges.append(e2)
43 ListOfEdges.append(e1)
44 wire1 = geompy.MakeWire(ListOfEdges)
45
46
47 #----------Face----------------
48 WantPlanarFace = 1
49 face1 = geompy.MakeFace(wire1,WantPlanarFace)
50
51 Id_face1 = geompy.addToStudy(face1,"Face1")
52
53
54
55 #-----------------------------SMESH-------------------------------------------
56
57
58 # -- Init mesh --
59 plane_mesh = salome.IDToObject( Id_face1)
60
61 mesh = smesh.Mesh(plane_mesh, "Mesh_1")
62
63 print"---------------------Hypothesis and Algorithms"
64
65 #---------------- NumberOfSegments
66
67 numberOfSegment = 9
68
69 algoWireDes = mesh.Segment()
70 listHyp = algoWireDes.GetCompatibleHypothesis()
71 print algoWireDes.GetName()
72 algoWireDes.SetName("Ware descritisation")
73
74 hypNbSeg = algoWireDes.NumberOfSegments(numberOfSegment)
75 print hypNbSeg.GetName()
76 print hypNbSeg.GetNumberOfSegments()
77 smesh.SetName(hypNbSeg, "Nb. Segments")
78
79
80 #--------------------------Max. Element Area
81 maxElementArea = 200
82
83 algoMef = mesh.Triangle()
84 listHyp = algoMef.GetCompatibleHypothesis()
85 print algoMef.GetName()
86 algoMef.SetName("Triangle (Mefisto)")
87
88 hypArea200 = algoMef.MaxElementArea(maxElementArea)
89 print hypArea200.GetName()
90 print hypArea200.GetMaxElementArea()
91 smesh.SetName(hypArea200, "Max. Element Area")
92
93
94 print "---------------------Compute the mesh"
95
96 ret = mesh.Compute()
97 print ret
98
99 salome.sg.updateObjBrowser(1)
100