Salome HOME
Fix bug 12796: Warning missed for the bad file 'test18.med'
[modules/smesh.git] / src / SMESH_SWIG / SMESH_reg.py
1 #  Copyright (C) 2003  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 #
21 #
22 #  File   : SMESH_reg.py
23 #  Module : SMESH
24
25 import salome
26 import geompy
27
28 import StdMeshers
29
30 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
31 smesh.SetCurrentStudy(salome.myStudy)
32
33 # ---- define a box
34 print "Define box"
35 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
36 idbox = geompy.addToStudy(box, "box")
37
38 # ---- add faces of box to study
39 print "Add faces to study"
40 idface = []
41 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
42 for f in subShapeList:
43   name = geompy.SubShapeName(f, box)
44   print name
45   idface.append( geompy.addToStudyInFather(box, f, name) )
46
47 # ---- add edges of box to study
48 print "Add edges to study"
49 idedge = []
50 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
51 for f in subShapeList:
52   name = geompy.SubShapeName(f, box)
53   print name
54   idedge.append( geompy.addToStudyInFather(box, f, name) )
55
56 salome.sg.updateObjBrowser(1);
57
58 # ---- launch SMESH
59 smeshgui = salome.ImportComponentGUI("SMESH")
60 smeshgui.Init(salome.myStudyId)
61
62
63 print "-------------------------- create Hypothesis"
64
65 print "-------------------------- LocalLength"
66 hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
67 hypLen1.SetLength(100)
68 print hypLen1.GetName()
69 print hypLen1.GetId()
70 print hypLen1.GetLength()
71
72 idlength = salome.ObjectToID(hypLen1)
73 smeshgui.SetName(idlength, "Local_Length_100");
74
75 hypNbSeg = []
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)
86
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)
97
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)
109
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)
121
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()
128
129 idarea1 = salome.ObjectToID(hypArea1)
130 smeshgui.SetName(idarea1, "MaxElementArea_2500");
131
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()
138
139 idarea2 = salome.ObjectToID(hypArea2)
140 smeshgui.SetName(idarea2, "MaxElementArea_500");
141
142 print "-------------------------- Regular_1D"
143 algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
144 listHyp = algoReg.GetCompatibleHypothesis()
145 for hyp in listHyp:
146     print hyp
147 print algoReg.GetName()
148 print algoReg.GetId()
149
150 idreg = salome.ObjectToID(algoReg)
151 smeshgui.SetName(idreg, "Regular_1D");
152
153 print "-------------------------- MEFISTO_2D"
154 algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
155 listHyp = algoMef.GetCompatibleHypothesis()
156 for hyp in listHyp:
157     print hyp
158 print algoMef.GetName()
159 print algoMef.GetId()
160
161 idmef = salome.ObjectToID(algoMef)
162 smeshgui.SetName(idmef, "MEFISTO_2D");
163
164 salome.sg.updateObjBrowser(1);
165
166 # ---- Init a Mesh with the box
167
168 box = salome.IDToObject(idbox)
169 names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ];
170 j = 0
171 for i in range(4):
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)
180   j=j+1
181
182 salome.sg.updateObjBrowser(1);
183