1 # Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 # File : SMESH_test1.py
30 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
31 smesh.SetCurrentStudy(salome.myStudy)
35 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
36 idbox = geompy.addToStudy(box, "box")
38 # ---- add first face of box in study
40 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
41 face = subShapeList[0]
42 name = geompy.SubShapeName(face, box)
44 idface = geompy.addToStudyInFather(box, face, name)
46 # ---- add shell from box in study
48 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
49 shell = subShellList[0]
50 name = geompy.SubShapeName(shell, box)
52 idshell = geompy.addToStudyInFather(box, shell, name)
54 # ---- add first edge of face in study
56 edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
58 name = geompy.SubShapeName(edge, face)
60 idedge = geompy.addToStudyInFather(face, edge, name)
64 smeshgui = salome.ImportComponentGUI("SMESH")
65 smeshgui.Init(salome.myStudyId)
67 print "-------------------------- create Hypothesis"
69 print "-------------------------- LocalLength"
70 hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
71 hypLen1.SetLength(100)
72 print hypLen1.GetName()
74 print hypLen1.GetLength()
76 idlength = salome.ObjectToID(hypLen1)
77 smeshgui.SetName(idlength, "Local_Length_100");
79 print "-------------------------- NumberOfSegments"
80 hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
81 hypNbSeg1.SetNumberOfSegments(7)
82 print hypNbSeg1.GetName()
83 print hypNbSeg1.GetId()
84 print hypNbSeg1.GetNumberOfSegments()
86 idseg = salome.ObjectToID(hypNbSeg1)
87 smeshgui.SetName(idseg, "NumberOfSegments_7");
89 print "-------------------------- MaxElementArea"
90 hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
91 hypArea1.SetMaxElementArea(2500)
92 print hypArea1.GetName()
93 print hypArea1.GetId()
94 print hypArea1.GetMaxElementArea()
96 idarea1 = salome.ObjectToID(hypArea1)
97 smeshgui.SetName(idarea1, "MaxElementArea_2500");
99 print "-------------------------- MaxElementArea"
100 hypArea2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
101 hypArea2.SetMaxElementArea(500)
102 print hypArea2.GetName()
103 print hypArea2.GetId()
104 print hypArea2.GetMaxElementArea()
106 idarea2 = salome.ObjectToID(hypArea2)
107 smeshgui.SetName(idarea2, "MaxElementArea_500");
109 print "-------------------------- Regular_1D"
110 algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
111 listHyp = algoReg.GetCompatibleHypothesis()
114 print algoReg.GetName()
115 print algoReg.GetId()
117 idreg = salome.ObjectToID(algoReg)
118 smeshgui.SetName(idreg, "Regular_1D");
120 print "-------------------------- MEFISTO_2D"
121 algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
122 listHyp = algoMef.GetCompatibleHypothesis()
125 print algoMef.GetName()
126 print algoMef.GetId()
128 idmef = salome.ObjectToID(algoMef)
129 smeshgui.SetName(idmef, "MEFISTO_2D");
131 # ---- Init a Mesh with the box
133 box = salome.IDToObject(idbox)
134 mesh = smesh.CreateMesh(box)
135 idmesh = salome.ObjectToID(mesh)
136 smeshgui.SetName(idmesh, "Meshbox");
138 print "-------------------------- add hypothesis to box"
139 mesh.AddHypothesis(box,algoReg)
140 mesh.AddHypothesis(box,hypNbSeg1)
141 mesh.AddHypothesis(box,algoMef)
142 mesh.AddHypothesis(box,hypArea1)
144 # ---- add hypothesis to edge
146 print "-------------------------- add hypothesis to edge"
147 edge = salome.IDToObject(idedge)
148 submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
149 mesh.AddHypothesis(edge, algoReg)
150 mesh.AddHypothesis(edge, hypLen1)
152 print "-------------------------- add hypothesis to face"
153 face = salome.IDToObject(idface)
154 submesh = mesh.GetSubMesh(face, "SubMeshFace")
155 mesh.AddHypothesis(face, hypArea2)
157 salome.sg.updateObjBrowser(1);