Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/smesh.git] / src / SMESH_SWIG / PAL_MESH_041_mesh.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 import geompy
21 import salome
22
23 import StdMeshers
24
25 #-----------------------------GEOM----------------------------------------
26
27 #----------Vertexes------------
28 p1 = geompy.MakeVertex(20.0,30.0,40.0)
29 p2 = geompy.MakeVertex(90.0,80.0,0.0)
30 p3 = geompy.MakeVertex(30.0,80.0,200.0)
31
32 #----------Edges---------------
33 e1 = geompy.MakeEdge(p1,p2)
34 e2 = geompy.MakeEdge(p2,p3)
35 e3 = geompy.MakeEdge(p3,p1)
36
37 #----------Wire----------------
38 ListOfEdges = []
39 ListOfEdges.append(e3)
40 ListOfEdges.append(e2)
41 ListOfEdges.append(e1)
42 wire1 = geompy.MakeWire(ListOfEdges)
43
44
45 #----------Face----------------
46 WantPlanarFace = 1
47 face1 = geompy.MakeFace(wire1,WantPlanarFace)
48
49 Id_face1 = geompy.addToStudy(face1,"Face1")
50
51
52
53 #-----------------------------SMESH-------------------------------------------
54 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
55
56 # -- Init --
57 plane_mesh = salome.IDToObject( Id_face1)
58 smesh.SetCurrentStudy(salome.myStudy)
59
60 mesh = smesh.CreateMesh(plane_mesh)
61
62 smeshgui = salome.ImportComponentGUI("SMESH")
63 smeshgui.Init(salome.myStudyId)
64
65 id_mesh = salome.ObjectToID(mesh)
66 smeshgui.SetName( id_mesh, "Mesh_1")
67
68
69 print"---------------------Hypothesis"
70
71
72 #---------------- NumberOfSegments
73 numberOfSegment = 9
74
75 hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
76 hypNbSeg.SetNumberOfSegments( numberOfSegment )
77
78 print hypNbSeg.GetName()
79 print hypNbSeg.GetNumberOfSegments()
80 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "Nb. Segments")
81
82
83 #--------------------------Max. Element Area
84 maxElementArea = 200
85
86 hypArea200 = smesh.CreateHypothesis("MaxElementArea","libStdMeshersEngine.so")
87 hypArea200.SetMaxElementArea( maxElementArea )
88 print hypArea200.GetName()
89 print hypArea200.GetMaxElementArea()
90
91 smeshgui.SetName(salome.ObjectToID(hypArea200), "Max. Element Area")
92
93 print"---------------------Algorithms"
94
95 #----------------------------Wire discretisation
96 algoWireDes = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
97 listHyp = algoWireDes.GetCompatibleHypothesis()
98
99 print algoWireDes.GetName()
100 smeshgui.SetName(salome.ObjectToID(algoWireDes), "Ware descritisation")
101
102 #----------------------------Triangle (Mefisto)
103 algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
104 listHyp = algoMef.GetCompatibleHypothesis()
105
106 print algoMef.GetName()
107
108 #----------------------------Add hipothesis to the plane
109 mesh.AddHypothesis( plane_mesh, hypNbSeg )     # nb segments
110 mesh.AddHypothesis( plane_mesh, hypArea200 )   # max area
111
112 mesh.AddHypothesis( plane_mesh, algoWireDes )  # Regular 1D/wire discretisation
113 mesh.AddHypothesis( plane_mesh, algoMef )      # MEFISTO 2D
114
115 smeshgui.SetName(salome.ObjectToID(algoMef), "Triangle (Mefisto)")
116
117 print "---------------------Compute the mesh"
118
119 smesh.Compute(mesh, plane_mesh)
120
121 salome.sg.updateObjBrowser(1)
122