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, 0.1, 0.5, 1.0, 1.0, 0.1] )
102 hypNbSeg3.SetConversionMode(0)
103 print hypNbSeg3.GetName()
104 print hypNbSeg3.GetId()
105 print hypNbSeg3.GetNumberOfSegments()
106 idseg3 = salome.ObjectToID(hypNbSeg3)
107 smeshgui.SetName(idseg3, "NumberOfSegmentsTable");
108 hypNbSeg.append(hypNbSeg3)
110 hypNbSeg4 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
111 hypNbSeg4.SetDistrType(3)
112 hypNbSeg4.SetNumberOfSegments(10)
113 hypNbSeg4.SetExpressionFunction("sin(3*t)")
114 hypNbSeg4.SetConversionMode(1)
115 print hypNbSeg4.GetName()
116 print hypNbSeg4.GetId()
117 print hypNbSeg4.GetNumberOfSegments()
118 idseg4 = salome.ObjectToID(hypNbSeg4)
119 smeshgui.SetName(idseg4, "NumberOfSegmentsExpr");
120 hypNbSeg.append(hypNbSeg4)
122 print "-------------------------- MaxElementArea"
123 hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
124 hypArea1.SetMaxElementArea(2500)
125 print hypArea1.GetName()
126 print hypArea1.GetId()
127 print hypArea1.GetMaxElementArea()
129 idarea1 = salome.ObjectToID(hypArea1)
130 smeshgui.SetName(idarea1, "MaxElementArea_2500");
132 print "-------------------------- MaxElementArea"
133 hypArea2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
134 hypArea2.SetMaxElementArea(500)
135 print hypArea2.GetName()
136 print hypArea2.GetId()
137 print hypArea2.GetMaxElementArea()
139 idarea2 = salome.ObjectToID(hypArea2)
140 smeshgui.SetName(idarea2, "MaxElementArea_500");
142 print "-------------------------- Regular_1D"
143 algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
144 listHyp = algoReg.GetCompatibleHypothesis()
147 print algoReg.GetName()
148 print algoReg.GetId()
150 idreg = salome.ObjectToID(algoReg)
151 smeshgui.SetName(idreg, "Regular_1D");
153 print "-------------------------- MEFISTO_2D"
154 algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
155 listHyp = algoMef.GetCompatibleHypothesis()
158 print algoMef.GetName()
159 print algoMef.GetId()
161 idmef = salome.ObjectToID(algoMef)
162 smeshgui.SetName(idmef, "MEFISTO_2D");
164 salome.sg.updateObjBrowser(1);
166 # ---- Init a Mesh with the box
168 box = salome.IDToObject(idbox)
169 names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ];
172 mesh = smesh.CreateMesh(box)
173 idmesh = salome.ObjectToID(mesh)
174 smeshgui.SetName(idmesh, names[j]);
175 print "-------------------------- add hypothesis to box"
176 mesh.AddHypothesis(box,algoReg)
177 mesh.AddHypothesis(box,hypNbSeg[j])
178 mesh.AddHypothesis(box,algoMef)
179 mesh.AddHypothesis(box,hypArea1)
182 salome.sg.updateObjBrowser(1);