smesh/doc/salome/gui/SMESH/modifying_meshes.htm

1753 lines
44 KiB
HTML
Raw Normal View History

2007-02-07 17:14:23 +05:00
<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
<html>
<head>
<title>Modifying Meshes</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com"><style>
<!--
P { margin-top:0pt; margin-bottom:0pt; }
LI.kadov-P { }
-->
</style><style type="text/css">
<!--
p.whs1 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }
p.whs2 { margin-top:0pt; margin-bottom:0pt; font-family:'Times New Roman' , serif; }
p.whs3 { margin-top:0pt; margin-bottom:0pt; }
h4.whs4 { margin-top:0pt; margin-bottom:0pt; }
p.whs5 { margin-top:0.5pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }
p.whs6 { margin-top:0.5pt; margin-bottom:0pt; }
p.whs7 { margin-top:0.5pt; margin-bottom:0pt; font-family:'Times New Roman' , serif; }
p.whs8 { font-family:'Lucida Console' , monospace; }
p.whs9 { font-family:'Times New Roman' , serif; }
p.whs10 { margin-left:36px; font-family:'Lucida Console' , monospace; }
p.whs11 { margin-left:36px; }
p.whs12 { margin-left:0px; font-family:'Times New Roman' , serif; }
p.whs13 { font-family:'Lucida Console' , monospace; margin-left:0px; }
-->
</style><script type="text/javascript" language="JavaScript">
<!--
if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
{
var strNSS = "<style type='text/css'>";
strNSS += "p.whs1 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs2 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs3 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "h4.whs4 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs5 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs6 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs7 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs12 {margin-left:1pt; }";
strNSS += "p.whs13 {margin-left:1pt; }";
strNSS +="</style>";
document.write(strNSS);
}
//-->
</script>
<script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
<!--
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();
}
if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
origWidth = innerWidth;
origHeight = innerHeight;
onresize = reDo;
}
onerror = null;
//-->
</script>
<style type="text/css">
<!--
div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
p.WebHelpNavBar { text-align:right; }
-->
</style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
<script type="text/javascript" language="javascript" src="whver.js"></script>
<script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
<script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
<script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
<script type="text/javascript" language="javascript1.2">
<!--
if (window.gbWhTopic)
{
if (window.setRelStartPage)
{
addTocInfo("MESH module\nTUI Scripts\nModifying Meshes");
addButton("show",BTN_IMG,"Show","","","","",0,0,"whd_show0.gif","whd_show2.gif","whd_show1.gif");
addButton("hide",BTN_IMG,"Hide","","","","",0,0,"whd_hide0.gif","whd_hide2.gif","whd_hide1.gif");
}
if (window.setRelStartPage)
{
setRelStartPage("index.htm");
autoSync(1);
sendSyncInfo();
sendAveInfoOut();
}
}
else
if (window.gbIE4)
document.location.reload();
//-->
</script>
</head>
<body><script type="text/javascript" language="javascript1.2">
<!--
if (window.writeIntopicBar)
writeIntopicBar(4);
//-->
</script>
<h1>Modifying Meshes</h1>
<h3><a name=bookmark>Adding Nodes and Elements</a></h3>
<h4>Add Node</h4>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># add node</p>
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">new_id
= mesh.AddNode(50, 10, 0)</span></p>
<p class="whs1">print &quot;&quot;</p>
<p class="whs1">if new_id == 0:
print &quot;KO node addition.&quot;</p>
<p class="whs1">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;New Node has been added with ID &quot;, new_id &nbsp;</p>
<p class="whs1">&nbsp;</p>
<h4>Add Edge</h4>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
<p class="whs1">print &quot;&quot;</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># add node</p>
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">n1
= mesh.AddNode(50, 10, 0)</span></p>
<p class="whs1">if n1 == 0: print
&quot;KO node addition.&quot; </p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># add edge</p>
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">e1
= mesh.AddEdge([n1, 38])</span></p>
<p class="whs1">if e1 == 0: print
&quot;KO edge addition.&quot;</p>
<p class="whs1">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;New Edge has been added with ID &quot;, e1 </p>
<h4>Add Triangle</h4>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
<p class="whs1">print &quot;&quot;</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># add node</p>
<p class="whs1">n1 = mesh.AddNode(50,
10, 0)</p>
<p class="whs1">if n1 == 0: print
&quot;KO node addition.&quot;</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># add triangle</p>
<p class="whs1">t1 = mesh.AddFace([n1,
38, 39])</p>
<p class="whs1">if t1 == 0: print
&quot;KO triangle addition.&quot;</p>
<p class="whs1">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;New Triangle has been added with ID &quot;, t1 </p>
<h4>Add Quadrangle</h4>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
<p class="whs1">print &quot;&quot;</p>
<p class="whs3">&nbsp;</p>
<p class="whs3"># add node</p>
<p class="whs1">n1 = mesh.AddNode(50,
10, 0)</p>
<p class="whs1">if n1 == 0: print
&quot;KO node addition.&quot;</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">n2 = mesh.AddNode(40,
20, 0)</p>
<p class="whs1">if n2 == 0: print
&quot;KO node addition.&quot;</p>
<p class="whs1">&nbsp;</p>
<p class="whs3"># add quadrangle</p>
<p class="whs1">q1 = mesh.AddFace([n2,
n1, 38, 39])</p>
<p class="whs1">if q1 == 0: print
&quot;KO quadrangle addition.&quot;</p>
<p class="whs3"><span style="font-family: 'Lucida Console', monospace;">else:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;New Quadrangle has been added with ID &quot;, q1</span> </p>
<h4>Add Tetrahedron</h4>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
<p class="whs1">print &quot;&quot;</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># add node</p>
<p class="whs1">n1 = mesh.AddNode(50,
10, 0)</p>
<p class="whs1">if n1 == 0: print
&quot;KO node addition.&quot;</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># add tetrahedron</p>
<p class="whs1">t1 = mesh.AddVolume([n1,
38, 39, 246])</p>
<p class="whs1">if t1 == 0: print
&quot;KO tetrahedron addition.&quot;</p>
<p class="whs3"><span style="font-family: 'Lucida Console', monospace;">else:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;New Tetrahedron has been added with ID &quot;, t1</span> </p>
<h4>Add Hexahedron</h4>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
<p class="whs1">print &quot;&quot;</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># add nodes</p>
<p class="whs1">nId1 = mesh.AddNode(50,
10, 0)</p>
<p class="whs1">nId2 = mesh.AddNode(47,
12, 0)</p>
<p class="whs1">nId3 = mesh.AddNode(50,
10, 10)</p>
<p class="whs1">nId4 = mesh.AddNode(47,
12, 10)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">if nId1 == 0 or
nId2 == 0 or nId3 == 0 or nId4 == 0: print &quot;KO node addition.&quot;</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># add hexahedron</p>
<p class="whs1">vId = mesh.AddVolume([nId2,
nId1, 38, 39, nId4, nId3, 245, 246])</p>
<p class="whs1">if vId == 0: print
&quot;KO Hexahedron addition.&quot;</p>
<p class="whs1">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;New Hexahedron has been added with ID &quot;, vId </p>
<p class="whs1">&nbsp;</p>
<h4>Add Polygon</h4>
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
math</span></p>
<p class="whs1">import salome</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">import smesh</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create an empty mesh
structure</p>
<p class="whs1">mesh = smesh.Mesh()
</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># a method to build
a polygonal mesh element with &lt;nb_vert&gt; angles:</p>
<p class="whs1">def MakePolygon
(a_mesh, x0, y0, z0, radius, nb_vert):</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;al
= 2.0 * math.pi / nb_vert</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;node_ids
= []</p>
<p class="whs1">&nbsp;</p>
<p class="whs2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#
Create nodes for a polygon</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;for
ii in range(nb_vert):</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nid
= mesh.AddNode(x0 + radius * math.cos(ii*al),</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;y0
+ radius * math.sin(ii*al),</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z0)</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;node_ids.append(nid)</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass</p>
<p class="whs1">&nbsp;</p>
<p class="whs2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#
Create a polygon</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;return
mesh.AddPolygonalFace(node_ids)</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Create three polygons</p>
<p class="whs1">f1 = MakePolygon(mesh,
0, 0, &nbsp;0,
30, 13)</p>
<p class="whs1">f2 = MakePolygon(mesh,
0, 0, 10, 21, &nbsp;9)</p>
<p class="whs1">f3 = MakePolygon(mesh,
0, 0, 20, 13, &nbsp;6)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">salome.sg.updateObjBrowser(1)
</p>
<h4>Add Polyhedron</h4>
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
salome</span></p>
<p class="whs1">import math</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create an empty mesh
structure</p>
<p class="whs1">mesh = smesh.Mesh()
&nbsp;</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Create nodes for
12-hedron with pentagonal faces</p>
<p class="whs1">al = 2 * math.pi
/ 5.0</p>
<p class="whs1">cosal = math.cos(al)</p>
<p class="whs1">aa = 13</p>
<p class="whs1">rr = aa / (2.0 *
math.sin(al/2.0))</p>
<p class="whs1">dr = 2.0 * rr *
cosal</p>
<p class="whs1">r1 = rr + dr</p>
<p class="whs1">dh = rr * math.sqrt(2.0
* (1.0 - cosal * (1.0 + 2.0 * cosal)))</p>
<p class="whs1">hh = 2.0 * dh -
dr * (rr*(cosal - 1) + (rr + dr)*(math.cos(al/2) - 1)) / dh</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">dd = [] <span style="font-family: 'Times New Roman', serif;">#
top</span></p>
<p class="whs1">cc = [] <span style="font-family: 'Times New Roman', serif;">#
below top</span></p>
<p class="whs1">bb = [] <span style="font-family: 'Times New Roman', serif;">#
above bottom</span></p>
<p class="whs1">aa = [] <span style="font-family: 'Times New Roman', serif;">#
bottom</span></p>
<p class="whs1">&nbsp;</p>
<p class="whs1">for i in range(5):</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;cos_bot
= math.cos(i*al)</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;sin_bot
= math.sin(i*al)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;<span
style="margin-top: 0pt;
margin-bottom: 0pt;
font-family: 'Lucida Console', monospace;">cos_top
= math.cos(i*al + al/2.0)</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;sin_top
= math.sin(i*al + al/2.0)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;nd
= mesh.AddNode(rr * cos_top, rr * sin_top, hh &nbsp;&nbsp;&nbsp;&nbsp;)
<span style="font-family: 'Times New Roman', serif;"># top</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;nc
= mesh.AddNode(r1 * cos_top, r1 * sin_top, hh - dh) <span style="font-family: 'Times New Roman', serif;">#
below top</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;nb
= mesh.AddNode(r1 * cos_bot, r1 * sin_bot, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dh)
<span style="font-family: 'Times New Roman', serif;"># above bottom</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;na
= mesh.AddNode(rr * cos_bot, rr * sin_bot, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0)
<span style="font-family: 'Times New Roman', serif;"># bottom</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;dd.append(nd)
<span style="font-family: 'Times New Roman', serif;"># top</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;cc.append(nc)
<span style="font-family: 'Times New Roman', serif;"># below top</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;bb.append(nb)
<span style="font-family: 'Times New Roman', serif;"># above bottom</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;aa.append(na)
<span style="font-family: 'Times New Roman', serif;"># bottom</span></p>
<p class="whs1">&nbsp;</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;pass</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Create a polyhedral
volume (12-hedron with pentagonal faces)</p>
<p class="whs1">MeshEditor.AddPolyhedralVolume([dd[0],
dd[1], dd[2], dd[3], dd[4], &nbsp;<span style="font-family: 'Times New Roman', serif;">#
top</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dd[0],
cc[0], bb[1], cc[1], dd[1], &nbsp;#
-</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dd[1],
cc[1], bb[2], cc[2], dd[2], &nbsp;#
-</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dd[2],
cc[2], bb[3], cc[3], dd[3], &nbsp;<span style="font-family: 'Times New Roman', serif;">#
- below top</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dd[3],
cc[3], bb[4], cc[4], dd[4], &nbsp;#
-</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dd[4],
cc[4], bb[0], cc[0], dd[0], &nbsp;#
-</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aa[4],
bb[4], cc[4], bb[0], aa[0], &nbsp;#
.</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aa[3],
bb[3], cc[3], bb[4], aa[4], &nbsp;#
.</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aa[2],
bb[2], cc[2], bb[3], aa[3], &nbsp;<span style="font-family: 'Times New Roman', serif;">#
. above bottom</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aa[1],
bb[1], cc[1], bb[2], aa[2], &nbsp;#
.</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aa[0],
bb[0], cc[0], bb[1], aa[1], &nbsp;#
.</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aa[0],
aa[1], aa[2], aa[3], aa[4]], <span style="font-family: 'Times New Roman', serif;">#
bottom</span></p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[5,5,5,5,5,5,5,5,5,5,5,5])</p>
<p class="whs1">salome.sg.updateObjBrowser(1)
</p>
<p class="whs1">&nbsp;</p>
<h3><a name=bookmark1>Removing Nodes and Elements</a></h3>
<h4 class="whs4">Removing Nodes</h4>
<p class="whs3">&nbsp;</p>
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
SMESH_mechanic</span></p>
<p class="whs1">&nbsp;</p>
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># remove nodes #246
and #255</p>
<p class="whs1">res = mesh.RemoveNodes([246,
255])</p>
<p class="whs1">if res == 1: print
&quot;Nodes removing is OK!&quot;</p>
<p class="whs1">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;KO nodes removing.&quot; </p>
<p class="whs3">&nbsp;</p>
<h4>Removing Elements</h4>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># remove three elements:
#850, #859 and #814</p>
<p class="whs1">res = mesh.RemoveElements([850,
859, 814])</p>
<p class="whs1">if res == 1: print
&quot;Elements removing is OK!&quot;</p>
<p class="whs1">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;KO Elements removing.&quot; &nbsp;</p>
<p class="whs1">&nbsp;</p>
<h3><a name=bookmark2>Renumbering Nodes and Elements</a></h3>
<p class="whs5">import SMESH_mechanic</p>
<p class="whs5">&nbsp;</p>
<p class="whs5">mesh = SMESH_mechanic.mesh</p>
<p class="whs6">&nbsp;</p>
<p class="whs6"><span style="font-family: 'Lucida Console', monospace;">mesh.RenumberNodes()</span>
</p>
<h3><a name=bookmark3>Moving Nodes</a></h3>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
<p class="whs3">&nbsp;</p>
<p class="whs3"># move node #38</p>
<p class="whs1">mesh.MoveNode(38,
20., 10., 0.) </p>
<p class="whs3">&nbsp;</p>
<h3><a name=bookmark4>Diagonal Inversion</a></h3>
<p class="whs5">import salome</p>
<p class="whs5">import smesh</p>
<p class="whs5">&nbsp;</p>
<p class="whs7"># create an empty mesh
structure</p>
<p class="whs5">mesh = smesh.Mesh()
</p>
<p class="whs5">&nbsp;</p>
<p class="whs7"># create the following
mesh:</p>
<p class="whs5"># .----.----.----.</p>
<p class="whs5"># | &nbsp;&nbsp;/|
&nbsp;&nbsp;/|
&nbsp;&nbsp;/|</p>
<p class="whs5"># | &nbsp;/
| &nbsp;/ | &nbsp;/
|</p>
<p class="whs5"># | / &nbsp;|
/ &nbsp;| / &nbsp;|</p>
<p class="whs5"># |/ &nbsp;&nbsp;|/
&nbsp;&nbsp;|/
&nbsp;&nbsp;|</p>
<p class="whs5"># .----.----.----.</p>
<p class="whs5">&nbsp;</p>
<p class="whs5">bb = [0, 0, 0, 0]</p>
<p class="whs5">tt = [0, 0, 0, 0]</p>
<p class="whs5">ff = [0, 0, 0, 0,
0, 0]</p>
<p class="whs5">&nbsp;</p>
<p class="whs5">bb[0] = mesh.AddNode(
0., 0., 0.)</p>
<p class="whs5">bb[1] = mesh.AddNode(10.,
0., 0.)</p>
<p class="whs5">bb[2] = mesh.AddNode(20.,
0., 0.)</p>
<p class="whs5">bb[3] = mesh.AddNode(30.,
0., 0.)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5">tt[0] = mesh.AddNode(
0., 15., 0.)</p>
<p class="whs5">tt[1] = mesh.AddNode(10.,
15., 0.)</p>
<p class="whs5">tt[2] = mesh.AddNode(20.,
15., 0.)</p>
<p class="whs5">tt[3] = mesh.AddNode(30.,
15., 0.)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5">ff[0] = mesh.AddFace([bb[0],
bb[1], tt[1]])</p>
<p class="whs5">ff[1] = mesh.AddFace([bb[0],
tt[1], tt[0]])</p>
<p class="whs5">ff[2] = mesh.AddFace([bb[1],
bb[2], tt[2]])</p>
<p class="whs5">ff[3] = mesh.AddFace([bb[1],
tt[2], tt[1]])</p>
<p class="whs5">ff[4] = mesh.AddFace([bb[2],
bb[3], tt[3]])</p>
<p class="whs5">ff[5] = mesh.AddFace([bb[2],
tt[3], tt[2]])</p>
<p class="whs5">&nbsp;</p>
<p class="whs7"># inverse the diagonal
bb[1] - tt[2]</p>
<p class="whs5">print &quot;\nDiagonal
inversion ... &quot;,</p>
<p class="whs5">res = mesh.InverseDiag(bb[1],
tt[2])</p>
<p class="whs5">if not res: print
&quot;failed!&quot;</p>
<p class="whs5">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;done.&quot;</p>
<p class="whs6">&nbsp;</p>
<p class="whs6"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
</p>
<h3><a name=bookmark5>Uniting two Triangles</a></h3>
<p class="whs8">import salome</p>
<p class="whs8">import smesh</p>
<p>&nbsp;</p>
<p># create an empty mesh structure</p>
<p class="whs8">mesh = smesh.Mesh()
</p>
<p>&nbsp;</p>
<p># create the following mesh:</p>
<p class="whs8"># .----.----.----.</p>
<p class="whs8"># | &nbsp;&nbsp;/|
&nbsp;&nbsp;/|
&nbsp;&nbsp;/|</p>
<p class="whs8"># | &nbsp;/
| &nbsp;/ | &nbsp;/
|</p>
<p class="whs8"># | / &nbsp;|
/ &nbsp;| / &nbsp;|</p>
<p class="whs8"># |/ &nbsp;&nbsp;|/
&nbsp;&nbsp;|/
&nbsp;&nbsp;|</p>
<p class="whs8"># .----.----.----.</p>
<p>&nbsp;</p>
<p class="whs8">bb = [0, 0, 0, 0]</p>
<p class="whs8">tt = [0, 0, 0, 0]</p>
<p class="whs8">ff = [0, 0, 0, 0,
0, 0]</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">bb[0]
= mesh.AddNode( 0., 0., 0.)</span></p>
<p class="whs8">bb[1] = mesh.AddNode(10.,
0., 0.)</p>
<p class="whs8">bb[2] = mesh.AddNode(20.,
0., 0.)</p>
<p class="whs8">bb[3] = mesh.AddNode(30.,
0., 0.)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">tt[0] = mesh.AddNode(
0., 15., 0.)</p>
<p class="whs8">tt[1] = mesh.AddNode(10.,
15., 0.)</p>
<p class="whs8">tt[2] = mesh.AddNode(20.,
15., 0.)</p>
<p class="whs8">tt[3] = mesh.AddNode(30.,
15., 0.)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">ff[0] = mesh.AddFace([bb[0],
bb[1], tt[1]])</p>
<p class="whs8">ff[1] = mesh.AddFace([bb[0],
tt[1], tt[0]])</p>
<p class="whs8">ff[2] = mesh.AddFace([bb[1],
bb[2], tt[2]])</p>
<p class="whs8">ff[3] = mesh.AddFace([bb[1],
tt[2], tt[1]])</p>
<p class="whs8">ff[4] = mesh.AddFace([bb[2],
bb[3], tt[3]])</p>
<p class="whs8">ff[5] = mesh.AddFace([bb[2],
tt[3], tt[2]]) </p>
<p>&nbsp;</p>
<p># delete the diagonal bb[1] - tt[2]</p>
<p class="whs8">print &quot;\nUnite
two triangles ... &quot;,</p>
<p class="whs8">res = mesh.DeleteDiag(bb[1],
tt[2])</p>
<p class="whs8">if not res: print
&quot;failed!&quot;</p>
<p class="whs8">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;done.&quot;</p>
<p class="whs8">&nbsp;</p>
<p><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
</p>
<h3><a name=bookmark6>Uniting a Set of Triangles</a></h3>
<p class="whs8">import salome</p>
<p class="whs8">import smesh</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># create an empty mesh
structure</p>
<p class="whs8">mesh = smesh.Mesh()
</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># create the following
mesh:</p>
<p class="whs8"># .----.----.----.</p>
<p class="whs8"># | &nbsp;&nbsp;/|
&nbsp;&nbsp;/|
&nbsp;&nbsp;/|</p>
<p class="whs8"># | &nbsp;/
| &nbsp;/ | &nbsp;/
|</p>
<p class="whs8"># | / &nbsp;|
/ &nbsp;| / &nbsp;|</p>
<p class="whs8"># |/ &nbsp;&nbsp;|/
&nbsp;&nbsp;|/
&nbsp;&nbsp;|</p>
<p class="whs8"># .----.----.----.</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">bb = [0, 0, 0, 0]</p>
<p class="whs8">tt = [0, 0, 0, 0]</p>
<p class="whs8">ff = [0, 0, 0, 0,
0, 0]</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">bb[0]
= mesh.AddNode( 0., 0., 0.)</span></p>
<p class="whs8">bb[1] = mesh.AddNode(10.,
0., 0.)</p>
<p class="whs8">bb[2] = mesh.AddNode(20.,
0., 0.)</p>
<p class="whs8">bb[3] = mesh.AddNode(30.,
0., 0.)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">tt[0] = mesh.AddNode(
0., 15., 0.)</p>
<p class="whs8">tt[1] = mesh.AddNode(10.,
15., 0.)</p>
<p class="whs8">tt[2] = mesh.AddNode(20.,
15., 0.)</p>
<p class="whs8">tt[3] = mesh.AddNode(30.,
15., 0.)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">ff[0] = mesh.AddFace([bb[0],
bb[1], tt[1]])</p>
<p class="whs8">ff[1] = mesh.AddFace([bb[0],
tt[1], tt[0]])</p>
<p class="whs8">ff[2] = mesh.AddFace([bb[1],
bb[2], tt[2]])</p>
<p class="whs8">ff[3] = mesh.AddFace([bb[1],
tt[2], tt[1]])</p>
<p class="whs8">ff[4] = mesh.AddFace([bb[2],
bb[3], tt[3]])</p>
<p class="whs8">ff[5] = mesh.AddFace([bb[2],
tt[3], tt[2]])</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># unite a set of triangles</p>
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">print
&quot;\nUnite a set of triangles ... &quot;,</span></p>
<p class="whs8">res = mesh.TriToQuad([ff[2],
ff[3], ff[4], ff[5]], smesh.FT_MinimumAngle, 60.)</p>
<p class="whs8">if not res: print
&quot;failed!&quot;</p>
<p class="whs8">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;done.&quot;</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">salome.sg.updateObjBrowser(1)
&nbsp;</p>
<h3><a name=bookmark12>Orientation</a></h3>
<p class="whs8">import salome</p>
<p class="whs8">import smesh</p>
<p class="whs8">&nbsp;</p>
<p># create an empty mesh structure</p>
<p class="whs8">mesh = smesh.Mesh()
</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># build five quadrangles:</p>
<p class="whs8">dx = 10</p>
<p class="whs8">dy = 20</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">n1
&nbsp;= mesh.AddNode(0.0
* dx, 0, 0)</span></p>
<p class="whs8">n2 &nbsp;=
mesh.AddNode(1.0 * dx, 0, 0)</p>
<p class="whs8">n3 &nbsp;=
mesh.AddNode(2.0 * dx, 0, 0)</p>
<p class="whs8">n4 &nbsp;=
mesh.AddNode(3.0 * dx, 0, 0)</p>
<p class="whs8">n5 &nbsp;=
mesh.AddNode(4.0 * dx, 0, 0)</p>
<p class="whs8">n6 &nbsp;=
mesh.AddNode(5.0 * dx, 0, 0)</p>
<p class="whs8">n7 &nbsp;=
mesh.AddNode(0.0 * dx, dy, 0)</p>
<p class="whs8">n8 &nbsp;=
mesh.AddNode(1.0 * dx, dy, 0)</p>
<p class="whs8">n9 &nbsp;=
mesh.AddNode(2.0 * dx, dy, 0)</p>
<p class="whs8">n10 = mesh.AddNode(3.0
* dx, dy, 0)</p>
<p class="whs8">n11 = mesh.AddNode(4.0
* dx, dy, 0)</p>
<p class="whs8">n12 = mesh.AddNode(5.0
* dx, dy, 0)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">f1 = mesh.AddFace([n1,
n2, n8 , n7 ])</p>
<p class="whs8">f2 = mesh.AddFace([n2,
n3, n9 , n8 ])</p>
<p class="whs8">f3 = mesh.AddFace([n3,
n4, n10, n9 ])</p>
<p class="whs8">f4 = mesh.AddFace([n4,
n5, n11, n10])</p>
<p class="whs8">f5 = mesh.AddFace([n5,
n6, n12, n11]) </p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># Change the orientation
of the second and the fourth faces.</p>
<p class="whs8">mesh.Reorient([2,
4])</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">salome.sg.updateObjBrowser(1)
</p>
<p class="whs8">&nbsp;</p>
<h3><a name=bookmark7>Cutting Quadrangles</a></h3>
<p class="whs8">import SMESH_mechanic</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">smesh = SMESH_mechanic.smesh</p>
<p class="whs8">mesh &nbsp;=
SMESH_mechanic.mesh</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># cut two quadrangles:
405 and 406</p>
<p class="whs8">mesh.QuadToTri([405,
406], smesh.FT_MinimumAngle) &nbsp;</p>
<p class="whs9">&nbsp;</p>
<h3><a name=bookmark8>Smoothing</a></h3>
<p class="whs8">import salome</p>
<p class="whs8">import geompy</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">import SMESH_mechanic</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">smesh
= SMESH_mechanic.smesh</span></p>
<p class="whs8">mesh = SMESH_mechanic.mesh</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># select the top face</p>
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">faces
= geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, geompy.ShapeType[&quot;FACE&quot;])</span></p>
<p class="whs8">face = faces[3]</p>
<p class="whs8">geompy.addToStudyInFather(SMESH_mechanic.shape_mesh,
face, &quot;face planar with hole&quot;)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"># create a group of
faces to be smoothed</p>
<p class="whs8">GroupSmooth = mesh.GroupOnGeom(face,
&quot;Group of faces (smooth)&quot;, smesh.FACE)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"># perform smoothing</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"># boolean SmoothObject(Object,
IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method)</p>
<p class="whs8">res = mesh.SmoothObject(GroupSmooth,
[], 20, 2., smesh.CENTROIDAL_SMOOTH)</p>
<p class="whs8">print &quot;\nSmoothing
... &quot;,</p>
<p class="whs8">if not res: print
&quot;failed!&quot;</p>
<p class="whs8">else: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;done.&quot;</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">salome.sg.updateObjBrowser(1)
</p>
<p class="whs8">&nbsp;</p>
<h3><a name=bookmark9>Extrusion</a></h3>
<p class="whs8">import salome</p>
<p class="whs8">import geompy</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">import SMESH_mechanic</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">smesh
= SMESH_mechanic.smesh</span></p>
<p class="whs8">mesh = SMESH_mechanic.mesh
</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># select the top face</p>
<p class="whs8">faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh,
geompy.ShapeType[&quot;FACE&quot;])</p>
<p class="whs8">face = faces[7]</p>
<p class="whs8">geompy.addToStudyInFather(SMESH_mechanic.shape_mesh,
face, &quot;face circular top&quot;)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"># create a vector
for extrusion</p>
<p class="whs8">point = smesh.PointStruct(0.,
0., 5.)</p>
<p class="whs8">vector = smesh.DirStruct(point)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"># create a group to
be extruded</p>
<p class="whs8">GroupTri = mesh.GroupOnGeom(face,
&quot;Group of faces (extrusion)&quot;, smesh.FACE)</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"># perform extrusion
of the group</p>
<p class="whs8">mesh.ExtrusionSweepObject(GroupTri,
vector, 5)</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
</p>
<h3><a name=bookmark10>Extrusion along a Path</a></h3>
<p class="whs8">import math</p>
<p class="whs8">import salome</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># Geometry</p>
<p class="whs8">import geompy</p>
<p class="whs9">&nbsp;</p>
<p class="whs9"># 1. Create points</p>
<p class="whs8">points = [[0, 0],
[50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]]</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">iv = 1</p>
<p class="whs8">vertices = []</p>
<p class="whs8">for point in points:</p>
<p class="whs10">vert
= geompy.MakeVertex(point[0], point[1], 0)</p>
<p class="whs10">geompy.addToStudy(vert,
&quot;Vertex_&quot; + `iv`)</p>
<p class="whs10">vertices.append(vert)</p>
<p class="whs10">iv
+= 1</p>
<p class="whs10">pass</p>
<p class="whs9">&nbsp;</p>
<p class="whs9"># 2. Create edges and
wires</p>
<p class="whs8">Edge_straight = geompy.MakeEdge(vertices[0],
vertices[4])</p>
<p class="whs8">Edge_bezierrr = geompy.MakeBezier(vertices)</p>
<p class="whs8">Wire_polyline = geompy.MakePolyline(vertices)</p>
<p class="whs8">Edge_Circle &nbsp;&nbsp;=
geompy.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2])</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">geompy.addToStudy(Edge_straight,
&quot;Edge_straight&quot;)</p>
<p class="whs8">geompy.addToStudy(Edge_bezierrr,
&quot;Edge_bezierrr&quot;)</p>
<p class="whs8">geompy.addToStudy(Wire_polyline,
&quot;Wire_polyline&quot;)</p>
<p class="whs8">geompy.addToStudy(Edge_Circle
&nbsp;, &quot;Edge_Circle&quot;)</p>
<p class="whs9">&nbsp;</p>
<p class="whs9"># 3. Explode wire on
edges, as they will be used for mesh extrusion</p>
<p class="whs8">Wire_polyline_edges
= geompy.SubShapeAll(Wire_polyline, geompy.ShapeType[&quot;EDGE&quot;])</p>
<p class="whs8">for ii in range(len(Wire_polyline_edges)):</p>
<p class="whs10">geompy.addToStudyInFather(Wire_polyline,
Wire_polyline_edges[ii], &quot;Edge_&quot; + `ii + 1`)</p>
<p class="whs10">pass</p>
<p class="whs11">&nbsp;</p>
<p class="whs9"># Mesh</p>
<p class="whs8">import smesh</p>
<p class="whs8">&nbsp;</p>
<p class="whs12"># Mesh
the given shape with the given 1d hypothesis</p>
<p class="whs13">def
Mesh1D(shape1d, nbSeg, name):</p>
<p class="whs13">&nbsp;&nbsp;mesh1d_tool
= smesh.Mesh(shape1d, name)</p>
<p class="whs13">&nbsp;&nbsp;algo
= mesh1d_tool.Segment()</p>
<p class="whs13">&nbsp;&nbsp;hyp
&nbsp;= algo.NumberOfSegments(nbSeg)</p>
<p class="whs13">&nbsp;&nbsp;isDone
= mesh1d_tool.Compute()</p>
<p class="whs13">&nbsp;&nbsp;if
not isDone: print 'Mesh ', name, ': computation failed'</p>
<p class="whs13">&nbsp;&nbsp;return
mesh1d_tool</p>
<p class="whs12"># Create
a mesh with six nodes, seven edges and two quadrangle faces</p>
<p class="whs13">def
MakeQuadMesh2(mesh_name):</p>
<p class="whs13">&nbsp;&nbsp;quad_1
= smesh.Mesh(name = mesh_name)</p>
<p class="whs13">&nbsp;&nbsp;</p>
<p class="whs13">&nbsp;&nbsp;<span
style="font-family: 'Times New Roman', serif;">#
six nodes</span></p>
<p class="whs13">&nbsp;&nbsp;n1
= quad_1.AddNode(0, 20, 10)</p>
<p class="whs13">&nbsp;&nbsp;n2
= quad_1.AddNode(0, 40, 10)</p>
<p class="whs13">&nbsp;&nbsp;n3
= quad_1.AddNode(0, 40, 30)</p>
<p class="whs13">&nbsp;&nbsp;n4
= quad_1.AddNode(0, 20, 30)</p>
<p class="whs13">&nbsp;&nbsp;n5
= quad_1.AddNode(0, &nbsp;0,
30)</p>
<p class="whs13">&nbsp;&nbsp;n6
= quad_1.AddNode(0, &nbsp;0,
10)</p>
<p class="whs13">&nbsp;&nbsp;</p>
<p class="whs13">&nbsp;&nbsp;<span
style="font-family: 'Times New Roman', serif;">#
seven edges</span></p>
<p class="whs13">&nbsp;&nbsp;quad_1.AddEdge([n1,
n2]) # 1</p>
<p class="whs13">&nbsp;&nbsp;quad_1.AddEdge([n2,
n3]) # 2</p>
<p class="whs13">&nbsp;&nbsp;quad_1.AddEdge([n3,
n4]) # 3</p>
<p class="whs13">&nbsp;&nbsp;quad_1.AddEdge([n4,
n1]) # 4</p>
<p class="whs13">&nbsp;&nbsp;quad_1.AddEdge([n4,
n5]) # 5</p>
<p class="whs13">&nbsp;&nbsp;quad_1.AddEdge([n5,
n6]) # 6</p>
<p class="whs13">&nbsp;&nbsp;quad_1.AddEdge([n6,
n1]) # 7</p>
<p class="whs13">&nbsp;</p>
<p class="whs13">&nbsp;&nbsp;<span
style="font-family: 'Times New Roman', serif;">#
two quadrangle faces</span></p>
<p class="whs13">&nbsp;&nbsp;quad_1.AddFace([n1,
n2, n3, n4]) # 8</p>
<p class="whs13">&nbsp;&nbsp;quad_1.AddFace([n1,
n4, n5, n6]) # 9</p>
<p class="whs13">&nbsp;&nbsp;return
[quad_1, [1,2,3,4,5,6,7], [8,9]]</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># Path
meshes</p>
<p class="whs13">Edge_straight_mesh
= Mesh1D(Edge_straight, 7, &quot;Edge_straight&quot;)</p>
<p class="whs13">Edge_bezierrr_mesh
= Mesh1D(Edge_bezierrr, 7, &quot;Edge_bezierrr&quot;)</p>
<p class="whs13">Wire_polyline_mesh
= Mesh1D(Wire_polyline, 3, &quot;Wire_polyline&quot;)</p>
<p class="whs13">Edge_Circle_mesh
&nbsp;&nbsp;=
Mesh1D(Edge_Circle &nbsp;,
8, &quot;Edge_Circle&quot;)</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># Initial
meshes (to be extruded)</p>
<p class="whs13">[quad_1,
ee_1, ff_1] = MakeQuadMesh2(&quot;quad_1&quot;)</p>
<p class="whs13">[quad_2,
ee_2, ff_2] = MakeQuadMesh2(&quot;quad_2&quot;)</p>
<p class="whs13">[quad_3,
ee_3, ff_3] = MakeQuadMesh2(&quot;quad_3&quot;)</p>
<p class="whs13">[quad_4,
ee_4, ff_4] = MakeQuadMesh2(&quot;quad_4&quot;)</p>
<p class="whs13">[quad_5,
ee_5, ff_5] = MakeQuadMesh2(&quot;quad_5&quot;)</p>
<p class="whs13">[quad_6,
ee_6, ff_6] = MakeQuadMesh2(&quot;quad_6&quot;)</p>
<p class="whs13">[quad_7,
ee_7, ff_7] = MakeQuadMesh2(&quot;quad_7&quot;)</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># ExtrusionAlongPath</p>
<p class="whs12"># IDsOfElements,
PathMesh, PathShape, NodeStart,</p>
<p class="whs12"># HasAngles,
Angles, HasRefPoint, RefPoint</p>
<p class="whs13">refPoint
= smesh.PointStruct(0, 0, 0)</p>
<p class="whs13">a10
= 10.0*math.pi/180.0</p>
<p class="whs13">a45
= 45.0*math.pi/180.0</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># 1.
Extrusion of two mesh edges along a straight path</p>
<p class="whs13">error
= quad_1.ExtrusionAlongPath([1,2], Edge_straight_mesh, Edge_straight,
1,</p>
<p class="whs13">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,
[], 0, refPoint)</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># 2.
Extrusion of one mesh edge along a curved path</p>
<p class="whs13">error
= quad_2.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1,</p>
<p class="whs13">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,
[], 0, refPoint)</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># 3.
Extrusion of one mesh edge along a curved path with usage of angles</p>
<p class="whs13">error
= quad_3.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1,</p>
<p class="whs13">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1,
[a45, a45, a45, 0, -a45, -a45, -a45], 0, refPoint)</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># 4.
Extrusion of one mesh edge along the path, which is a part of a meshed
wire</p>
<p class="whs13">error
= quad_4.ExtrusionAlongPath([4], Wire_polyline_mesh, Wire_polyline_edges[0],
1,</p>
<p class="whs13">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1,
[a10, a10, a10], 0, refPoint)</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># 5.
Extrusion of two mesh faces along the path, which is a part of a meshed
wire</p>
<p class="whs13">error
= quad_5.ExtrusionAlongPath(ff_5 , Wire_polyline_mesh, Wire_polyline_edges[2],
4,</p>
<p class="whs13">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,
[], 0, refPoint)</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># 6.
Extrusion of two mesh faces along a closed path</p>
<p class="whs13">error
= quad_6.ExtrusionAlongPath(ff_6 , Edge_Circle_mesh, Edge_Circle, 1,</p>
<p class="whs13">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,
[], 0, refPoint)</p>
<p class="whs13">&nbsp;</p>
<p class="whs12"># 7.
Extrusion of two mesh faces along a closed path with usage of angles</p>
<p class="whs13">error
= quad_7.ExtrusionAlongPath(ff_7, Edge_Circle_mesh, Edge_Circle, 1,</p>
<p class="whs13">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1,
[a45, -a45, a45, -a45, a45, -a45, a45, -a45], 0, refPoint)</p>
<p class="whs13">&nbsp;</p>
<p class="whs13">salome.sg.updateObjBrowser(1)
</p>
<h3><a name=bookmark11>Revolution</a></h3>
<p class="whs8">import math</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">import SMESH_mechanic</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">mesh
&nbsp;= SMESH_mechanic.mesh</span></p>
<p class="whs8">smesh = SMESH_mechanic.smesh</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># create a group of faces
to be revolved</p>
<p class="whs8">FacesRotate = [492,
493, 502, 503]</p>
<p class="whs8">GroupRotate = mesh.CreateGroup(SMESH.FACE,&quot;Group
of faces (rotate)&quot;)</p>
<p class="whs8">GroupRotate.Add(FacesRotate)</p>
<p class="whs9">&nbsp;</p>
<p class="whs9"># define revolution angle
and axis</p>
<p class="whs8">angle45 = 45 * math.pi
/ 180</p>
<p class="whs8">axisXYZ = SMESH.AxisStruct(-38.3128,
-73.3658, -23.321, -13.3402, -13.3265, 6.66632)</p>
<p class="whs8">&nbsp;</p>
<p class="whs9"># perform revolution
of an object</p>
<p class="whs8">mesh.RotationSweepObject(GroupRotate,
axisXYZ, angle45, 4, 1e-5) </p>
<p class="whs9">&nbsp;</p>
<h3><a name=bookmark13>Pattern Mapping</a></h3>
<p class="whs8">import geompy</p>
<p class="whs8">&nbsp;</p>
<p class="whs8">import smesh</p>
<p class="whs8">&nbsp;</p>
<p class="whs8"># define the geometry</p>
<p class="whs9">Box_1 = geompy.MakeBoxDXDYDZ(200.,
200., 200.)</p>
<p class="whs9">geompy.addToStudy(Box_1,
&quot;Box_1&quot;)</p>
<p class="whs9">&nbsp;</p>
<p class="whs9">faces = geompy.SubShapeAll(Box_1,
geompy.ShapeType[&quot;FACE&quot;])</p>
<p class="whs9">Face_1 = faces[0]</p>
<p class="whs9">Face_2 = faces[1]</p>
<p class="whs9">&nbsp;</p>
<p class="whs9">geompy.addToStudyInFather(Box_1,
Face_1, &quot;Face_1&quot;)</p>
<p class="whs9">geompy.addToStudyInFather(Box_1,
Face_2, &quot;Face_2&quot;)</p>
<p class="whs9">&nbsp;</p>
<p class="whs8"># build a quadrangle
mesh 3x3 on Face_1</p>
<p class="whs9">Mesh_1 = smesh.Mesh(Face_1)</p>
<p class="whs9">algo1D = Mesh_1.Segment()</p>
<p class="whs9">algo1D.NumberOfSegments(3)</p>
<p class="whs9">Mesh_1.Quadrangle()</p>
<p class="whs9">&nbsp;</p>
<p class="whs9">isDone = Mesh_1.Compute()</p>
<p class="whs9">if not isDone: print
'Mesh Mesh_1 : computation failed'</p>
<p class="whs9">&nbsp;</p>
<p class="whs8"># build a triangle
mesh on Face_2</p>
<p class="whs9">Mesh_2 = smesh.Mesh(Face_2)</p>
<p class="whs9">&nbsp;</p>
<p class="whs9">algo1D = Mesh_2.Segment()</p>
<p class="whs9">algo1D.NumberOfSegments(1)</p>
<p class="whs9">algo2D = Mesh_2.Triangle()</p>
<p class="whs9">algo2D.MaxElementArea(240)</p>
<p class="whs9">&nbsp;</p>
<p class="whs9">isDone = Mesh_2.Compute()</p>
<p class="whs9">if not isDone: print
'Mesh Mesh_2 : computation failed'</p>
<p class="whs9">&nbsp;</p>
<p class="whs8"># create a pattern</p>
<p class="whs9">pattern = smesh.GetPattern()</p>
<p class="whs9">&nbsp;</p>
<p class="whs9">isDone = pattern.LoadFromFace(Mesh_2.GetMesh(),
Face_2, 0)</p>
<p class="whs9">if (isDone != 1): print
'LoadFromFace :', pattern.GetErrorCode()</p>
<p class="whs9">&nbsp;</p>
<p class="whs8"># apply the pattern
to a face of the first mesh</p>
<p class="whs9">pattern.ApplyToMeshFaces(Mesh_1.GetMesh(),
[17], 0, 0)</p>
<p class="whs9">&nbsp;</p>
<p class="whs9">isDone = pattern.MakeMesh(Mesh_1.GetMesh(),
0, 0)</p>
<p class="whs9">if (isDone != 1): print
'MakeMesh :', pattern.GetErrorCode() &nbsp;</p>
<script type="text/javascript" language="javascript1.2">
<!--
if (window.writeIntopicBar)
writeIntopicBar(0);
//-->
</script>
</body>
</html>