mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-16 10:38:33 +05:00
1753 lines
44 KiB
HTML
Executable File
1753 lines
44 KiB
HTML
Executable File
<!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"> </p>
|
|
|
|
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1"> </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 ""</p>
|
|
|
|
<p class="whs1">if new_id == 0:
|
|
print "KO node addition."</p>
|
|
|
|
<p class="whs1">else: print
|
|
"New Node has been added with ID ", new_id </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h4>Add Edge</h4>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">print ""</p>
|
|
|
|
<p class="whs1"> </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
|
|
"KO node addition." </p>
|
|
|
|
<p class="whs1"> </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
|
|
"KO edge addition."</p>
|
|
|
|
<p class="whs1">else: print
|
|
"New Edge has been added with ID ", e1 </p>
|
|
|
|
<h4>Add Triangle</h4>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">print ""</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add node</p>
|
|
|
|
<p class="whs1">n1 = mesh.AddNode(50,
|
|
10, 0)</p>
|
|
|
|
<p class="whs1">if n1 == 0: print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add triangle</p>
|
|
|
|
<p class="whs1">t1 = mesh.AddFace([n1,
|
|
38, 39])</p>
|
|
|
|
<p class="whs1">if t1 == 0: print
|
|
"KO triangle addition."</p>
|
|
|
|
<p class="whs1">else: print
|
|
"New Triangle has been added with ID ", t1 </p>
|
|
|
|
<h4>Add Quadrangle</h4>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">print ""</p>
|
|
|
|
<p class="whs3"> </p>
|
|
|
|
<p class="whs3"># add node</p>
|
|
|
|
<p class="whs1">n1 = mesh.AddNode(50,
|
|
10, 0)</p>
|
|
|
|
<p class="whs1">if n1 == 0: print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">n2 = mesh.AddNode(40,
|
|
20, 0)</p>
|
|
|
|
<p class="whs1">if n2 == 0: print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1"> </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
|
|
"KO quadrangle addition."</p>
|
|
|
|
<p class="whs3"><span style="font-family: 'Lucida Console', monospace;">else:
|
|
print
|
|
"New Quadrangle has been added with ID ", q1</span> </p>
|
|
|
|
<h4>Add Tetrahedron</h4>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">print ""</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add node</p>
|
|
|
|
<p class="whs1">n1 = mesh.AddNode(50,
|
|
10, 0)</p>
|
|
|
|
<p class="whs1">if n1 == 0: print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1"> </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
|
|
"KO tetrahedron addition."</p>
|
|
|
|
<p class="whs3"><span style="font-family: 'Lucida Console', monospace;">else:
|
|
print
|
|
"New Tetrahedron has been added with ID ", t1</span> </p>
|
|
|
|
<h4>Add Hexahedron</h4>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">print ""</p>
|
|
|
|
<p class="whs1"> </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"> </p>
|
|
|
|
<p class="whs1">if nId1 == 0 or
|
|
nId2 == 0 or nId3 == 0 or nId4 == 0: print "KO node addition."</p>
|
|
|
|
<p class="whs1"> </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
|
|
"KO Hexahedron addition."</p>
|
|
|
|
<p class="whs1">else: print
|
|
"New Hexahedron has been added with ID ", vId </p>
|
|
|
|
<p class="whs1"> </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"> </p>
|
|
|
|
<p class="whs1">import smesh</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># create an empty mesh
|
|
structure</p>
|
|
|
|
<p class="whs1">mesh = smesh.Mesh()
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># a method to build
|
|
a polygonal mesh element with <nb_vert> angles:</p>
|
|
|
|
<p class="whs1">def MakePolygon
|
|
(a_mesh, x0, y0, z0, radius, nb_vert):</p>
|
|
|
|
<p class="whs1"> al
|
|
= 2.0 * math.pi / nb_vert</p>
|
|
|
|
<p class="whs1"> node_ids
|
|
= []</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"> #
|
|
Create nodes for a polygon</p>
|
|
|
|
<p class="whs1"> for
|
|
ii in range(nb_vert):</p>
|
|
|
|
<p class="whs1"> nid
|
|
= mesh.AddNode(x0 + radius * math.cos(ii*al),</p>
|
|
|
|
<p class="whs1"> y0
|
|
+ radius * math.sin(ii*al),</p>
|
|
|
|
<p class="whs1"> z0)</p>
|
|
|
|
<p class="whs1"> node_ids.append(nid)</p>
|
|
|
|
<p class="whs1"> pass</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"> #
|
|
Create a polygon</p>
|
|
|
|
<p class="whs1"> return
|
|
mesh.AddPolygonalFace(node_ids)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># Create three polygons</p>
|
|
|
|
<p class="whs1">f1 = MakePolygon(mesh,
|
|
0, 0, 0,
|
|
30, 13)</p>
|
|
|
|
<p class="whs1">f2 = MakePolygon(mesh,
|
|
0, 0, 10, 21, 9)</p>
|
|
|
|
<p class="whs1">f3 = MakePolygon(mesh,
|
|
0, 0, 20, 13, 6)</p>
|
|
|
|
<p class="whs1"> </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"> </p>
|
|
|
|
<p class="whs2"># create an empty mesh
|
|
structure</p>
|
|
|
|
<p class="whs1">mesh = smesh.Mesh()
|
|
</p>
|
|
|
|
<p class="whs1"> </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"> </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"> </p>
|
|
|
|
<p class="whs1">for i in range(5):</p>
|
|
|
|
<p class="whs1"> cos_bot
|
|
= math.cos(i*al)</p>
|
|
|
|
<p class="whs1"> sin_bot
|
|
= math.sin(i*al)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1"> <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"> sin_top
|
|
= math.sin(i*al + al/2.0)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1"> nd
|
|
= mesh.AddNode(rr * cos_top, rr * sin_top, hh )
|
|
<span style="font-family: 'Times New Roman', serif;"># top</span></p>
|
|
|
|
<p class="whs1"> 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"> nb
|
|
= mesh.AddNode(r1 * cos_bot, r1 * sin_bot, dh)
|
|
<span style="font-family: 'Times New Roman', serif;"># above bottom</span></p>
|
|
|
|
<p class="whs1"> na
|
|
= mesh.AddNode(rr * cos_bot, rr * sin_bot, 0)
|
|
<span style="font-family: 'Times New Roman', serif;"># bottom</span></p>
|
|
|
|
<p class="whs1"> dd.append(nd)
|
|
<span style="font-family: 'Times New Roman', serif;"># top</span></p>
|
|
|
|
<p class="whs1"> cc.append(nc)
|
|
<span style="font-family: 'Times New Roman', serif;"># below top</span></p>
|
|
|
|
<p class="whs1"> bb.append(nb)
|
|
<span style="font-family: 'Times New Roman', serif;"># above bottom</span></p>
|
|
|
|
<p class="whs1"> aa.append(na)
|
|
<span style="font-family: 'Times New Roman', serif;"># bottom</span></p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1"> pass</p>
|
|
|
|
<p class="whs1"> </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], <span style="font-family: 'Times New Roman', serif;">#
|
|
top</span></p>
|
|
|
|
<p class="whs1"> dd[0],
|
|
cc[0], bb[1], cc[1], dd[1], #
|
|
-</p>
|
|
|
|
<p class="whs1"> dd[1],
|
|
cc[1], bb[2], cc[2], dd[2], #
|
|
-</p>
|
|
|
|
<p class="whs1"> dd[2],
|
|
cc[2], bb[3], cc[3], dd[3], <span style="font-family: 'Times New Roman', serif;">#
|
|
- below top</span></p>
|
|
|
|
<p class="whs1"> dd[3],
|
|
cc[3], bb[4], cc[4], dd[4], #
|
|
-</p>
|
|
|
|
<p class="whs1"> dd[4],
|
|
cc[4], bb[0], cc[0], dd[0], #
|
|
-</p>
|
|
|
|
<p class="whs1"> aa[4],
|
|
bb[4], cc[4], bb[0], aa[0], #
|
|
.</p>
|
|
|
|
<p class="whs1"> aa[3],
|
|
bb[3], cc[3], bb[4], aa[4], #
|
|
.</p>
|
|
|
|
<p class="whs1"> aa[2],
|
|
bb[2], cc[2], bb[3], aa[3], <span style="font-family: 'Times New Roman', serif;">#
|
|
. above bottom</span></p>
|
|
|
|
<p class="whs1"> aa[1],
|
|
bb[1], cc[1], bb[2], aa[2], #
|
|
.</p>
|
|
|
|
<p class="whs1"> aa[0],
|
|
bb[0], cc[0], bb[1], aa[1], #
|
|
.</p>
|
|
|
|
<p class="whs1"> aa[0],
|
|
aa[1], aa[2], aa[3], aa[4]], <span style="font-family: 'Times New Roman', serif;">#
|
|
bottom</span></p>
|
|
|
|
<p class="whs1"> [5,5,5,5,5,5,5,5,5,5,5,5])</p>
|
|
|
|
<p class="whs1">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3><a name=bookmark1>Removing Nodes and Elements</a></h3>
|
|
|
|
<h4 class="whs4">Removing Nodes</h4>
|
|
|
|
<p class="whs3"> </p>
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
SMESH_mechanic</span></p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1"> </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
|
|
"Nodes removing is OK!"</p>
|
|
|
|
<p class="whs1">else: print
|
|
"KO nodes removing." </p>
|
|
|
|
<p class="whs3"> </p>
|
|
|
|
<h4>Removing Elements</h4>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1"> </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
|
|
"Elements removing is OK!"</p>
|
|
|
|
<p class="whs1">else: print
|
|
"KO Elements removing." </p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3><a name=bookmark2>Renumbering Nodes and Elements</a></h3>
|
|
|
|
<p class="whs5">import SMESH_mechanic</p>
|
|
|
|
<p class="whs5"> </p>
|
|
|
|
<p class="whs5">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs6"> </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"> </p>
|
|
|
|
<p class="whs1">mesh = SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs3"> </p>
|
|
|
|
<p class="whs3"># move node #38</p>
|
|
|
|
<p class="whs1">mesh.MoveNode(38,
|
|
20., 10., 0.) </p>
|
|
|
|
<p class="whs3"> </p>
|
|
|
|
<h3><a name=bookmark4>Diagonal Inversion</a></h3>
|
|
|
|
<p class="whs5">import salome</p>
|
|
|
|
<p class="whs5">import smesh</p>
|
|
|
|
<p class="whs5"> </p>
|
|
|
|
<p class="whs7"># create an empty mesh
|
|
structure</p>
|
|
|
|
<p class="whs5">mesh = smesh.Mesh()
|
|
</p>
|
|
|
|
<p class="whs5"> </p>
|
|
|
|
<p class="whs7"># create the following
|
|
mesh:</p>
|
|
|
|
<p class="whs5"># .----.----.----.</p>
|
|
|
|
<p class="whs5"># | /|
|
|
/|
|
|
/|</p>
|
|
|
|
<p class="whs5"># | /
|
|
| / | /
|
|
|</p>
|
|
|
|
<p class="whs5"># | / |
|
|
/ | / |</p>
|
|
|
|
<p class="whs5"># |/ |/
|
|
|/
|
|
|</p>
|
|
|
|
<p class="whs5"># .----.----.----.</p>
|
|
|
|
<p class="whs5"> </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"> </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"> </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"> </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"> </p>
|
|
|
|
<p class="whs7"># inverse the diagonal
|
|
bb[1] - tt[2]</p>
|
|
|
|
<p class="whs5">print "\nDiagonal
|
|
inversion ... ",</p>
|
|
|
|
<p class="whs5">res = mesh.InverseDiag(bb[1],
|
|
tt[2])</p>
|
|
|
|
<p class="whs5">if not res: print
|
|
"failed!"</p>
|
|
|
|
<p class="whs5">else: print
|
|
"done."</p>
|
|
|
|
<p class="whs6"> </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> </p>
|
|
|
|
<p># create an empty mesh structure</p>
|
|
|
|
<p class="whs8">mesh = smesh.Mesh()
|
|
</p>
|
|
|
|
<p> </p>
|
|
|
|
<p># create the following mesh:</p>
|
|
|
|
<p class="whs8"># .----.----.----.</p>
|
|
|
|
<p class="whs8"># | /|
|
|
/|
|
|
/|</p>
|
|
|
|
<p class="whs8"># | /
|
|
| / | /
|
|
|</p>
|
|
|
|
<p class="whs8"># | / |
|
|
/ | / |</p>
|
|
|
|
<p class="whs8"># |/ |/
|
|
|/
|
|
|</p>
|
|
|
|
<p class="whs8"># .----.----.----.</p>
|
|
|
|
<p> </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"> </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"> </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"> </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> </p>
|
|
|
|
<p># delete the diagonal bb[1] - tt[2]</p>
|
|
|
|
<p class="whs8">print "\nUnite
|
|
two triangles ... ",</p>
|
|
|
|
<p class="whs8">res = mesh.DeleteDiag(bb[1],
|
|
tt[2])</p>
|
|
|
|
<p class="whs8">if not res: print
|
|
"failed!"</p>
|
|
|
|
<p class="whs8">else: print
|
|
"done."</p>
|
|
|
|
<p class="whs8"> </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"> </p>
|
|
|
|
<p class="whs9"># create an empty mesh
|
|
structure</p>
|
|
|
|
<p class="whs8">mesh = smesh.Mesh()
|
|
</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs9"># create the following
|
|
mesh:</p>
|
|
|
|
<p class="whs8"># .----.----.----.</p>
|
|
|
|
<p class="whs8"># | /|
|
|
/|
|
|
/|</p>
|
|
|
|
<p class="whs8"># | /
|
|
| / | /
|
|
|</p>
|
|
|
|
<p class="whs8"># | / |
|
|
/ | / |</p>
|
|
|
|
<p class="whs8"># |/ |/
|
|
|/
|
|
|</p>
|
|
|
|
<p class="whs8"># .----.----.----.</p>
|
|
|
|
<p class="whs8"> </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"> </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"> </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"> </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"> </p>
|
|
|
|
<p class="whs9"># unite a set of triangles</p>
|
|
|
|
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">print
|
|
"\nUnite a set of triangles ... ",</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
|
|
"failed!"</p>
|
|
|
|
<p class="whs8">else: print
|
|
"done."</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<h3><a name=bookmark12>Orientation</a></h3>
|
|
|
|
<p class="whs8">import salome</p>
|
|
|
|
<p class="whs8">import smesh</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p># create an empty mesh structure</p>
|
|
|
|
<p class="whs8">mesh = smesh.Mesh()
|
|
</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs9"># build five quadrangles:</p>
|
|
|
|
<p class="whs8">dx = 10</p>
|
|
|
|
<p class="whs8">dy = 20</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">n1
|
|
= mesh.AddNode(0.0
|
|
* dx, 0, 0)</span></p>
|
|
|
|
<p class="whs8">n2 =
|
|
mesh.AddNode(1.0 * dx, 0, 0)</p>
|
|
|
|
<p class="whs8">n3 =
|
|
mesh.AddNode(2.0 * dx, 0, 0)</p>
|
|
|
|
<p class="whs8">n4 =
|
|
mesh.AddNode(3.0 * dx, 0, 0)</p>
|
|
|
|
<p class="whs8">n5 =
|
|
mesh.AddNode(4.0 * dx, 0, 0)</p>
|
|
|
|
<p class="whs8">n6 =
|
|
mesh.AddNode(5.0 * dx, 0, 0)</p>
|
|
|
|
<p class="whs8">n7 =
|
|
mesh.AddNode(0.0 * dx, dy, 0)</p>
|
|
|
|
<p class="whs8">n8 =
|
|
mesh.AddNode(1.0 * dx, dy, 0)</p>
|
|
|
|
<p class="whs8">n9 =
|
|
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"> </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"> </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"> </p>
|
|
|
|
<p class="whs8">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<h3><a name=bookmark7>Cutting Quadrangles</a></h3>
|
|
|
|
<p class="whs8">import SMESH_mechanic</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8">smesh = SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs8">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs9"># cut two quadrangles:
|
|
405 and 406</p>
|
|
|
|
<p class="whs8">mesh.QuadToTri([405,
|
|
406], smesh.FT_MinimumAngle) </p>
|
|
|
|
<p class="whs9"> </p>
|
|
|
|
<h3><a name=bookmark8>Smoothing</a></h3>
|
|
|
|
<p class="whs8">import salome</p>
|
|
|
|
<p class="whs8">import geompy</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8">import SMESH_mechanic</p>
|
|
|
|
<p class="whs8"> </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"> </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["FACE"])</span></p>
|
|
|
|
<p class="whs8">face = faces[3]</p>
|
|
|
|
<p class="whs8">geompy.addToStudyInFather(SMESH_mechanic.shape_mesh,
|
|
face, "face planar with hole")</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># create a group of
|
|
faces to be smoothed</p>
|
|
|
|
<p class="whs8">GroupSmooth = mesh.GroupOnGeom(face,
|
|
"Group of faces (smooth)", smesh.FACE)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># perform smoothing</p>
|
|
|
|
<p class="whs8"> </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 "\nSmoothing
|
|
... ",</p>
|
|
|
|
<p class="whs8">if not res: print
|
|
"failed!"</p>
|
|
|
|
<p class="whs8">else: print
|
|
"done."</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<h3><a name=bookmark9>Extrusion</a></h3>
|
|
|
|
<p class="whs8">import salome</p>
|
|
|
|
<p class="whs8">import geompy</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8">import SMESH_mechanic</p>
|
|
|
|
<p class="whs8"> </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"> </p>
|
|
|
|
<p class="whs9"># select the top face</p>
|
|
|
|
<p class="whs8">faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh,
|
|
geompy.ShapeType["FACE"])</p>
|
|
|
|
<p class="whs8">face = faces[7]</p>
|
|
|
|
<p class="whs8">geompy.addToStudyInFather(SMESH_mechanic.shape_mesh,
|
|
face, "face circular top")</p>
|
|
|
|
<p class="whs8"> </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"> </p>
|
|
|
|
<p class="whs8"># create a group to
|
|
be extruded</p>
|
|
|
|
<p class="whs8">GroupTri = mesh.GroupOnGeom(face,
|
|
"Group of faces (extrusion)", smesh.FACE)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># perform extrusion
|
|
of the group</p>
|
|
|
|
<p class="whs8">mesh.ExtrusionSweepObject(GroupTri,
|
|
vector, 5)</p>
|
|
|
|
<p class="whs8"> </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"> </p>
|
|
|
|
<p class="whs9"># Geometry</p>
|
|
|
|
<p class="whs8">import geompy</p>
|
|
|
|
<p class="whs9"> </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"> </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,
|
|
"Vertex_" + `iv`)</p>
|
|
|
|
<p class="whs10">vertices.append(vert)</p>
|
|
|
|
<p class="whs10">iv
|
|
+= 1</p>
|
|
|
|
<p class="whs10">pass</p>
|
|
|
|
<p class="whs9"> </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 =
|
|
geompy.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2])</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8">geompy.addToStudy(Edge_straight,
|
|
"Edge_straight")</p>
|
|
|
|
<p class="whs8">geompy.addToStudy(Edge_bezierrr,
|
|
"Edge_bezierrr")</p>
|
|
|
|
<p class="whs8">geompy.addToStudy(Wire_polyline,
|
|
"Wire_polyline")</p>
|
|
|
|
<p class="whs8">geompy.addToStudy(Edge_Circle
|
|
, "Edge_Circle")</p>
|
|
|
|
<p class="whs9"> </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["EDGE"])</p>
|
|
|
|
<p class="whs8">for ii in range(len(Wire_polyline_edges)):</p>
|
|
|
|
<p class="whs10">geompy.addToStudyInFather(Wire_polyline,
|
|
Wire_polyline_edges[ii], "Edge_" + `ii + 1`)</p>
|
|
|
|
<p class="whs10">pass</p>
|
|
|
|
<p class="whs11"> </p>
|
|
|
|
<p class="whs9"># Mesh</p>
|
|
|
|
<p class="whs8">import smesh</p>
|
|
|
|
<p class="whs8"> </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"> mesh1d_tool
|
|
= smesh.Mesh(shape1d, name)</p>
|
|
|
|
<p class="whs13"> algo
|
|
= mesh1d_tool.Segment()</p>
|
|
|
|
<p class="whs13"> hyp
|
|
= algo.NumberOfSegments(nbSeg)</p>
|
|
|
|
<p class="whs13"> isDone
|
|
= mesh1d_tool.Compute()</p>
|
|
|
|
<p class="whs13"> if
|
|
not isDone: print 'Mesh ', name, ': computation failed'</p>
|
|
|
|
<p class="whs13"> 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"> quad_1
|
|
= smesh.Mesh(name = mesh_name)</p>
|
|
|
|
<p class="whs13"> </p>
|
|
|
|
<p class="whs13"> <span
|
|
style="font-family: 'Times New Roman', serif;">#
|
|
six nodes</span></p>
|
|
|
|
<p class="whs13"> n1
|
|
= quad_1.AddNode(0, 20, 10)</p>
|
|
|
|
<p class="whs13"> n2
|
|
= quad_1.AddNode(0, 40, 10)</p>
|
|
|
|
<p class="whs13"> n3
|
|
= quad_1.AddNode(0, 40, 30)</p>
|
|
|
|
<p class="whs13"> n4
|
|
= quad_1.AddNode(0, 20, 30)</p>
|
|
|
|
<p class="whs13"> n5
|
|
= quad_1.AddNode(0, 0,
|
|
30)</p>
|
|
|
|
<p class="whs13"> n6
|
|
= quad_1.AddNode(0, 0,
|
|
10)</p>
|
|
|
|
<p class="whs13"> </p>
|
|
|
|
<p class="whs13"> <span
|
|
style="font-family: 'Times New Roman', serif;">#
|
|
seven edges</span></p>
|
|
|
|
<p class="whs13"> quad_1.AddEdge([n1,
|
|
n2]) # 1</p>
|
|
|
|
<p class="whs13"> quad_1.AddEdge([n2,
|
|
n3]) # 2</p>
|
|
|
|
<p class="whs13"> quad_1.AddEdge([n3,
|
|
n4]) # 3</p>
|
|
|
|
<p class="whs13"> quad_1.AddEdge([n4,
|
|
n1]) # 4</p>
|
|
|
|
<p class="whs13"> quad_1.AddEdge([n4,
|
|
n5]) # 5</p>
|
|
|
|
<p class="whs13"> quad_1.AddEdge([n5,
|
|
n6]) # 6</p>
|
|
|
|
<p class="whs13"> quad_1.AddEdge([n6,
|
|
n1]) # 7</p>
|
|
|
|
<p class="whs13"> </p>
|
|
|
|
<p class="whs13"> <span
|
|
style="font-family: 'Times New Roman', serif;">#
|
|
two quadrangle faces</span></p>
|
|
|
|
<p class="whs13"> quad_1.AddFace([n1,
|
|
n2, n3, n4]) # 8</p>
|
|
|
|
<p class="whs13"> quad_1.AddFace([n1,
|
|
n4, n5, n6]) # 9</p>
|
|
|
|
<p class="whs13"> return
|
|
[quad_1, [1,2,3,4,5,6,7], [8,9]]</p>
|
|
|
|
<p class="whs13"> </p>
|
|
|
|
<p class="whs12"># Path
|
|
meshes</p>
|
|
|
|
<p class="whs13">Edge_straight_mesh
|
|
= Mesh1D(Edge_straight, 7, "Edge_straight")</p>
|
|
|
|
<p class="whs13">Edge_bezierrr_mesh
|
|
= Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr")</p>
|
|
|
|
<p class="whs13">Wire_polyline_mesh
|
|
= Mesh1D(Wire_polyline, 3, "Wire_polyline")</p>
|
|
|
|
<p class="whs13">Edge_Circle_mesh
|
|
=
|
|
Mesh1D(Edge_Circle ,
|
|
8, "Edge_Circle")</p>
|
|
|
|
<p class="whs13"> </p>
|
|
|
|
<p class="whs12"># Initial
|
|
meshes (to be extruded)</p>
|
|
|
|
<p class="whs13">[quad_1,
|
|
ee_1, ff_1] = MakeQuadMesh2("quad_1")</p>
|
|
|
|
<p class="whs13">[quad_2,
|
|
ee_2, ff_2] = MakeQuadMesh2("quad_2")</p>
|
|
|
|
<p class="whs13">[quad_3,
|
|
ee_3, ff_3] = MakeQuadMesh2("quad_3")</p>
|
|
|
|
<p class="whs13">[quad_4,
|
|
ee_4, ff_4] = MakeQuadMesh2("quad_4")</p>
|
|
|
|
<p class="whs13">[quad_5,
|
|
ee_5, ff_5] = MakeQuadMesh2("quad_5")</p>
|
|
|
|
<p class="whs13">[quad_6,
|
|
ee_6, ff_6] = MakeQuadMesh2("quad_6")</p>
|
|
|
|
<p class="whs13">[quad_7,
|
|
ee_7, ff_7] = MakeQuadMesh2("quad_7")</p>
|
|
|
|
<p class="whs13"> </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"> </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"> 0,
|
|
[], 0, refPoint)</p>
|
|
|
|
<p class="whs13"> </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"> 0,
|
|
[], 0, refPoint)</p>
|
|
|
|
<p class="whs13"> </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"> 1,
|
|
[a45, a45, a45, 0, -a45, -a45, -a45], 0, refPoint)</p>
|
|
|
|
<p class="whs13"> </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"> 1,
|
|
[a10, a10, a10], 0, refPoint)</p>
|
|
|
|
<p class="whs13"> </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"> 0,
|
|
[], 0, refPoint)</p>
|
|
|
|
<p class="whs13"> </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"> 0,
|
|
[], 0, refPoint)</p>
|
|
|
|
<p class="whs13"> </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"> 1,
|
|
[a45, -a45, a45, -a45, a45, -a45, a45, -a45], 0, refPoint)</p>
|
|
|
|
<p class="whs13"> </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"> </p>
|
|
|
|
<p class="whs8">import SMESH_mechanic</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">mesh
|
|
= SMESH_mechanic.mesh</span></p>
|
|
|
|
<p class="whs8">smesh = SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs8"> </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,"Group
|
|
of faces (rotate)")</p>
|
|
|
|
<p class="whs8">GroupRotate.Add(FacesRotate)</p>
|
|
|
|
<p class="whs9"> </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"> </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"> </p>
|
|
|
|
<h3><a name=bookmark13>Pattern Mapping</a></h3>
|
|
|
|
<p class="whs8">import geompy</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8">import smesh</p>
|
|
|
|
<p class="whs8"> </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,
|
|
"Box_1")</p>
|
|
|
|
<p class="whs9"> </p>
|
|
|
|
<p class="whs9">faces = geompy.SubShapeAll(Box_1,
|
|
geompy.ShapeType["FACE"])</p>
|
|
|
|
<p class="whs9">Face_1 = faces[0]</p>
|
|
|
|
<p class="whs9">Face_2 = faces[1]</p>
|
|
|
|
<p class="whs9"> </p>
|
|
|
|
<p class="whs9">geompy.addToStudyInFather(Box_1,
|
|
Face_1, "Face_1")</p>
|
|
|
|
<p class="whs9">geompy.addToStudyInFather(Box_1,
|
|
Face_2, "Face_2")</p>
|
|
|
|
<p class="whs9"> </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"> </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"> </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"> </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"> </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"> </p>
|
|
|
|
<p class="whs8"># create a pattern</p>
|
|
|
|
<p class="whs9">pattern = smesh.GetPattern()</p>
|
|
|
|
<p class="whs9"> </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"> </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"> </p>
|
|
|
|
<p class="whs9">isDone = pattern.MakeMesh(Mesh_1.GetMesh(),
|
|
0, 0)</p>
|
|
|
|
<p class="whs9">if (isDone != 1): print
|
|
'MakeMesh :', pattern.GetErrorCode() </p>
|
|
|
|
<script type="text/javascript" language="javascript1.2">
|
|
<!--
|
|
if (window.writeIntopicBar)
|
|
writeIntopicBar(0);
|
|
//-->
|
|
</script>
|
|
</body>
|
|
</html>
|