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
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 faces of box to study
39 print "Add faces to study"
41 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
42 for f in subShapeList:
43 name = geompy.SubShapeName(f, box)
45 idface.append( geompy.addToStudyInFather(box, f, name) )
47 # ---- add edges of box to study
48 print "Add edges to study"
50 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
51 for f in subShapeList:
52 name = geompy.SubShapeName(f, box)
54 idedge.append( geompy.addToStudyInFather(box, f, name) )
56 salome.sg.updateObjBrowser(1);
59 smeshgui = salome.ImportComponentGUI("SMESH")
60 smeshgui.Init(salome.myStudyId)
63 print "-------------------------- create Hypothesis"
65 print "-------------------------- LocalLength"
66 hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
67 hypLen1.SetLength(100)
68 print hypLen1.GetName()
70 print hypLen1.GetLength()
72 idlength = salome.ObjectToID(hypLen1)
73 smeshgui.SetName(idlength, "Local_Length_100");
76 print "-------------------------- NumberOfSegments"
77 hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
78 hypNbSeg1.SetDistrType(0)
79 hypNbSeg1.SetNumberOfSegments(7)
80 print hypNbSeg1.GetName()
81 print hypNbSeg1.GetId()
82 print hypNbSeg1.GetNumberOfSegments()
83 idseg1 = salome.ObjectToID(hypNbSeg1)
84 smeshgui.SetName(idseg1, "NumberOfSegmentsReg");
85 hypNbSeg.append(hypNbSeg1)
87 hypNbSeg2 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
88 hypNbSeg2.SetDistrType(1)
89 hypNbSeg2.SetNumberOfSegments(7)
90 hypNbSeg2.SetScaleFactor(2)
91 print hypNbSeg2.GetName()
92 print hypNbSeg2.GetId()
93 print hypNbSeg2.GetNumberOfSegments()
94 idseg2 = salome.ObjectToID(hypNbSeg2)
95 smeshgui.SetName(idseg2, "NumberOfSegmentsScale");
96 hypNbSeg.append(hypNbSeg2)
98 hypNbSeg3 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
99 hypNbSeg3.SetDistrType(2)
100 hypNbSeg3.SetNumberOfSegments(7)
101 hypNbSeg3.SetTableFunction( [0.25, 0.5, 0.5, 0.25] )
102 print hypNbSeg3.GetName()
103 print hypNbSeg3.GetId()
104 print hypNbSeg3.GetNumberOfSegments()
105 idseg3 = salome.ObjectToID(hypNbSeg3)
106 smeshgui.SetName(idseg3, "NumberOfSegmentsTable");
107 hypNbSeg.append(hypNbSeg3)
109 hypNbSeg4 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
110 hypNbSeg4.SetDistrType(3)
111 hypNbSeg4.SetNumberOfSegments(7)
112 hypNbSeg4.SetExpressionFunction("sin(t)")
113 print hypNbSeg4.GetName()
114 print hypNbSeg4.GetId()
115 print hypNbSeg4.GetNumberOfSegments()
116 idseg4 = salome.ObjectToID(hypNbSeg4)
117 smeshgui.SetName(idseg4, "NumberOfSegmentsExpr");
118 hypNbSeg.append(hypNbSeg4)
120 print "-------------------------- MaxElementArea"
121 hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
122 hypArea1.SetMaxElementArea(2500)
123 print hypArea1.GetName()
124 print hypArea1.GetId()
125 print hypArea1.GetMaxElementArea()
127 idarea1 = salome.ObjectToID(hypArea1)
128 smeshgui.SetName(idarea1, "MaxElementArea_2500");
130 print "-------------------------- MaxElementArea"
131 hypArea2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
132 hypArea2.SetMaxElementArea(500)
133 print hypArea2.GetName()
134 print hypArea2.GetId()
135 print hypArea2.GetMaxElementArea()
137 idarea2 = salome.ObjectToID(hypArea2)
138 smeshgui.SetName(idarea2, "MaxElementArea_500");
140 print "-------------------------- Regular_1D"
141 algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
142 listHyp = algoReg.GetCompatibleHypothesis()
145 print algoReg.GetName()
146 print algoReg.GetId()
148 idreg = salome.ObjectToID(algoReg)
149 smeshgui.SetName(idreg, "Regular_1D");
151 print "-------------------------- MEFISTO_2D"
152 algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
153 listHyp = algoMef.GetCompatibleHypothesis()
156 print algoMef.GetName()
157 print algoMef.GetId()
159 idmef = salome.ObjectToID(algoMef)
160 smeshgui.SetName(idmef, "MEFISTO_2D");
162 salome.sg.updateObjBrowser(1);
164 # ---- Init a Mesh with the box
166 box = salome.IDToObject(idbox)
167 names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ];
170 mesh = smesh.CreateMesh(box)
171 idmesh = salome.ObjectToID(mesh)
172 smeshgui.SetName(idmesh, names[j]);
173 print "-------------------------- add hypothesis to box"
174 mesh.AddHypothesis(box,algoReg)
175 mesh.AddHypothesis(box,hypNbSeg[j])
176 mesh.AddHypothesis(box,algoMef)
177 mesh.AddHypothesis(box,hypArea1)
180 salome.sg.updateObjBrowser(1);