Salome HOME
Merge with version on tag OCC-V2_1_0d
[modules/geom.git] / src / GEOM_SWIG / GEOM_Spanner.py
1 #  GEOM GEOM_SWIG : binding of C++ implementaion with Python
2 #
3 #  Copyright (C) 2003  CEA
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU Lesser General Public
7 #  License as published by the Free Software Foundation; either
8 #  version 2.1 of the License.
9 #
10 #  This library is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public
16 #  License along with this library; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 #  See http://www.salome-platform.org or email : webmaster.salome@opencascade.org
20 #
21 #
22 #
23 #  File   : GEOM_Spanner.py
24 #  Author : Julia DOROVSKIKH
25 #  Module : GEOM
26 #  $Header$
27
28 def GetFaceNearPoint (geompy, block, pnt):
29   anObj = geompy.BlocksOp.GetFaceNearPoint(block, pnt)
30   if anObj is None:
31     print "GetFaceNearPoint : ", geompy.BlocksOp.GetErrorCode()
32   return anObj
33
34 def GetOppositeFace (geompy, block, face):
35   anObj = geompy.BlocksOp.GetOppositeFace(block, face)
36   if anObj is None:
37     print "GetOppositeFace : ", geompy.BlocksOp.GetErrorCode()
38   return anObj
39
40 def GetFaceByNormale (geompy, block, vec):
41   anObj = geompy.BlocksOp.GetFaceByNormale(block, vec)
42   if anObj is None:
43     print "GetFaceByNormale : ", geompy.BlocksOp.GetErrorCode()
44   return anObj
45
46 def GetBlockNearPoint (geompy, comp, pnt):
47   anObj = geompy.BlocksOp.GetBlockNearPoint(comp, pnt)
48   if anObj is None:
49     print "GetBlockNearPoint : ", geompy.BlocksOp.GetErrorCode()
50   return anObj
51
52 ############# MakeSpanner #############
53
54 def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None, hasGUI = 0):
55
56   ### Variables ###
57
58   th = 4.0
59
60   ### BlocksOp ###
61
62   BlocksOp = geompy.BlocksOp
63
64   ### Basic points and directions ###
65
66   p0  = geompy.MakeVertex(0., 0., 0.)
67   pth = geompy.MakeVertex(0., 0., th)
68
69   vx = geompy.MakeVectorDXDYDZ(1., 0., 0.)
70   vy = geompy.MakeVectorDXDYDZ(0., 1., 0.)
71   vz = geompy.MakeVectorDXDYDZ(0., 0., 1.)
72
73   vxy = geompy.MakeVectorDXDYDZ(1., 1., 0.)
74
75   ### Block 1 ###
76
77   p_10_0  = geompy.MakeVertex(10.,  0., 0.)
78   p_10_25 = geompy.MakeVertex(10., 25., 0.)
79   p_0_35  = geompy.MakeVertex( 0., 35., 0.)
80   p_0_10  = geompy.MakeVertex( 0., 10., 0.)
81
82   Face11 = geompy.MakeQuad4Vertices(p_10_0, p_10_25, p_0_10, p_0_35);
83   id_face11 = geompy.addToStudy(Face11, "1 Face for Block 1")
84
85   Face12 = geompy.MakeTranslationTwoPoints(Face11, p0, pth)
86   id_face12 = geompy.addToStudy(Face12, "2 Face for Block 1")
87
88   Block1 = geompy.MakeHexa2Faces(Face11, Face12)
89   id_block1 = geompy.addToStudy(Block1, "Block 1")
90
91   ### Block 2 ###
92
93   p_15_0  = geompy.MakeVertex(15.,  0., 0.)
94   p_15_20 = geompy.MakeVertex(15., 20., 0.)
95
96   Edge21 = geompy.MakeEdge(p_15_0, p_15_20)
97   id_edge21 = geompy.addToStudy(Edge21, "1 Edge for Block 2")
98
99   Edge22 = BlocksOp.GetEdge(Block1, p_10_0, p_10_25)
100   if Edge22 is None:
101     print "BlocksOp.GetEdge(Block1, p_10_0, p_10_25) : ", BlocksOp.GetErrorCode()
102   id_edge22 = geompy.addToStudy(Edge22, "2 Edge for Block 2")
103
104   Face21 = geompy.MakeQuad2Edges(Edge21, Edge22);
105   id_face21 = geompy.addToStudy(Face21, "1 Face for Block 2")
106
107   Face22 = geompy.MakeTranslationTwoPoints(Face21, p0, pth)
108   id_face22 = geompy.addToStudy(Face22, "2 Face for Block 2")
109
110   Block2 = geompy.MakeHexa2Faces(Face21, Face22)
111   id_block2 = geompy.addToStudy(Block2, "Block 2")
112
113   ### Block 3 ###
114
115   p_15_10_1 = geompy.MakeVertex(15., 10., 1.)
116
117   Face31 = GetFaceNearPoint(geompy, Block2, p_15_10_1)
118   id_face31 = geompy.addToStudy(Face31, "1 Face for Block 3")
119
120   Prism1 = geompy.MakePrismVecH(Face31, vx, 5);
121   id_prism1 = geompy.addToStudy(Prism1, "Prism to be Block 3")
122
123   nbFaces = geompy.ShapesOp.NumberOfFaces(Prism1)
124   if nbFaces == 6:
125     print "Prism 1 is a hexahedral solid"
126   else:
127     print "Prism 1 is not a hexahedral solid"
128
129   Prism1_faces = geompy.SubShapeAllSorted(Prism1, geompy.ShapeType["FACE"])
130   ii = 1
131   for aFace in  Prism1_faces:
132     name = geompy.SubShapeName(aFace, Prism1)
133     Id_Face = geompy.addToStudyInFather(Prism1, aFace, name)
134     ii = ii + 1
135
136   Block3 = geompy.MakeHexa(Prism1_faces[0], Prism1_faces[1],
137                            Prism1_faces[2], Prism1_faces[3],
138                            Prism1_faces[4], Prism1_faces[5]);
139   id_block3 = geompy.addToStudy(Block3, "Block 3")
140
141   ### Block 4 ###
142
143   Face41 = GetOppositeFace(geompy, Block3, Face31)
144   id_face41 = geompy.addToStudy(Face41, "1 Face for Block 4")
145
146   p_25_5  = geompy.MakeVertex(25.,  5., 0.)
147   p_25_20 = geompy.MakeVertex(25., 20., 0.)
148
149   Edge41 = geompy.MakeEdge(p_25_5, p_25_20)
150   id_edge41 = geompy.addToStudy(Edge41, "1 Edge for Block 4")
151
152   p_25_5_2  = geompy.MakeVertex(25.,  5., th)
153   p_25_20_2 = geompy.MakeVertex(25., 20., th)
154
155   Edge42 = geompy.MakeEdge(p_25_5_2, p_25_20_2)
156   id_edge42 = geompy.addToStudy(Edge42, "2 Edge for Block 4")
157
158   Edge43 = geompy.MakeEdge(p_25_5, p_25_5_2)
159   id_edge43 = geompy.addToStudy(Edge43, "3 Edge for Block 4")
160
161   Edge44 = geompy.MakeEdge(p_25_20, p_25_20_2)
162   id_edge44 = geompy.addToStudy(Edge44, "4 Edge for Block 4")
163
164   Face42 = geompy.MakeQuad(Edge41, Edge42, Edge43, Edge44)
165   id_face42 = geompy.addToStudy(Face42, "2 Face for Block 4")
166
167   Block4 = geompy.MakeHexa2Faces(Face41, Face42)
168   id_block4 = geompy.addToStudy(Block4, "Block 4")
169
170   ### Block 5 ###
171
172   p_25_30   = geompy.MakeVertex(25., 30., 0.)
173   p_25_30_1 = geompy.MakeVertex(25., 30., 1)
174   axis_rot = geompy.MakeVector(p_25_30, p_25_30_1)
175
176   Face51 = Face42
177   Face52 = geompy.MakeRotation(Face51, axis_rot, math.pi/2.)
178   id_face52 = geompy.addToStudy(Face52, "2 Face for Block 5")
179
180   Block5 = geompy.MakeHexa2Faces(Face51, Face52)
181   id_block5 = geompy.addToStudy(Block5, "Block 5")
182
183   ### Compound of blocks 1 - 4 ###
184
185   Comp1234 = geompy.MakeCompound([Block1, Block2, Block3, Block4])
186   Glue1234 = geompy.MakeGlueFaces(Comp1234, 1e-5)
187   id_glue1234 = geompy.addToStudy(Glue1234, "Glue 1234")
188
189   plane_mirror = geompy.MakePlane(p_25_30, vxy, 100.)
190   #id_plane_mirror = geompy.addToStudy(plane_mirror, "Plane for mirror")
191
192   Mirror1 = geompy.MakeMirrorByPlane(Glue1234, plane_mirror)
193   id_mirror1 = geompy.addToStudy(Mirror1, "Mirror 1")
194
195   ### The second end ###
196
197   p_18_0 = geompy.MakeVertex(18., 0., 0.)
198   p_20_0 = geompy.MakeVertex(20., 0., 0.)
199   p_40_0 = geompy.MakeVertex(40., 0., 0.)
200
201   Edge1s = geompy.MakeEdge(p_20_0, p_40_0)
202   id_edge1s = geompy.addToStudy(Edge1s, "1 Edge for Block 1s")
203
204   Edge2s = geompy.MakeRotation(Edge1s, vz, math.pi/12.)
205   id_edge2s = geompy.addToStudy(Edge2s, "2 Edge for Block 1s")
206
207   p_18_0_r = geompy.MakeRotation(p_18_0, vz, math.pi/24.)
208   p_20_0_r = geompy.MakeRotation(p_20_0, vz, math.pi/12.)
209   p_40_0_r = geompy.MakeRotation(p_40_0, vz, math.pi/12.)
210
211   Edge3s = geompy.MakeEdge(p_40_0, p_40_0_r)
212   id_edge3s = geompy.addToStudy(Edge3s, "3 Edge for Block 1s")
213
214   Edge4s = geompy.MakeArc(p_20_0, p_18_0_r, p_20_0_r)
215   id_edge4s = geompy.addToStudy(Edge4s, "4 Edge for Block 1s")
216
217   Face1s = geompy.MakeQuad(Edge1s, Edge2s, Edge3s, Edge4s)
218   id_face1s = geompy.addToStudy(Face1s, "1 Face for Block 1s")
219
220   Block1s = geompy.MakePrismVecH(Face1s, vz, th);
221   id_block1s = geompy.addToStudy(Block1s, "Block 1s")
222
223   p_30_0_1 = geompy.MakeVertex(30., 0., 1.)
224
225   Face2s = GetFaceNearPoint(geompy, Block1s, p_30_0_1)
226   id_face2s = geompy.addToStudy(Face2s, "2 Face of Block 1s")
227
228   f2s_ind = geompy.LocalOp.GetSubShapeIndex(Block1s, Face2s)
229
230   Block1s_tr1 = geompy.MakeMultiTransformation1D(Block1s, f2s_ind, 0, 24)
231   id_block1s_tr1 = geompy.addToStudy(Block1s_tr1, "Multi-transformed Block 1s")
232
233   p_60_150_0 = geompy.MakeVertex(60., -150., 0.)
234   Gear = geompy.MakeTranslationTwoPoints(Block1s_tr1, p0, p_60_150_0)
235   id_gear = geompy.addToStudy(Gear, "Gear")
236
237   ### Link two parts ###
238
239   ### Linking Block 1 ###
240
241   p_55_0_1 = geompy.MakeVertex(55., 0., 1.)
242   p_55_110_1 = geompy.MakeVertex(55., -110., 1.)
243
244   Face11l = GetFaceNearPoint(geompy, Block5, p_55_0_1)
245   id_face11l = geompy.addToStudy(Face11l, "1 Face for Linking Block 1")
246
247   Face12l = GetFaceNearPoint(geompy, Gear, p_55_110_1)
248   id_face12l = geompy.addToStudy(Face12l, "2 Face for Linking Block 1")
249
250   Block1l = geompy.MakeHexa2Faces(Face11l, Face12l)
251   id_block1l = geompy.addToStudy(Block1l, "Linking Block 1")
252
253   ### Linking Block 2 ###
254
255   p_25_0_1 = geompy.MakeVertex(25., 0., 1.)
256   p_45_110_1 = geompy.MakeVertex(45., -110., 1.)
257
258   Face21l = GetFaceNearPoint(geompy, Block4, p_25_0_1)
259   id_face21l = geompy.addToStudy(Face21l, "1 Face for Linking Block 2")
260
261   Face22l = GetFaceNearPoint(geompy, Gear, p_45_110_1)
262   id_face22l = geompy.addToStudy(Face22l, "2 Face for Linking Block 2")
263
264   Block2l = geompy.MakeHexa2Faces(Face21l, Face22l)
265   id_block2l = geompy.addToStudy(Block2l, "Linking Block 2")
266
267   ### Linking Block 3 ###
268
269   p_55_30_1 = geompy.MakeVertex(55., 30., 1.)
270   p_65_110_1 = geompy.MakeVertex(65., -110., 1.)
271
272   Face31l = GetFaceNearPoint(geompy, Mirror1, p_55_30_1)
273   id_face31l = geompy.addToStudy(Face31l, "1 Face for Linking Block 3")
274
275   Face32l = GetFaceNearPoint(geompy, Gear, p_65_110_1)
276   id_face32l = geompy.addToStudy(Face32l, "2 Face for Linking Block 3")
277
278   Block3l = geompy.MakeHexa2Faces(Face31l, Face32l)
279   id_block3l = geompy.addToStudy(Block3l, "Linking Block 3")
280
281   ### Handle ###
282
283   CompLB = geompy.MakeCompound([Block1l, Block2l, Block3l])
284   Handle = geompy.MakeGlueFaces(CompLB, 1e-5)
285   id_handle = geompy.addToStudy(Handle, "Handle")
286
287   Block1h = GetBlockNearPoint(geompy, Handle, p_45_110_1)
288   id_block1h = geompy.addToStudyInFather(Handle, Block1h, "Block 1 of Handle")
289
290   Block2h = GetBlockNearPoint(geompy, Handle, p_65_110_1)
291   id_block2h = geompy.addToStudyInFather(Handle, Block2h, "Block 2 of Handle")
292
293   Face11h = GetFaceByNormale(geompy, Block1h, vx)
294   id_face11h = geompy.addToStudyInFather(Block1h, Face11h, "Face 1")
295
296   Face12h = GetOppositeFace(geompy, Block1h, Face11h)
297   id_face12h = geompy.addToStudyInFather(Block1h, Face12h, "Face 2")
298
299   Face21h = GetFaceByNormale(geompy, Block2h, vx)
300   id_face21h = geompy.addToStudyInFather(Block2h, Face21h, "Face 1")
301
302   Face22h = GetOppositeFace(geompy, Block2h, Face21h)
303   id_face22h = geompy.addToStudyInFather(Block2h, Face22h, "Face 2")
304
305   Block3h = BlocksOp.GetBlockByParts(Handle, [Face11h, Face21h])
306   if BlocksOp.IsDone() == 0:
307     Block3h = BlocksOp.GetBlockByParts(Handle, [Face11h, Face22h])
308     if BlocksOp.IsDone() == 0:
309         Block3h = BlocksOp.GetBlockByParts(Handle, [Face12h, Face21h])
310         if BlocksOp.IsDone() == 0:
311             Block3h = BlocksOp.GetBlockByParts(Handle, [Face12h, Face22h])
312   if BlocksOp.IsDone() == 0:
313     print "ERROR: BlocksOp.GetBlockByParts() failed : ", BlocksOp.GetErrorCode()
314   else:
315     id_block3h = geompy.addToStudyInFather(Handle, Block3h, "Block 3 of Handle")
316
317   ### The whole shape ###
318
319   CompALL = geompy.MakeCompound([Glue1234, Block5, Mirror1, Handle, Gear])
320   Spanner = geompy.MakeGlueFaces(CompALL, 1e-5)
321   id_glueALL = geompy.addToStudy(Spanner, "The Spanner")
322
323   ### Check the Spanner ###
324
325   isCompOfBlocks6 = BlocksOp.IsCompoundOfBlocks(Spanner, 6, 6)
326   if isCompOfBlocks6 == 0:
327     print "Spanner is not a compound of hexahedral solids"
328   else:
329     print "Spanner is a compound of hexahedral solids"
330
331   if isBlocksTest == 1:
332
333     print "##################### Test More #####################"
334
335     ### Get Blocks 4 and 5 from the spanner ###
336
337     Face42_sp = BlocksOp.GetFaceByEdges(Spanner, Edge41, Edge42)
338     if Face42_sp is None:
339       print "BlocksOp.GetFaceByEdges(Spanner, Edge41, Edge42) : ", BlocksOp.GetErrorCode()
340     id_face42_sp = geompy.addToStudyInFather(Spanner, Face42_sp, "Face 4_2")
341
342     Blocks_f4_sp = BlocksOp.GetBlocksByParts(Spanner, [Face42_sp])
343     if Blocks_f4_sp is None:
344       print "BlocksOp.GetBlocksByParts() : ", BlocksOp.GetErrorCode()
345
346     for aBlock in Blocks_f4_sp:
347       name = geompy.SubShapeName(aBlock, Spanner)
348       Id_block = geompy.addToStudyInFather(Spanner, aBlock, name)
349
350       f42_sp_ind = geompy.LocalOp.GetSubShapeIndex(aBlock, Face42_sp)
351
352       Face_5_horiz = GetFaceByNormale(geompy, aBlock, vz)
353       f_5_horiz_ind = geompy.LocalOp.GetSubShapeIndex(aBlock, Face_5_horiz)
354
355       MRot = geompy.MakeMultiTransformation2D(aBlock, f42_sp_ind, 0, 3, f_5_horiz_ind, 0, 5)
356       if MRot is not None:
357         p_z100 = geompy.MakeVertex(0., 0., 100.)
358         MRot_tr = geompy.MakeTranslationTwoPoints(MRot, p0, p_z100)
359         id_MRot_tr = geompy.addToStudy(MRot_tr, "Multi-rotated block 5")
360
361     if BlocksOp.IsDone() == 0:
362       print "Operation failed"
363
364     ### Get one face of the Gear ###
365
366     p_20_0_tr   = geompy.MakeTranslationTwoPoints(p_20_0  , p0, p_60_150_0)
367     p_20_0_r_tr = geompy.MakeTranslationTwoPoints(p_20_0_r, p0, p_60_150_0)
368     p_40_0_tr   = geompy.MakeTranslationTwoPoints(p_40_0  , p0, p_60_150_0)
369     p_40_0_r_tr = geompy.MakeTranslationTwoPoints(p_40_0_r, p0, p_60_150_0)
370
371     Face_g_1 = BlocksOp.GetFaceByPoints(Gear, p_20_0_tr, p_20_0_r_tr, p_40_0_tr, p_40_0_r_tr)
372     if Face_g_1 is None:
373       print "BlocksOp.GetFaceByPoints(Gear, ...) : ", BlocksOp.GetErrorCode()
374     id_face_g_1 = geompy.addToStudyInFather(Gear, Face_g_1, "Face of Gear by four points")
375
376     edgesNb = geompy.ShapesOp.NumberOfEdges(Face_g_1)
377     print "Face of Gear has ", edgesNb, " edges"
378
379     Face_g_1_tr = geompy.MakeTranslationTwoPoints(Face_g_1, p0, pth)
380     id_face_g_1_tr = geompy.addToStudyInFather(Gear, Face_g_1_tr, "Face of Gear by four points, translated")
381
382     ### equivalent of Block1s, but made as block
383
384     Block_new = geompy.MakeHexa2Faces(Face_g_1, Face_g_1_tr)
385     id_block_new = geompy.addToStudy(Block_new, "Block New")
386
387   if isMeshTest == 1:
388
389     print "##################### Build Mesh #####################"
390
391     import StdMeshers
392
393     # ---- add a middle block of spanner handle in study
394
395     p_45_0_1 = geompy.MakeVertex(45., 0., 1.)
396     BlockMh = GetBlockNearPoint(geompy, Spanner, p_45_0_1)
397     id_blockMh = geompy.addToStudyInFather(Spanner, BlockMh, "Middle Block of Spanner Handle")
398
399     # ---- add the top face of the middle block in study
400
401     FaceTop = GetFaceByNormale(geompy, BlockMh, vz)
402     id_facetop = geompy.addToStudyInFather(BlockMh, FaceTop, "Top Face")
403
404     # ---- add long edges of the top face in study
405
406     FaceTop_edges = geompy.SubShapeAllSorted(FaceTop, geompy.ShapeType["EDGE"])
407     Edge1 = FaceTop_edges[0]
408     Edge2 = FaceTop_edges[3]
409     Id_Edge1 = geompy.addToStudyInFather(FaceTop, Edge1, "Edge 1")
410     Id_Edge2 = geompy.addToStudyInFather(FaceTop, Edge2, "Edge 2")
411
412     # ---- launch SMESH
413
414     smeshgui = None
415     if hasGUI == 1:
416       smeshgui = salome.ImportComponentGUI("SMESH")
417       smeshgui.Init(salome.myStudyId)
418
419     print "-------------------------- create Hypothesis"
420
421     print "-------------------------- NumberOfSegments"
422
423     hypNbSeg3 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
424     hypNbSeg3.SetNumberOfSegments(3)
425     print hypNbSeg3.GetName()
426     print hypNbSeg3.GetId()
427     print hypNbSeg3.GetNumberOfSegments()
428
429     if hasGUI == 1:
430       idseg = salome.ObjectToID(hypNbSeg3)
431       smeshgui.SetName(idseg, "NumberOfSegments_3");
432
433     print "-------------------------- LocalLength"
434
435     hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
436     hypLen1.SetLength(10)
437     print hypLen1.GetName()
438     print hypLen1.GetId()
439     print hypLen1.GetLength()
440
441     if hasGUI == 1:
442       idlength = salome.ObjectToID(hypLen1)
443       smeshgui.SetName(idlength, "Local_Length_10");
444
445     print "-------------------------- Propagation"
446
447     hypProp = smesh.CreateHypothesis("Propagation", "libStdMeshersEngine.so")
448     print hypProp.GetName()
449     print hypProp.GetId()
450
451     if hasGUI == 1:
452       idprop = salome.ObjectToID(hypProp)
453       smeshgui.SetName(idprop, "Propagation hypothesis");
454
455     #print "-------------------------- NumberOfSegments"
456     #
457     #hypNbSeg15 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
458     #hypNbSeg15.SetNumberOfSegments(15)
459     #print hypNbSeg15.GetName()
460     #print hypNbSeg15.GetId()
461     #print hypNbSeg15.GetNumberOfSegments()
462     #
463     #if hasGUI == 1:
464     #  idseg15 = salome.ObjectToID(hypNbSeg15)
465     #  smeshgui.SetName(idseg15, "NumberOfSegments_15");
466
467     print "-------------------------- Regular_1D"
468
469     algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
470     listHyp = algoReg.GetCompatibleHypothesis()
471     for hyp in listHyp:
472         print hyp
473     print algoReg.GetName()
474     print algoReg.GetId()
475
476     if hasGUI == 1:
477       idreg = salome.ObjectToID(algoReg)
478       smeshgui.SetName(idreg, "Regular_1D");
479
480     print "-------------------------- Quadrangle_2D"
481
482     algoQuad = smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
483     listHyp = algoQuad.GetCompatibleHypothesis()
484     for hyp in listHyp:
485         print hyp
486     print algoQuad.GetName()
487     print algoQuad.GetId()
488
489     if hasGUI == 1:
490       idquad = salome.ObjectToID(algoQuad)
491       smeshgui.SetName(idquad, "Quadrangle_2D");
492
493     print "---- Init a Mesh with the Spanner"
494
495     mesh = smesh.CreateMesh(Spanner)
496     if hasGUI == 1:
497       idmesh = salome.ObjectToID(mesh)
498       smeshgui.SetName(idmesh, "Meshed Spanner");
499
500     print "-------------------------- add hypothesis to Spanner"
501
502     mesh.AddHypothesis(Spanner, algoReg)
503     mesh.AddHypothesis(Spanner, hypNbSeg3)
504     mesh.AddHypothesis(Spanner, algoQuad)
505
506     print "-------------------------- add hypothesis to the Middle Block"
507
508     submesh_bl = mesh.GetSubMesh(BlockMh, "SubMesh Middle Block")
509     mesh.AddHypothesis(BlockMh, hypLen1)
510
511     print "-------------------------- add hypothesis to the long edges of the Top Face of the Middle Block"
512
513     submesh_e1 = mesh.GetSubMesh(Edge1, "SubMesh Edge 1 of Top Face")
514     mesh.AddHypothesis(Edge1, hypProp)
515     #mesh.AddHypothesis(Edge1, hypNbSeg15)
516
517     submesh_e2 = mesh.GetSubMesh(Edge2, "SubMesh Edge 2 of Top Face")
518     mesh.AddHypothesis(Edge2, hypProp)
519     #mesh.AddHypothesis(Edge2, hypNbSeg15)
520
521     print "-------------------------- compute the mesh"
522     smesh.Compute(mesh, Spanner)
523
524     print "Information about the Mesh:"
525     print "Number of nodes       : ", mesh.NbNodes()
526     print "Number of edges       : ", mesh.NbEdges()
527     print "Number of faces       : ", mesh.NbFaces()
528     print "Number of triangles   : ", mesh.NbTriangles()
529     print "Number of quadrangles : ", mesh.NbQuadrangles()
530     print "Number of volumes     : ", mesh.NbVolumes()
531     print "Number of tetrahedrons: ", mesh.NbTetras()
532
533   return Spanner