1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 # See http://www.salome-platform.org/
25 #-----------------------------GEOM----------------------------------------
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)
32 #----------Edges---------------
33 e1 = geompy.MakeEdge(p1,p2)
34 e2 = geompy.MakeEdge(p2,p3)
35 e3 = geompy.MakeEdge(p3,p1)
37 #----------Wire----------------
39 ListOfEdges.append(e3)
40 ListOfEdges.append(e2)
41 ListOfEdges.append(e1)
42 wire1 = geompy.MakeWire(ListOfEdges)
45 #----------Face----------------
47 face1 = geompy.MakeFace(wire1,WantPlanarFace)
49 Id_face1 = geompy.addToStudy(face1,"Face1")
53 #-----------------------------SMESH-------------------------------------------
54 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
57 plane_mesh = salome.IDToObject( Id_face1)
58 smesh.SetCurrentStudy(salome.myStudy)
60 mesh = smesh.CreateMesh(plane_mesh)
62 smeshgui = salome.ImportComponentGUI("SMESH")
63 smeshgui.Init(salome.myStudyId)
65 id_mesh = salome.ObjectToID(mesh)
66 smeshgui.SetName( id_mesh, "Mesh_1")
69 print"---------------------Hypothesis"
72 #---------------- NumberOfSegments
75 hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
76 hypNbSeg.SetNumberOfSegments( numberOfSegment )
78 print hypNbSeg.GetName()
79 print hypNbSeg.GetNumberOfSegments()
80 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "Nb. Segments")
83 #--------------------------Max. Element Area
86 hypArea200 = smesh.CreateHypothesis("MaxElementArea","libStdMeshersEngine.so")
87 hypArea200.SetMaxElementArea( maxElementArea )
88 print hypArea200.GetName()
89 print hypArea200.GetMaxElementArea()
91 smeshgui.SetName(salome.ObjectToID(hypArea200), "Max. Element Area")
93 print"---------------------Algorithms"
95 #----------------------------Wire discretisation
96 algoWireDes = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
97 listHyp = algoWireDes.GetCompatibleHypothesis()
99 print algoWireDes.GetName()
100 smeshgui.SetName(salome.ObjectToID(algoWireDes), "Ware descritisation")
102 #----------------------------Triangle (Mefisto)
103 algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
104 listHyp = algoMef.GetCompatibleHypothesis()
106 print algoMef.GetName()
108 #----------------------------Add hipothesis to the plane
109 mesh.AddHypothesis( plane_mesh, hypNbSeg ) # nb segments
110 mesh.AddHypothesis( plane_mesh, hypArea200 ) # max area
112 mesh.AddHypothesis( plane_mesh, algoWireDes ) # Regular 1D/wire discretisation
113 mesh.AddHypothesis( plane_mesh, algoMef ) # MEFISTO 2D
115 smeshgui.SetName(salome.ObjectToID(algoMef), "Triangle (Mefisto)")
117 print "---------------------Compute the mesh"
119 smesh.Compute(mesh, plane_mesh)
121 salome.sg.updateObjBrowser(1)