1 <!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
6 <title>Transforming Meshes</title>
7 <meta http-equiv="content-type" content="text/html; charset=windows-1252">
8 <meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com"><style type="text/css">
10 h3.whs1 { margin-top:0pt; margin-bottom:0pt; }
11 h4.whs2 { margin-top:0pt; margin-bottom:0pt; }
12 p.whs3 { font-family:'Lucida Console' , monospace; margin-top:0pt; margin-bottom:0pt; }
13 p.whs4 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }
14 p.whs5 { margin-top:0pt; margin-bottom:0pt; font-family:'Times New Roman' , serif; }
15 p.whs6 { margin-top:0pt; margin-bottom:0pt; }
17 </style><script type="text/javascript" language="JavaScript">
19 if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
21 var strNSS = "<style type='text/css'>";
22 strNSS += "h3.whs1 {margin-top:1pt;margin-bottom:1pt; }";
23 strNSS += "h4.whs2 {margin-top:1pt;margin-bottom:1pt; }";
24 strNSS += "p.whs3 {margin-top:1pt;margin-bottom:1pt; }";
25 strNSS += "p.whs4 {margin-top:1pt;margin-bottom:1pt; }";
26 strNSS += "p.whs5 {margin-top:1pt;margin-bottom:1pt; }";
27 strNSS += "p.whs6 {margin-top:1pt;margin-bottom:1pt; }";
29 document.write(strNSS);
33 <script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
36 if (innerWidth != origWidth || innerHeight != origHeight)
39 if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
40 origWidth = innerWidth;
41 origHeight = innerHeight;
47 <style type="text/css">
49 div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
50 p.WebHelpNavBar { text-align:right; }
52 </style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
53 <script type="text/javascript" language="javascript" src="whver.js"></script>
54 <script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
55 <script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
56 <script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
57 <script type="text/javascript" language="javascript1.2">
61 if (window.setRelStartPage)
63 addTocInfo("MESH module\nTUI Scripts\nTransforming Meshes");
64 addButton("show",BTN_IMG,"Show","","","","",0,0,"whd_show0.gif","whd_show2.gif","whd_show1.gif");
65 addButton("hide",BTN_IMG,"Hide","","","","",0,0,"whd_hide0.gif","whd_hide2.gif","whd_hide1.gif");
70 if (window.setRelStartPage)
72 setRelStartPage("index.htm");
82 document.location.reload();
86 <body><script type="text/javascript" language="javascript1.2">
88 if (window.writeIntopicBar)
92 <h1>Transforming Meshes</h1>
94 <h3 class="whs1">Transforming Meshes</h3>
96 <h4 class="whs2"> </h4>
98 <h4 class="whs2"><a name=bookmark>Translation</a></h4>
100 <p class="whs3"> </p>
102 <p class="whs4">import SMESH_mechanic</p>
104 <p class="whs4"> </p>
106 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">smesh
107 = SMESH_mechanic.smesh </span></p>
109 <p class="whs4">mesh = SMESH_mechanic.mesh
112 <p class="whs4"> </p>
114 <p class="whs5"># define translation
117 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">point
118 = smesh.PointStruct(-150., -150., 0.)</span></p>
120 <p class="whs4">vector =smesh.DirStruct(point)
123 <p class="whs4"> </p>
125 <p class="whs5"># translate a mesh</p>
127 <p class="whs4">doCopy = 1</p>
129 <p class="whs4"> </p>
131 <p class="whs4">mesh.Translate([],
132 vector, doCopy) </p>
134 <p class="whs6"> </p>
136 <h4 class="whs2"><a name=bookmark1>Rotation</a></h4>
138 <p class="whs3"> </p>
140 <p class="whs3">import math</p>
142 <p class="whs3">import SMESH_mechanic</p>
144 <p class="whs3"> </p>
146 <p class="whs3"><span style="font-family: 'Lucida Console', monospace;">smesh
147 = SMESH_mechanic.smesh</span></p>
149 <p class="whs3">mesh = SMESH_mechanic.mesh </p>
151 <p class="whs3"> </p>
153 <p class="whs5"># define rotation axis
156 <p class="whs3">axisXYZ = smesh.AxisStruct(0., 0., 0.,
159 <p class="whs3">angle270 = 1.5 * math.pi</p>
161 <p class="whs3"> </p>
163 <p class="whs5"># rotate a mesh</p>
165 <p class="whs4">mesh.Rotate([],
166 axisXYZ, angle270, 1) </p>
168 <p class="whs6"> </p>
170 <h4 class="whs2"><a name=bookmark2>Symmetry</a></h4>
172 <p class="whs3"> </p>
174 <p class="whs3">import math</p>
176 <p class="whs3"> </p>
178 <p class="whs3">import SMESH_mechanic</p>
180 <p class="whs3"> </p>
182 <p class="whs3"><span style="font-family: 'Lucida Console', monospace;">smesh
183 = SMESH_mechanic.smesh</span></p>
185 <p class="whs3">mesh = SMESH_mechanic.mesh </p>
187 <p class="whs3"> </p>
189 <p class="whs5"># create a symmetrical
190 copy of the mesh mirrored through a point</p>
192 <p class="whs3">axis = SMESH.AxisStruct(0, 0, 0, 0, 0,
195 <p class="whs3"> </p>
197 <p class="whs3">mesh.Mirror([], axis, smesh.POINT, 1)
200 <p class="whs6"> </p>
202 <h4 class="whs2"><a name=bookmark3>Merging
205 <p class="whs3"> </p>
207 <p class="whs4">import SMESH_mechanic</p>
209 <p class="whs4">mesh = SMESH_mechanic.mesh</p>
211 <p class="whs4"> </p>
213 <p class="whs5"># merge nodes</p>
215 <p class="whs4">Tolerance = 25.0</p>
217 <p class="whs4"> </p>
219 <p class="whs4">GroupsOfNodes =
220 mesh.FindCoincidentNodes(Tolerance)</p>
222 <p class="whs4">mesh.MergeNodes(GroupsOfNodes)
225 <p class="whs6"> </p>
227 <h4><a name=bookmark8>Merging Elements</a></h4>
229 <p class="whs4">import salome</p>
231 <p class="whs4">import geompy</p>
233 <p class="whs4">import smesh</p>
235 <p class="whs4"> </p>
237 <p class="whs5"># create a face to
240 <p class="whs4">px = geompy.MakeVertex(100.,
244 <p class="whs4">py = geompy.MakeVertex(0.
248 <p class="whs4">pz = geompy.MakeVertex(0.
252 <p class="whs4"> </p>
254 <p class="whs4">vxy = geompy.MakeVector(px,
257 <p class="whs4">arc = geompy.MakeArc(py,
260 <p class="whs4"> </p>
262 <p class="whs4">wire = geompy.MakeWire([vxy,
265 <p class="whs4">isPlanarFace = 1</p>
267 <p class="whs4"> </p>
269 <p class="whs4">face1 = geompy.MakeFace(wire,
272 <p class="whs4">id_face1 = geompy.addToStudy(face1,
273 "Face1")</p>
275 <p class="whs4"> </p>
277 <p class="whs5"># create a circle to
278 be an extrusion path</p>
280 <p class="whs4">px1 = geompy.MakeVertex(
284 <p class="whs4">py1 = geompy.MakeVertex(-100.,
287 <p class="whs4">pz1 = geompy.MakeVertex(
289 0.,
292 <p class="whs4"> </p>
294 <p class="whs4">circle = geompy.MakeCircleThreePnt(py1,
297 <p class="whs4">id_circle = geompy.addToStudy(circle,
298 "Path")</p>
300 <p class="whs4"> </p>
302 <p class="whs5"># create a 2D mesh
305 <p class="whs4">trias = smesh.Mesh(face1,
306 "Face : 2D mesh")</p>
308 <p class="whs4"> </p>
310 <p class="whs4">algo1D = trias.Segment()</p>
312 <p class="whs4">algo1D.NumberOfSegments(6)</p>
314 <p class="whs4">algo2D = trias.Triangle()</p>
316 <p class="whs4">algo2D.LengthFromEdges()</p>
318 <p class="whs4"> </p>
320 <p class="whs4">trias.Compute()</p>
322 <p class="whs5"> </p>
324 <p class="whs5"># create a path mesh</p>
326 <p class="whs4">circlemesh = smesh.Mesh(circle,
327 "Path mesh")</p>
329 <p class="whs4">algo = circlemesh.Segment()</p>
331 <p class="whs4">algo.NumberOfSegments(10)</p>
333 <p class="whs4">circlemesh.Compute()</p>
335 <p class="whs5"> </p>
337 <p class="whs5"># extrusion of the
340 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">trias.ExtrusionAlongPath([],
341 circlemesh, circle,</span></p>
343 <p class="whs4"> 1,
344 0, [], 0, smesh.PointStruct(0, 0, 0))</p>
346 <p class="whs4"> </p>
348 <p class="whs5"># merge nodes</p>
350 <p class="whs4">print "Number
351 of nodes before MergeNodes:", </p>
353 <p class="whs4">trias.NbNodes()</p>
355 <p class="whs4">tolerance = 0.001</p>
357 <p class="whs4">array_of_nodes_groups
358 = trias.FindCoincidentNodes(tolerance)</p>
360 <p class="whs4"> </p>
362 <p class="whs4">trias.MergeNodes(array_of_nodes_groups)</p>
364 <p class="whs4"> </p>
366 <p class="whs4">print "Number
367 of nodes after MergeNodes:", trias.NbNodes()</p>
369 <p class="whs4">print ""</p>
371 <p class="whs4">print "Number
372 of elements before MergeEqualElements:"</p>
374 <p class="whs4">print "Edges
375 :
376 ", trias.NbEdges()</p>
378 <p class="whs4">print "Triangles
380 trias.NbTriangles()</p>
382 <p class="whs4">print "Quadrangles:
383 ", trias.NbQuadrangles()</p>
385 <p class="whs4">print "Volumes
387 ", trias.NbVolumes()</p>
389 <p class="whs4"> </p>
391 <p class="whs5"># merge elements</p>
393 <p class="whs4">trias.MergeEqualElements()</p>
395 <p class="whs4">print "Number
396 of elements after MergeEqualElements:"</p>
398 <p class="whs4">print "Edges
399 :
400 ", trias.NbEdges()</p>
402 <p class="whs4">print "Triangles
404 trias.NbTriangles()</p>
406 <p class="whs4">print "Quadrangles:
407 ", trias.NbQuadrangles()</p>
409 <p class="whs4">print "Volumes
411 ", trias.NbVolumes()</p>
413 <p class="whs4"> </p>
415 <p class="whs4">salome.sg.updateObjBrowser(1)
418 <p class="whs4"> </p>
420 <h3>Sewing Meshes</h3>
422 <h4><a name=bookmark4>Sew Meshes Border to Border</a></h4>
424 <p class="whs4">import geompy</p>
426 <p class="whs4">import smesh</p>
428 <p class="whs4"> </p>
430 <p class="whs5"># create two faces
433 <p class="whs4">box1 = geompy.MakeBox(0.,
434 0., -10., 30., 20., 25.)</p>
436 <p class="whs4">facesList1 = geompy.SubShapeAll(box1,
437 geompy.ShapeType["FACE"])</p>
439 <p class="whs4">face1 = facesList1[2]</p>
441 <p class="whs4"> </p>
443 <p class="whs4">box2 = geompy.MakeBox(0.,
444 5., 0., 20., 20., 15.)</p>
446 <p class="whs4">facesList2 = geompy.SubShapeAll(box2,
447 geompy.ShapeType["FACE"])</p>
449 <p class="whs4">face2 = facesList2[1]</p>
451 <p class="whs4"> </p>
453 <p class="whs4">edgesList = geompy.SubShapeAll(face2,
454 geompy.ShapeType["EDGE"])</p>
456 <p class="whs4">edge1 = edgesList[2]</p>
458 <p class="whs4"> </p>
460 <p class="whs4">aComp = geompy.MakeCompound([face1,
463 <p class="whs4">geompy.addToStudy(aComp,
464 "Two faces")</p>
466 <p class="whs4"> </p>
468 <p class="whs5"># create a mesh on
471 <p class="whs4">mesh = smesh.Mesh(aComp,
472 "Two faces : quadrangle mesh")</p>
474 <p class="whs4"> </p>
476 <p class="whs4">algo1D = mesh.Segment()</p>
478 <p class="whs4">algo1D.NumberOfSegments(9)</p>
480 <p class="whs4">algo2D = mesh.Quadrangle()</p>
482 <p class="whs4"> </p>
484 <p class="whs4">algo_local = mesh.Segment(edge1)</p>
486 <p class="whs4">algo_local.Arithmetic1D(1,
489 <p class="whs4">algo_local.Propagation()</p>
491 <p class="whs4"> </p>
493 <p class="whs4">mesh.Compute()</p>
495 <p class="whs4"> </p>
497 <p class="whs5"># sew border to side</p>
499 <p class="whs5"># FirstNodeIDOnFreeBorder,
500 SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,</p>
502 <p class="whs5"># FirstNodeIDOnSide,
503 LastNodeIDOnSide,</p>
505 <p class="whs5"># CreatePolygons, CreatePolyedrs</p>
507 <p class="whs4">mesh.SewBorderToSide(5,
508 45, 6, 113, 109, 0, 0) </p>
510 <h4><a name=bookmark5>Sew Conform Free Borders</a></h4>
512 <p class="whs4">import geompy</p>
514 <p class="whs4">import smesh</p>
516 <p class="whs4"> </p>
518 <p class="whs5"># create two faces
521 <p class="whs4">box1 = geompy.MakeBox(0.,
522 0., -10., 20., 20., 15.)</p>
524 <p class="whs4">facesList1 = geompy.SubShapeAll(box1,
525 geompy.ShapeType["FACE"])</p>
527 <p class="whs4">face1 = facesList1[2]</p>
529 <p class="whs4"> </p>
531 <p class="whs4">box2 = geompy.MakeBox(0.,
532 5., 0., 20., 20., 15.)</p>
534 <p class="whs4">facesList2 = geompy.SubShapeAll(box2,
535 geompy.ShapeType["FACE"])</p>
537 <p class="whs4">face2 = facesList2[1]</p>
539 <p class="whs4"> </p>
541 <p class="whs4">edgesList = geompy.SubShapeAll(face2,
542 geompy.ShapeType["EDGE"])</p>
544 <p class="whs4">edge1 = edgesList[2]</p>
546 <p class="whs4"> </p>
548 <p class="whs4">aComp = geompy.MakeCompound([face1,
551 <p class="whs4">geompy.addToStudy(aComp,
552 "Two faces")</p>
554 <p class="whs4"> </p>
556 <p class="whs5"># create a mesh on
559 <p class="whs4">mesh = smesh.Mesh(aComp,
560 "Two faces : quadrangle mesh")</p>
562 <p class="whs4"> </p>
564 <p class="whs4">algo1D = mesh.Segment()</p>
566 <p class="whs4">algo1D.NumberOfSegments(9)</p>
568 <p class="whs4">algo2D = mesh.Quadrangle()</p>
570 <p class="whs4"> </p>
572 <p class="whs4">algo_local = mesh.Segment(edge1)</p>
574 <p class="whs4">algo_local.Arithmetic1D(1,
577 <p class="whs4">algo_local.Propagation()</p>
579 <p class="whs4"> </p>
581 <p class="whs4">mesh.Compute()</p>
583 <p class="whs4"> </p>
585 <p class="whs5"># sew conform free
588 <p class="whs5"># FirstNodeID1, SecondNodeID1,
589 LastNodeID1, FirstNodeID2, SecondNodeID2</p>
591 <p class="whs4">mesh.SewConformFreeBorders(5,
592 45, 6, 3, 24) </p>
594 <h4><a name=bookmark6>Sew Free Borders</a></h4>
596 <p class="whs4">import geompy</p>
598 <p class="whs4">import smesh</p>
600 <p class="whs4"> </p>
602 <p class="whs5"># create two faces
605 <p class="whs4">box1 = geompy.MakeBox(0.,
606 0., 0., 20., 20., 15.)</p>
608 <p class="whs4">facesList1 = geompy.SubShapeAll(box1,
609 geompy.ShapeType["FACE"])</p>
611 <p class="whs4">face1 = facesList1[2]</p>
613 <p class="whs4"> </p>
615 <p class="whs4">box2 = geompy.MakeBox(0.,
616 5., 0., 20., 20., 15.)</p>
618 <p class="whs4">facesList2 = geompy.SubShapeAll(box2,
619 geompy.ShapeType["FACE"])</p>
621 <p class="whs4">face2 = facesList2[1]</p>
623 <p class="whs4"> </p>
625 <p class="whs4">edgesList = geompy.SubShapeAll(face2,
626 geompy.ShapeType["EDGE"])</p>
628 <p class="whs4">edge1 = edgesList[2]</p>
630 <p class="whs4"> </p>
632 <p class="whs4">aComp = geompy.MakeCompound([face1,
635 <p class="whs4">geompy.addToStudy(aComp,
636 "Two faces")</p>
638 <p class="whs4"> </p>
640 <p class="whs5"># create a mesh on
643 <p class="whs4">mesh = smesh.Mesh(aComp,
644 "Two faces : quadrangle mesh")</p>
646 <p class="whs4"> </p>
648 <p class="whs4">algo1D = mesh.Segment()</p>
650 <p class="whs4">algo1D.NumberOfSegments(4)</p>
652 <p class="whs4">algo2D = mesh.Quadrangle()</p>
654 <p class="whs4"> </p>
656 <p class="whs4">algo_local = mesh.Segment(edge1)</p>
658 <p class="whs4">algo_local.Arithmetic1D(1,
661 <p class="whs4">algo_local.Propagation()</p>
663 <p class="whs4"> </p>
665 <p class="whs4">mesh.Compute()</p>
667 <p class="whs4"> </p>
669 <p class="whs5"># sew free borders</p>
671 <p class="whs5"># FirstNodeID1, SecondNodeID1,
674 <p class="whs5"># FirstNodeID2, SecondNodeID2,
675 LastNodeID2, CreatePolygons, CreatePolyedrs</p>
677 <p class="whs6">mesh.SewFreeBorders(6,
678 21, 5, 1, 12, 3, 0, 0) </p>
680 <h4><a name=bookmark7>Sew Side Elements</a></h4>
682 <p class="whs4">import geompy</p>
684 <p class="whs4">import smesh</p>
686 <p class="whs4"> </p>
688 <p class="whs5"># create two boxes</p>
690 <p class="whs4">box1 = geompy.MakeBox(0.,
694 <p class="whs4">box2 = geompy.MakeBox(0.,
695 15., 0., 20., 25., 10.)</p>
697 <p class="whs4"> </p>
699 <p class="whs4">EdgesList = geompy.SubShapeAll(box2,
700 geompy.ShapeType["EDGE"])</p>
702 <p class="whs4"> </p>
704 <p class="whs4">aComp = geompy.MakeCompound([box1,
707 <p class="whs4">geompy.addToStudy(aComp,
708 "Two boxes")</p>
710 <p class="whs4"> </p>
712 <p class="whs5"># create a mesh on
715 <p class="whs4">mesh = smesh.Mesh(aComp,
716 "Two faces : quadrangle mesh")</p>
718 <p class="whs4"> </p>
720 <p class="whs4">algo1D = mesh.Segment()</p>
722 <p class="whs4">algo1D.NumberOfSegments(2)</p>
724 <p class="whs4">algo2D = mesh.Quadrangle()</p>
726 <p class="whs4"> </p>
728 <p class="whs4">algo_local = mesh.Segment(EdgesList[8])</p>
730 <p class="whs4">algo_local.NumberOfSegments(4)</p>
732 <p class="whs4">algo_local.Propagation()</p>
734 <p class="whs4"> </p>
736 <p class="whs4">mesh.Compute()</p>
738 <p class="whs4"> </p>
740 <p class="whs5"># sew side elements</p>
742 <p class="whs5"># IDsOfSide1Elements,
743 IDsOfSide2Elements,</p>
745 <p class="whs5"># NodeID1OfSide1ToMerge,
746 NodeID1OfSide2ToMerge, NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge</p>
748 <p class="whs4">mesh.SewSideElements([69,
749 70, 71, 72], [91, 92, 89, 90], 8, 38, 23, 58) </p>
751 <script type="text/javascript" language="javascript1.2">
753 if (window.writeIntopicBar)