Salome HOME
*** empty log message ***
[modules/smesh.git] / doc / salome / gui / SMESH / constructing_meshes.htm
1 <!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">\r
2 \r
3 <html>\r
4 \r
5 <head>\r
6 <title>Constructing Meshes</title>\r
7 <meta http-equiv="content-type" content="text/html; charset=windows-1252">\r
8 <meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com"><style type="text/css">\r
9 <!--\r
10 p.whs1 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }\r
11 p.whs2 { margin-top:0pt; margin-bottom:0pt; }\r
12 p.whs3 { font-family:'Lucida Console' , monospace; margin-top:0px; margin-bottom:0px; }\r
13 p.whs4 { margin-top:0px; margin-bottom:0px; }\r
14 p.whs5 { margin-top:0px; margin-bottom:0px; font-family:'Times New Roman' , serif; }\r
15 -->\r
16 </style><script type="text/javascript" language="JavaScript">\r
17 <!--\r
18 if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))\r
19 {\r
20   var strNSS = "<style type='text/css'>";\r
21   strNSS += "p.whs1 {margin-top:1pt;margin-bottom:1pt; }";\r
22   strNSS += "p.whs2 {margin-top:1pt;margin-bottom:1pt; }";\r
23   strNSS += "p.whs3 {margin-top:1pt;margin-bottom:1pt; }";\r
24   strNSS += "p.whs4 {margin-top:1pt;margin-bottom:1pt; }";\r
25   strNSS += "p.whs5 {margin-top:1pt;margin-bottom:1pt; }";\r
26   strNSS +="</style>";\r
27   document.write(strNSS);\r
28 }\r
29 //-->\r
30 </script>\r
31 <script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">\r
32 <!--\r
33 function reDo() {\r
34   if (innerWidth != origWidth || innerHeight != origHeight)\r
35      location.reload();\r
36 }\r
37 if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {\r
38         origWidth = innerWidth;\r
39         origHeight = innerHeight;\r
40         onresize = reDo;\r
41 }\r
42 onerror = null; \r
43 //-->\r
44 </script>\r
45 <style type="text/css">\r
46 <!--\r
47 div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }\r
48 -->\r
49 </style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>\r
50 <script type="text/javascript" language="javascript" src="whver.js"></script>\r
51 <script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>\r
52 <script type="text/javascript" language="javascript1.2" src="whutils.js"></script>\r
53 <script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>\r
54 </head>\r
55 <body><script type="text/javascript" language="javascript1.2">\r
56 <!--\r
57 if (window.gbWhTopic)\r
58 {\r
59         if (window.addTocInfo)\r
60         {\r
61         addTocInfo("MESH module\nTUI Scripts\nCreating Meshes");\r
62 addButton("show",BTN_TEXT,"Show","","","","",0,0,"","","");\r
63 \r
64         }\r
65         if (window.writeBtnStyle)\r
66                 writeBtnStyle();\r
67 \r
68         if (window.writeIntopicBar)\r
69                 writeIntopicBar(1);\r
70 \r
71         if (window.setRelStartPage)\r
72         {\r
73         setRelStartPage("smesh.htm");\r
74 \r
75                 autoSync(1);\r
76                 sendSyncInfo();\r
77                 sendAveInfoOut();\r
78         }\r
79 }\r
80 else\r
81         if (window.gbIE4)\r
82                 document.location.reload();\r
83 //-->\r
84 </script>\r
85 <h1>Creating Meshes</h1>\r
86 \r
87 <h3><a name=bookmark>Construction of a Mesh</a></h3>\r
88 \r
89 <p class="whs1">import salome</p>\r
90 \r
91 <p class="whs1">import geompy</p>\r
92 \r
93 <p class="whs1">import StdMeshers</p>\r
94 \r
95 <p class="whs1">smesh = salome.lcc.FindOrLoadComponent(&quot;FactoryServer&quot;, \r
96  &quot;SMESH&quot;)</p>\r
97 \r
98 <p class="whs1">smeshgui = salome.ImportComponentGUI(&quot;SMESH&quot;)</p>\r
99 \r
100 <p class="whs1">smeshgui.Init(salome.myStudyId);</p>\r
101 \r
102 <p class="whs2">&nbsp;</p>\r
103 \r
104 <p class="whs2"># create a box</p>\r
105 \r
106 <p class="whs1">box = geompy.MakeBox(0., \r
107  0., 0., 100., 200., 300.)</p>\r
108 \r
109 <p class="whs2">&nbsp;</p>\r
110 \r
111 <p class="whs2"># add box to the study</p>\r
112 \r
113 <p class="whs1">idbox = geompy.addToStudy(box, \r
114  &quot;box&quot;)</p>\r
115 \r
116 <p class="whs2">&nbsp;</p>\r
117 \r
118 <p class="whs2"># create a hypothesis</p>\r
119 \r
120 <p class="whs1">print &quot;-------------------------- \r
121  create Hypothesis&quot;</p>\r
122 \r
123 <p class="whs1">print &quot;-------------------------- \r
124  NumberOfSegments&quot;</p>\r
125 \r
126 <p class="whs1">numberOfSegments \r
127  = 7</p>\r
128 \r
129 <p class="whs1">hypNbSeg = smesh.CreateHypothesis(&quot;NumberOfSegments&quot;, \r
130  &quot;libStdMeshersEngine.so&quot;)</p>\r
131 \r
132 <p class="whs1">hypNbSeg.SetNumberOfSegments(numberOfSegments)</p>\r
133 \r
134 <p class="whs1">print hypNbSeg.GetName()</p>\r
135 \r
136 <p class="whs1">print hypNbSeg.GetId()</p>\r
137 \r
138 <p class="whs1">print hypNbSeg.GetNumberOfSegments()</p>\r
139 \r
140 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypNbSeg), \r
141  &quot;NumberOfSegments_10&quot;)</p>\r
142 \r
143 <p class="whs1">print &quot;-------------------------- \r
144  MaxElementArea&quot;</p>\r
145 \r
146 <p class="whs1">maxElementArea = \r
147  800</p>\r
148 \r
149 <p class="whs1">hypArea = smesh.CreateHypothesis(&quot;MaxElementArea&quot;, \r
150  &quot;libStdMeshersEngine.so&quot;)</p>\r
151 \r
152 <p class="whs1">hypArea.SetMaxElementArea(maxElementArea)</p>\r
153 \r
154 <p class="whs1">print hypArea.GetName()</p>\r
155 \r
156 <p class="whs1">print hypArea.GetId()</p>\r
157 \r
158 <p class="whs1">print hypArea.GetMaxElementArea()</p>\r
159 \r
160 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypArea), \r
161  &quot;MaxElementArea_500&quot;)</p>\r
162 \r
163 <p class="whs1">print &quot;-------------------------- \r
164  MaxElementVolume&quot;</p>\r
165 \r
166 <p class="whs1">maxElementVolume \r
167  = 900</p>\r
168 \r
169 <p class="whs1">hypVolume = smesh.CreateHypothesis(&quot;MaxElementVolume&quot;, \r
170  &quot;libStdMeshersEngine.so&quot;)</p>\r
171 \r
172 <p class="whs1">hypVolume.SetMaxElementVolume(maxElementVolume)</p>\r
173 \r
174 <p class="whs1">print hypVolume.GetName()</p>\r
175 \r
176 <p class="whs1">print hypVolume.GetId()</p>\r
177 \r
178 <p class="whs1">print hypVolume.GetMaxElementVolume()</p>\r
179 \r
180 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypVolume), \r
181  &quot;MaxElementVolume_500&quot;)</p>\r
182 \r
183 <p class="whs2">&nbsp;</p>\r
184 \r
185 <p class="whs2"># create algorithms</p>\r
186 \r
187 <p class="whs1">print &quot;-------------------------- \r
188  create Algorithms&quot;</p>\r
189 \r
190 <p class="whs1">print &quot;-------------------------- \r
191  Regular_1D&quot;</p>\r
192 \r
193 <p class="whs1">regular1D = smesh.CreateHypothesis(&quot;Regular_1D&quot;, \r
194  &quot;libStdMeshersEngine.so&quot;)</p>\r
195 \r
196 <p class="whs1">smeshgui.SetName(salome.ObjectToID(regular1D), \r
197  &quot;Wire Discretisation&quot;)</p>\r
198 \r
199 <p class="whs1">print &quot;-------------------------- \r
200  MEFISTO_2D&quot;</p>\r
201 \r
202 <p class="whs1">mefisto2D = smesh.CreateHypothesis(&quot;MEFISTO_2D&quot;, \r
203  &quot;libStdMeshersEngine.so&quot;)</p>\r
204 \r
205 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mefisto2D), \r
206  &quot;MEFISTO_2D&quot;)</p>\r
207 \r
208 <p class="whs2">&nbsp;</p>\r
209 \r
210 <p class="whs2"># initialize a mesh with \r
211  the box</p>\r
212 \r
213 <p class="whs1">mesh = smesh.CreateMesh(box)</p>\r
214 \r
215 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mesh), \r
216  &quot;MeshBox&quot;)</p>\r
217 \r
218 <p class="whs2">&nbsp;</p>\r
219 \r
220 <p class="whs2"># add the hypothesis to \r
221  the box</p>\r
222 \r
223 <p class="whs1">print &quot;-------------------------- \r
224  add hypothesis to the box&quot;</p>\r
225 \r
226 <p class="whs1">mesh.AddHypothesis(box,hypNbSeg)</p>\r
227 \r
228 <p class="whs1">mesh.AddHypothesis(box,hypArea)</p>\r
229 \r
230 <p class="whs1">mesh.AddHypothesis(box,hypVolume)</p>\r
231 \r
232 <p class="whs1">mesh.AddHypothesis(box,regular1D)</p>\r
233 \r
234 <p class="whs1">mesh.AddHypothesis(box,mefisto2D)</p>\r
235 \r
236 <p class="whs2">&nbsp;</p>\r
237 \r
238 <p class="whs2"># compute the mesh</p>\r
239 \r
240 <p class="whs1">print &quot;-------------------------- \r
241  compute the mesh of the box&quot;</p>\r
242 \r
243 <p class="whs1">ret = smesh.Compute(mesh,box)</p>\r
244 \r
245 <p class="whs1">print ret</p>\r
246 \r
247 <p class="whs1">if ret == 0:</p>\r
248 \r
249 <p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;print \r
250  &quot;probleme when computing the mesh&quot;</p>\r
251 \r
252 <p class="whs1">salome.sg.updateObjBrowser(1)</p>\r
253 \r
254 <p class="whs1">&nbsp;</p>\r
255 \r
256 <h3><a name=bookmark1>Construction of a Submesh</a></h3>\r
257 \r
258 <p class="whs3">&nbsp;</p>\r
259 \r
260 <p class="whs3"><span style="font-family: 'Lucida Console', monospace;">from \r
261  geompy import *</span></p>\r
262 \r
263 <p class="whs3">import smesh</p>\r
264 \r
265 <p class="whs4">&nbsp;</p>\r
266 \r
267 <p class="whs4"># create vertices</p>\r
268 \r
269 <p class="whs3">Point111 = MakeVertex( 0, &nbsp;0, \r
270  &nbsp;0)</p>\r
271 \r
272 <p class="whs3">Point211 = MakeVertex(10, &nbsp;0, \r
273  &nbsp;0)</p>\r
274 \r
275 <p class="whs3">Point121 = MakeVertex( 0, 10, &nbsp;0)</p>\r
276 \r
277 <p class="whs3">Point221 = MakeVertex(10, 10, &nbsp;0)</p>\r
278 \r
279 <p class="whs3">Point112 = MakeVertex( 0, &nbsp;0, \r
280  10)</p>\r
281 \r
282 <p class="whs3">Point212 = MakeVertex(10, &nbsp;0, \r
283  10)</p>\r
284 \r
285 <p class="whs3">Point122 = MakeVertex( 0, 10, 10)</p>\r
286 \r
287 <p class="whs3">Point222 = MakeVertex(10, 10, 10)</p>\r
288 \r
289 <p class="whs4">&nbsp;</p>\r
290 \r
291 <p class="whs4"># create edges</p>\r
292 \r
293 <p class="whs3">EdgeX111 = MakeEdge(Point111, Point211)</p>\r
294 \r
295 <p class="whs3">EdgeX121 = MakeEdge(Point121, Point221)</p>\r
296 \r
297 <p class="whs3">EdgeX112 = MakeEdge(Point112, Point212)</p>\r
298 \r
299 <p class="whs3">EdgeX122 = MakeEdge(Point122, Point222)</p>\r
300 \r
301 <p class="whs3">EdgeY11 = MakeEdge(Point111, Point121)</p>\r
302 \r
303 <p class="whs3">EdgeY21 = MakeEdge(Point211, Point221)</p>\r
304 \r
305 <p class="whs3">EdgeY12 = MakeEdge(Point112, Point122)</p>\r
306 \r
307 <p class="whs3">EdgeY22 = MakeEdge(Point212, Point222)</p>\r
308 \r
309 <p class="whs3">EdgeZ111 = MakeEdge(Point111, Point112)</p>\r
310 \r
311 <p class="whs3">EdgeZ211 = MakeEdge(Point211, Point212)</p>\r
312 \r
313 <p class="whs3">EdgeZ121 = MakeEdge(Point121, Point122)</p>\r
314 \r
315 <p class="whs3">EdgeZ221 = MakeEdge(Point221, Point222)</p>\r
316 \r
317 <p class="whs4">&nbsp;</p>\r
318 \r
319 <p class="whs4"># create faces</p>\r
320 \r
321 <p class="whs3">FaceX11 = MakeQuad(EdgeY11, EdgeZ111, \r
322  EdgeY12, EdgeZ121)</p>\r
323 \r
324 <p class="whs3">FaceX21 = MakeQuad(EdgeY21, EdgeZ211, \r
325  EdgeY22, EdgeZ221)</p>\r
326 \r
327 <p class="whs3">FaceY111 = MakeQuad(EdgeX111, EdgeZ111, \r
328  EdgeX112, EdgeZ211)</p>\r
329 \r
330 <p class="whs3">FaceY121 = MakeQuad(EdgeX121, EdgeZ121, \r
331  EdgeX122, EdgeZ221)</p>\r
332 \r
333 <p class="whs3">FaceZ11 = MakeQuad(EdgeX111, EdgeY11, \r
334  EdgeX121, EdgeY21)</p>\r
335 \r
336 <p class="whs3">FaceZ12 = MakeQuad(EdgeX112, EdgeY12, \r
337  EdgeX122, EdgeY22)</p>\r
338 \r
339 <p class="whs4">&nbsp;</p>\r
340 \r
341 <p class="whs4"># create a solid</p>\r
342 \r
343 <p class="whs3">Block = MakeHexa(FaceX11, FaceX21, FaceY111, \r
344  FaceY121, FaceZ11, FaceZ12)</p>\r
345 \r
346 <p class="whs4">&nbsp;</p>\r
347 \r
348 <p class="whs4"># create a compound</p>\r
349 \r
350 <p class="whs3">box = MakeCompound([Block])</p>\r
351 \r
352 <p class="whs4">&nbsp;</p>\r
353 \r
354 <p class="whs4"># add in the study</p>\r
355 \r
356 <p class="whs3">box_id = addToStudy(box, &quot;Box compound&quot;)</p>\r
357 \r
358 <p class="whs4">&nbsp;</p>\r
359 \r
360 <p class="whs4"># create hexahedral mesh \r
361  on the box</p>\r
362 \r
363 <p class="whs3">hexa = smesh.Mesh(box, &quot;Box compound \r
364  : hexahedrical mesh&quot;)</p>\r
365 \r
366 <p class="whs3">algo = hexa.Segment()</p>\r
367 \r
368 <p class="whs4">&nbsp;</p>\r
369 \r
370 <p class="whs4"># define &quot;NumberOfSegments&quot; \r
371  hypothesis to cut the edge in a fixed number of segments</p>\r
372 \r
373 <p class="whs3">algo.NumberOfSegments(4)</p>\r
374 \r
375 <p class="whs4">&nbsp;</p>\r
376 \r
377 <p class="whs4"># creates a quadrangle \r
378  2D algorithm for the faces</p>\r
379 \r
380 <p class="whs3">hexa.Quadrangle()</p>\r
381 \r
382 <p class="whs4">&nbsp;</p>\r
383 \r
384 <p class="whs4"># construct a submesh with \r
385  a local hypothesis</p>\r
386 \r
387 <p class="whs3">algo = hexa.Segment(EdgeX111)</p>\r
388 \r
389 <p class="whs4">&nbsp;</p>\r
390 \r
391 <p class="whs4"># define &quot;Arithmetic1D&quot; \r
392  hypothesis to cut an edge in several segments with increasing arithmetic \r
393  length </p>\r
394 \r
395 <p class="whs3">algo.Arithmetic1D(1, 4)</p>\r
396 \r
397 <p class="whs4">&nbsp;</p>\r
398 \r
399 <p class="whs4"># define &quot;Propagation&quot; \r
400  hypothesis that propagates all other hypothesis on all edges on the opposite \r
401  side in case of quadrangular faces</p>\r
402 \r
403 <p class="whs3">algo.Propagation()</p>\r
404 \r
405 <p class="whs4">&nbsp;</p>\r
406 \r
407 <p class="whs4"># compute the mesh</p>\r
408 \r
409 <p class="whs3">hexa.Compute() )</p>\r
410 \r
411 <p class="whs3">&nbsp;</p>\r
412 \r
413 <h3><a name=bookmark2>Editing of a mesh</a></h3>\r
414 \r
415 <p class="whs3">&nbsp;</p>\r
416 \r
417 <p class="whs3"><span style="font-family: 'Lucida Console', monospace;">import \r
418  salome</span></p>\r
419 \r
420 <p class="whs3">import geompy</p>\r
421 \r
422 <p class="whs3">import SMESH</p>\r
423 \r
424 <p class="whs3">import StdMeshers</p>\r
425 \r
426 <p class="whs3">&nbsp;</p>\r
427 \r
428 <p class="whs3">smesh = salome.lcc.FindOrLoadComponent(&quot;FactoryServer&quot;, \r
429  &quot;SMESH&quot;)</p>\r
430 \r
431 <p class="whs3">smesh.SetCurrentStudy(salome.myStudy)</p>\r
432 \r
433 <p class="whs3">&nbsp;</p>\r
434 \r
435 <p class="whs3">box &nbsp;&nbsp;= \r
436  geompy.MakeBox(0., 0., 0., 20., 20., 20.)</p>\r
437 \r
438 <p class="whs3">idbox = geompy.addToStudy(box, &quot;box&quot;)</p>\r
439 \r
440 <p class="whs3">&nbsp;</p>\r
441 \r
442 <p class="whs3">subShapeList = geompy.SubShapeAll(box, \r
443  geompy.ShapeType[&quot;EDGE&quot;])</p>\r
444 \r
445 <p class="whs3">edge &nbsp;&nbsp;= \r
446  subShapeList[0]</p>\r
447 \r
448 <p class="whs3">name &nbsp;&nbsp;= \r
449  geompy.SubShapeName(edge, box)</p>\r
450 \r
451 <p class="whs3">idedge = geompy.addToStudyInFather(box, \r
452  edge, name)</p>\r
453 \r
454 <p class="whs3">&nbsp;</p>\r
455 \r
456 <p class="whs3">box &nbsp;= \r
457  salome.IDToObject(idbox)</p>\r
458 \r
459 <p class="whs3">edge = salome.IDToObject(idedge)</p>\r
460 \r
461 <p class="whs3">&nbsp;</p>\r
462 \r
463 <p class="whs3">hyp1 = smesh.CreateHypothesis(&quot;NumberOfSegments&quot;, \r
464  &quot;libStdMeshersEngine.so&quot;)</p>\r
465 \r
466 <p class="whs3">hyp1.SetNumberOfSegments(3)</p>\r
467 \r
468 <p class="whs3">hyp2 = smesh.CreateHypothesis(&quot;MaxElementArea&quot;, \r
469  &quot;libStdMeshersEngine.so&quot;)</p>\r
470 \r
471 <p class="whs3">hyp2.SetMaxElementArea(10)</p>\r
472 \r
473 <p class="whs3">hyp3 = smesh.CreateHypothesis(&quot;Arithmetic1D&quot;, \r
474  &quot;libStdMeshersEngine.so&quot;)</p>\r
475 \r
476 <p class="whs3">hyp3.SetLength(1,1)</p>\r
477 \r
478 <p class="whs3">hyp3.SetLength(6,0)</p>\r
479 \r
480 <p class="whs3">hyp4 = smesh.CreateHypothesis(&quot;Propagation&quot;, \r
481  &quot;libStdMeshersEngine.so&quot;)</p>\r
482 \r
483 <p class="whs3">&nbsp;</p>\r
484 \r
485 <p class="whs3">algo1 = smesh.CreateHypothesis(&quot;Regular_1D&quot;, \r
486  &quot;libStdMeshersEngine.so&quot;)</p>\r
487 \r
488 <p class="whs3">algo2 = smesh.CreateHypothesis(&quot;MEFISTO_2D&quot;, \r
489  &quot;libStdMeshersEngine.so&quot;)</p>\r
490 \r
491 <p class="whs3">&nbsp;</p>\r
492 \r
493 <p class="whs3">mesh = smesh.CreateMesh(box)</p>\r
494 \r
495 <p class="whs3">mesh.AddHypothesis(box,hyp1)</p>\r
496 \r
497 <p class="whs3">mesh.AddHypothesis(box,hyp2)</p>\r
498 \r
499 <p class="whs3">mesh.AddHypothesis(box,algo1)</p>\r
500 \r
501 <p class="whs3">mesh.AddHypothesis(box,algo2)</p>\r
502 \r
503 <p class="whs3">mesh.AddHypothesis(edge,hyp3)</p>\r
504 \r
505 <p class="whs3">mesh.AddHypothesis(edge,hyp4)</p>\r
506 \r
507 <p class="whs3">mesh.AddHypothesis(edge,algo1)</p>\r
508 \r
509 <p class="whs3">&nbsp;</p>\r
510 \r
511 <p class="whs3">smesh.Compute(mesh,box)</p>\r
512 \r
513 <p class="whs3">salome.sg.updateObjBrowser(1)</p>\r
514 \r
515 <p class="whs3">&nbsp;</p>\r
516 \r
517 <p class="whs5"># remove a hypothesis</p>\r
518 \r
519 <p class="whs3">mesh.RemoveHypothesis(edge,hyp4)</p>\r
520 \r
521 <p class="whs3">&nbsp;</p>\r
522 \r
523 <p class="whs3">smesh.Compute(mesh,box)</p>\r
524 \r
525 <p class="whs3">salome.sg.updateObjBrowser(1)</p>\r
526 \r
527 <p class="whs3">&nbsp;</p>\r
528 \r
529 <p class="whs5"># change the value \r
530  of the hypothesis</p>\r
531 \r
532 <p class="whs3">hyp2.SetMaxElementArea(2)</p>\r
533 \r
534 <p class="whs3">mesh.AddHypothesis(box,hyp2)</p>\r
535 \r
536 <p class="whs3">&nbsp;</p>\r
537 \r
538 <p class="whs3">smesh.Compute(mesh,box)</p>\r
539 \r
540 <p class="whs3">salome.sg.updateObjBrowser(1) </p>\r
541 \r
542 <p class="whs4">&nbsp;</p>\r
543 \r
544 <h3><a name=bookmark3>Export of a Mesh</a></h3>\r
545 \r
546 <p class="whs4">&nbsp;</p>\r
547 \r
548 <p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import \r
549  salome</span></p>\r
550 \r
551 <p class="whs1">import geompy</p>\r
552 \r
553 <p class="whs1">import StdMeshers</p>\r
554 \r
555 <p class="whs1">smesh = salome.lcc.FindOrLoadComponent(&quot;FactoryServer&quot;, \r
556  &quot;SMESH&quot;)</p>\r
557 \r
558 <p class="whs1">smeshgui = salome.ImportComponentGUI(&quot;SMESH&quot;)</p>\r
559 \r
560 <p class="whs1">smeshgui.Init(salome.myStudyId);</p>\r
561 \r
562 <p class="whs2">&nbsp;</p>\r
563 \r
564 <p class="whs2"># create a box</p>\r
565 \r
566 <p class="whs1">box = geompy.MakeBox(0., \r
567  0., 0., 100., 200., 300.)</p>\r
568 \r
569 <p class="whs2">&nbsp;</p>\r
570 \r
571 <p class="whs2"># add the box to the study</p>\r
572 \r
573 <p class="whs1">idbox = geompy.addToStudy(box, \r
574  &quot;box&quot;)</p>\r
575 \r
576 <p class="whs2">&nbsp;</p>\r
577 \r
578 <p class="whs2"># create a hypothesis</p>\r
579 \r
580 <p class="whs1">print &quot;-------------------------- \r
581  create Hypothesis&quot;</p>\r
582 \r
583 <p class="whs1">print &quot;-------------------------- \r
584  NumberOfSegments&quot;</p>\r
585 \r
586 <p class="whs1">numberOfSegments \r
587  = 7</p>\r
588 \r
589 <p class="whs1">hypNbSeg = smesh.CreateHypothesis(&quot;NumberOfSegments&quot;, \r
590  &quot;libStdMeshersEngine.so&quot;)</p>\r
591 \r
592 <p class="whs1">hypNbSeg.SetNumberOfSegments(numberOfSegments)</p>\r
593 \r
594 <p class="whs1">print hypNbSeg.GetName()</p>\r
595 \r
596 <p class="whs1">print hypNbSeg.GetId()</p>\r
597 \r
598 <p class="whs1">print hypNbSeg.GetNumberOfSegments()</p>\r
599 \r
600 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypNbSeg), \r
601  &quot;NumberOfSegments_10&quot;)</p>\r
602 \r
603 <p class="whs1">print &quot;-------------------------- \r
604  MaxElementArea&quot;</p>\r
605 \r
606 <p class="whs1">maxElementArea = \r
607  800</p>\r
608 \r
609 <p class="whs1">hypArea = smesh.CreateHypothesis(&quot;MaxElementArea&quot;, \r
610  &quot;libStdMeshersEngine.so&quot;)</p>\r
611 \r
612 <p class="whs1">hypArea.SetMaxElementArea(maxElementArea)</p>\r
613 \r
614 <p class="whs1">print hypArea.GetName()</p>\r
615 \r
616 <p class="whs1">print hypArea.GetId()</p>\r
617 \r
618 <p class="whs1">print hypArea.GetMaxElementArea()</p>\r
619 \r
620 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypArea), \r
621  &quot;MaxElementArea_500&quot;)</p>\r
622 \r
623 <p class="whs1">print &quot;-------------------------- \r
624  MaxElementVolume&quot;</p>\r
625 \r
626 <p class="whs1">maxElementVolume \r
627  = 900</p>\r
628 \r
629 <p class="whs1">hypVolume = smesh.CreateHypothesis(&quot;MaxElementVolume&quot;, \r
630  &quot;libStdMeshersEngine.so&quot;)</p>\r
631 \r
632 <p class="whs1">hypVolume.SetMaxElementVolume(maxElementVolume)</p>\r
633 \r
634 <p class="whs1">print hypVolume.GetName()</p>\r
635 \r
636 <p class="whs1">print hypVolume.GetId()</p>\r
637 \r
638 <p class="whs1">print hypVolume.GetMaxElementVolume()</p>\r
639 \r
640 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypVolume), \r
641  &quot;MaxElementVolume_500&quot;)</p>\r
642 \r
643 <p class="whs2">&nbsp;</p>\r
644 \r
645 <p class="whs2"># create algorithms</p>\r
646 \r
647 <p class="whs1">print &quot;-------------------------- \r
648  create Algorithms&quot;</p>\r
649 \r
650 <p class="whs1">print &quot;-------------------------- \r
651  Regular_1D&quot;</p>\r
652 \r
653 <p class="whs1">regular1D = smesh.CreateHypothesis(&quot;Regular_1D&quot;, \r
654  &quot;libStdMeshersEngine.so&quot;)</p>\r
655 \r
656 <p class="whs1">smeshgui.SetName(salome.ObjectToID(regular1D), \r
657  &quot;Wire Discretisation&quot;)</p>\r
658 \r
659 <p class="whs1">print &quot;-------------------------- \r
660  MEFISTO_2D&quot;</p>\r
661 \r
662 <p class="whs1">mefisto2D = smesh.CreateHypothesis(&quot;MEFISTO_2D&quot;, \r
663  &quot;libStdMeshersEngine.so&quot;)</p>\r
664 \r
665 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mefisto2D), \r
666  &quot;MEFISTO_2D&quot;)</p>\r
667 \r
668 <p class="whs2">&nbsp;</p>\r
669 \r
670 <p class="whs2"># initialize a mesh with \r
671  the box</p>\r
672 \r
673 <p class="whs1">mesh = smesh.CreateMesh(box)</p>\r
674 \r
675 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mesh), \r
676  &quot;MeshBox&quot;)</p>\r
677 \r
678 <p class="whs1">&nbsp;</p>\r
679 \r
680 <p class="whs2"># add the hypothesis to \r
681  the box</p>\r
682 \r
683 <p class="whs1">print &quot;-------------------------- \r
684  add hypothesis to the box&quot;</p>\r
685 \r
686 <p class="whs1">mesh.AddHypothesis(box,hypNbSeg)</p>\r
687 \r
688 <p class="whs1">mesh.AddHypothesis(box,hypArea)</p>\r
689 \r
690 <p class="whs1">mesh.AddHypothesis(box,hypVolume)</p>\r
691 \r
692 <p class="whs1">mesh.AddHypothesis(box,regular1D)</p>\r
693 \r
694 <p class="whs1">mesh.AddHypothesis(box,mefisto2D)</p>\r
695 \r
696 <p class="whs2">&nbsp;</p>\r
697 \r
698 <p class="whs2"># compute the mesh</p>\r
699 \r
700 <p class="whs1">print &quot;-------------------------- \r
701  compute the mesh of the box&quot;</p>\r
702 \r
703 <p class="whs1">ret = smesh.Compute(mesh,box)</p>\r
704 \r
705 <p class="whs1">print ret</p>\r
706 \r
707 <p class="whs1">if ret == 0:</p>\r
708 \r
709 <p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;print \r
710  &quot;probleme when computing the mesh&quot;</p>\r
711 \r
712 <p class="whs1">salome.sg.updateObjBrowser(1)</p>\r
713 \r
714 <p class="whs1">mesh.ExportMED(&quot;/tmp/meshMED.med&quot;,0)</p>\r
715 \r
716 <p class="whs2">&nbsp;</p>\r
717 \r
718 <p class="whs4">&nbsp;</p>\r
719 \r
720 <script type="text/javascript" language="javascript1.2">\r
721 <!--\r
722 if (window.writeIntopicBar)\r
723         writeIntopicBar(0);\r
724 //-->\r
725 </script>\r
726 </body>\r
727 </html>\r