mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-16 10:38:33 +05:00
1834 lines
44 KiB
HTML
Executable File
1834 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; }
|
|
p.whs3 { margin-top:0pt; margin-bottom:0pt; font-family:'Times New Roman' , serif; }
|
|
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 { font-family:'Lucida Console' , monospace; }
|
|
p.whs8 { font-family:'Times New Roman' , serif; }
|
|
p.whs9 { margin-left:36px; font-family:'Lucida Console' , monospace; }
|
|
p.whs10 { margin-left:36px; }
|
|
p.whs11 { margin-left:192px; font-family:'Lucida Console' , monospace; }
|
|
p.whs12 { margin-left:48px; font-family:'Lucida Console' , monospace; }
|
|
p.whs13 { margin-left:40px; font-family:'Lucida Console' , monospace; }
|
|
-->
|
|
</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 +="</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</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># add node</p>
|
|
|
|
<p class="whs1">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(50,
|
|
10, 0) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h4>Add Edge</h4>
|
|
|
|
<p class="whs1">import SMESH</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># add node</p>
|
|
|
|
<p class="whs1">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(50,
|
|
10, 0) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add edge</p>
|
|
|
|
<p class="whs1">LastNodeId = mesh.NbNodes()</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddEdge([LastNodeId,
|
|
38]) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Edge addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO edge addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h4>Add Triangle</h4>
|
|
|
|
<p class="whs1">import SMESH</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add node</p>
|
|
|
|
<p class="whs1">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(50,
|
|
10, 0) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">LastNodeId = mesh.NbNodes()</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># add triangle</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddFace([LastNodeId,
|
|
38, 39]) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Triangle addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO triangle addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h4>Add Quadrangle</h4>
|
|
|
|
<p class="whs1">import SMESH</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add node</p>
|
|
|
|
<p class="whs1">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(50,
|
|
10, 0) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">LastNodeId = mesh.NbNodes()</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># add quadrangle</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(40,
|
|
20, 0) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddFace([mesh.NbNodes(),
|
|
LastNodeId, 38, 39]) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Quadrangle addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO quadrangle addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<h4>Add Tetrahedron</h4>
|
|
|
|
<p class="whs1">import SMESH</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add node</p>
|
|
|
|
<p class="whs1">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(50,
|
|
10, 0) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">LastNodeId = mesh.NbNodes()</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># add tetrahedron</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddVolume([LastNodeId,
|
|
38, 39, 246]) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Tetrahedron addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO tetrahedron addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<h4>Add Hexahedron</h4>
|
|
|
|
<p class="whs1">import SMESH</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add nodes</p>
|
|
|
|
<p class="whs1">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(50,
|
|
10, 0) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1">aNodeId1 = mesh.NbNodes()</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(47,
|
|
12, 0) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1">aNodeId2 = mesh.NbNodes()</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(50,
|
|
10, 10) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1">aNodeId3 = mesh.NbNodes()</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddNode(47,
|
|
12, 10) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node addition."</p>
|
|
|
|
<p class="whs1">aNodeId4 = mesh.NbNodes()</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># add hexahedron</p>
|
|
|
|
<p class="whs1">if aMeshEditor.AddVolume([aNodeId2,
|
|
aNodeId1, 38, 39, aNodeId4, aNodeId3, 245, 246]) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Hexahedron addition is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO Hexahedron addition."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<h4>Add Polygon</h4>
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">import StdMeshers</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># GEOM module </p>
|
|
|
|
<p class="whs1">shape_mesh = geompy.MakeCylinderRH(13,
|
|
77)</p>
|
|
|
|
<p class="whs1">geompy.addToStudy(shape_mesh,
|
|
"cylinder")</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># SMESH module</p>
|
|
|
|
<p class="whs1">smesh = salome.lcc.FindOrLoadComponent("FactoryServer",
|
|
"SMESH")</p>
|
|
|
|
<p class="whs1">smesh.SetCurrentStudy(salome.myStudy)</p>
|
|
|
|
<p class="whs1">mesh = smesh.CreateMesh(shape_mesh)</p>
|
|
|
|
<p class="whs1">MeshEditor = mesh.GetMeshEditor()</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"> node_start_id
|
|
= a_mesh.NbNodes() + 1</p>
|
|
|
|
<p class="whs1"> al
|
|
= 2.0 * math.pi / nb_vert</p>
|
|
|
|
<p class="whs1"> node_ids
|
|
= []</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># Create nodes for a polyhedron</p>
|
|
|
|
<p class="whs1"> for
|
|
ii in range(nb_vert):</p>
|
|
|
|
<p class="whs1"> MeshEditor.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(node_start_id
|
|
+ ii)</p>
|
|
|
|
<p class="whs1"> pass</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># Create a polygon</p>
|
|
|
|
<p class="whs1"> MeshEditor.AddPolygonalFace(node_ids)</p>
|
|
|
|
<p class="whs1"> return
|
|
0</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># Create three polygons</p>
|
|
|
|
<p class="whs1">MakePolygon(mesh,
|
|
0, 0, 0,
|
|
30, 13)</p>
|
|
|
|
<p class="whs1">MakePolygon(mesh,
|
|
0, 0, 10, 21, 9)</p>
|
|
|
|
<p class="whs1">MakePolygon(mesh,
|
|
0, 0, 20, 13, 6)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h4>Add polyhedron</h4>
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
salome</span></p>
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">#import SMESH</p>
|
|
|
|
<p class="whs1">import StdMeshers</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs3"># GEOM</p>
|
|
|
|
<p class="whs1">shape_mesh = geompy.MakeCylinderRH(13,
|
|
77)</p>
|
|
|
|
<p class="whs1">geompy.addToStudy(shape_mesh,
|
|
"cylinder")</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs3"># SMESH</p>
|
|
|
|
<p class="whs1">smesh = salome.lcc.FindOrLoadComponent("FactoryServer",
|
|
"SMESH")</p>
|
|
|
|
<p class="whs1">smesh.SetCurrentStudy(salome.myStudy)</p>
|
|
|
|
<p class="whs1">mesh = smesh.CreateMesh(shape_mesh)</p>
|
|
|
|
<p class="whs1">MeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs3"># Now we are going
|
|
to create a 12-hedron:</p>
|
|
|
|
<p class="whs3"> </p>
|
|
|
|
<p class="whs3"># Create nodes for
|
|
polyhedron</p>
|
|
|
|
<p class="whs1">al = 2 * math.pi
|
|
/ 5.0</p>
|
|
|
|
<p class="whs1">cosal = math.cos(al)</p>
|
|
|
|
<p class="whs1"> </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">for i in range(5):</p>
|
|
|
|
<p class="whs1"> MeshEditor.AddNode(rr*math.cos(i*al),
|
|
rr*math.sin(i*al), 0)
|
|
<span style="font-family: 'Times New Roman', serif;"># 1,3,5,7, 9 # bottom</span></p>
|
|
|
|
<p class="whs1"> MeshEditor.AddNode(r1*math.cos(i*al),
|
|
r1*math.sin(i*al), dh) <span style="font-family: 'Times New Roman', serif;">#
|
|
2,4,6,8,10 # above bottom</span></p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">for i in range(5):</p>
|
|
|
|
<p class="whs1"> MeshEditor.AddNode(rr*math.cos(i*al
|
|
+ al/2.0),</p>
|
|
|
|
<p class="whs1"> rr*math.sin(i*al
|
|
+ al/2.0), hh) # 11,13,15,17,19 <span style="font-family: 'Times New Roman', serif;">#
|
|
top</span></p>
|
|
|
|
<p class="whs1"> MeshEditor.AddNode(r1*math.cos(i*al
|
|
+ al/2.0),</p>
|
|
|
|
<p class="whs1"> r1*math.sin(i*al
|
|
+ al/2.0), hh - dh) # 12,14,16,18,20 <span style="font-family: 'Times New Roman', serif;">#
|
|
below top</span></p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs3"># Create a polyhedral
|
|
volume</p>
|
|
|
|
<p class="whs1">MeshEditor.AddPolyhedralVolume([
|
|
1, 3, 5,
|
|
7, 9,
|
|
<span style="font-family: 'Times New Roman', serif;">#
|
|
bottom</span></p>
|
|
|
|
<p class="whs1"> 1,
|
|
2, 12,
|
|
4, 3,
|
|
<span style="font-family: 'Times New Roman', serif;">#
|
|
.</span></p>
|
|
|
|
<p class="whs1"> 3,
|
|
4, 14,
|
|
6, 5,
|
|
<span style="font-family: 'Times New Roman', serif;">#
|
|
.</span></p>
|
|
|
|
<p class="whs1"> 5,
|
|
6, 16,
|
|
8, 7,
|
|
<span style="font-family: 'Times New Roman', serif;">#
|
|
. above bottom</span></p>
|
|
|
|
<p class="whs1"> 7,
|
|
8, 18,
|
|
10, 9,
|
|
<span style="font-family: 'Times New Roman', serif;">#
|
|
.</span></p>
|
|
|
|
<p class="whs1"> 9,
|
|
10, 20, 2,
|
|
1, <span
|
|
style="font-family: 'Times New Roman', serif;">#
|
|
.</span></p>
|
|
|
|
<p class="whs1"> 11,
|
|
12, 4,
|
|
14, 13, <span style="font-family: 'Times New Roman', serif;">#
|
|
-</span></p>
|
|
|
|
<p class="whs1"> 13,
|
|
14, 6,
|
|
16, 15, <span style="font-family: 'Times New Roman', serif;">#
|
|
-</span></p>
|
|
|
|
<p class="whs1"> 15,
|
|
16, 8,
|
|
18, 17, <span style="font-family: 'Times New Roman', serif;">#
|
|
- below top</span></p>
|
|
|
|
<p class="whs1"> 17,
|
|
18, 10, 20, 19, <span style="font-family: 'Times New Roman', serif;">#
|
|
-</span></p>
|
|
|
|
<p class="whs1"> 19,
|
|
20, 2,
|
|
12, 11, <span style="font-family: 'Times New Roman', serif;">#
|
|
-</span></p>
|
|
|
|
<p class="whs1"> 11,
|
|
13, 15, 17, 19], <span style="font-family: 'Times New Roman', serif;">#
|
|
top</span></p>
|
|
|
|
<p class="whs1"> [5,5,5,5,5,5,5,5,5,5,5,5])</p>
|
|
|
|
<p class="whs1"> </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="whs2"> </p>
|
|
|
|
<p class="whs1">import SMESH</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<p class="whs2"># add node</p>
|
|
|
|
<p class="whs1">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">if aMeshEditor.RemoveNodes([246,
|
|
255]) == 1:</p>
|
|
|
|
<p class="whs1"> print
|
|
"Node removing is OK!"</p>
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
<p class="whs1"> print
|
|
"KO node removing."</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<h4>Removing Elements</h4>
|
|
|
|
<p class="whs1">import SMESH</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">anEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">anEditor.RemoveElements([850,
|
|
859, 814])</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<h3><a name=bookmark2>Renumbering Nodes and Elements</a></h3>
|
|
|
|
<p class="whs5">import SMESH</p>
|
|
|
|
<p class="whs5">import SMESH_mechanic</p>
|
|
|
|
<p class="whs5"> </p>
|
|
|
|
<p class="whs5">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs5">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs5"> </p>
|
|
|
|
<p class="whs5">anEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs5">anEditor.RenumberNodes()</p>
|
|
|
|
<p class="whs5"> </p>
|
|
|
|
<p class="whs6"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs6"> </p>
|
|
|
|
<p> </p>
|
|
|
|
<h3><a name=bookmark3>Moving Nodes</a></h3>
|
|
|
|
<p class="whs1">import SMESH</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># move node</p>
|
|
|
|
<p class="whs1">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">aMeshEditor.MoveNode(38,
|
|
20, 10, 0)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<h3><a name=bookmark4>Diagonal Inversion</a></h3>
|
|
|
|
<p class="whs1">import SMESH</p>
|
|
|
|
<p class="whs1">import SMESH_mechanic</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs1">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs1">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs1">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"># inverse diagonal</p>
|
|
|
|
<p class="whs1">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs1">aMeshEditor.InverseDiag(700,
|
|
642)</p>
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs2"> </p>
|
|
|
|
<h3><a name=bookmark5>Uniting two Triangles</a></h3>
|
|
|
|
<p class="whs7">import SMESH</p>
|
|
|
|
<p class="whs7">import SMESH_mechanic</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs7">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs7">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p># delete diagonal</p>
|
|
|
|
<p class="whs7">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs7">aMeshEditor.DeleteDiag(700,
|
|
642)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p> </p>
|
|
|
|
<h3><a name=bookmark6>Uniting a Set of Triangles</a></h3>
|
|
|
|
<p class="whs7">import SMESH</p>
|
|
|
|
<p class="whs7">import SMESH_mechanic</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs7">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs7">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p># unite a set of triangles</p>
|
|
|
|
<p class="whs7">aFilterMgr = smesh.CreateFilterManager()</p>
|
|
|
|
<p class="whs7">aFunctor = aFilterMgr.CreateMinimumAngle()</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs7">aMeshEditor.TriToQuad([1145,
|
|
1147, 1159, 1135], aFunctor, 60)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<h3><a name=bookmark12>Orientation</a></h3>
|
|
|
|
<p class="whs7"><span style="font-family: 'Lucida Console', monospace;">import
|
|
salome</span></p>
|
|
|
|
<p class="whs7">import geompy</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">import StdMeshers</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># GEOM module</p>
|
|
|
|
<p class="whs7">shape_mesh = geompy.MakeCylinderRH(13,
|
|
77)</p>
|
|
|
|
<p class="whs7">geompy.addToStudy(shape_mesh,
|
|
"cylinder")</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># SMESH module</p>
|
|
|
|
<p class="whs7">smesh = salome.lcc.FindOrLoadComponent("FactoryServer",
|
|
"SMESH")</p>
|
|
|
|
<p class="whs7">smesh.SetCurrentStudy(salome.myStudy)</p>
|
|
|
|
<p class="whs7">mesh = smesh.CreateMesh(shape_mesh)</p>
|
|
|
|
<p class="whs7">MeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># build five quadrangles:</p>
|
|
|
|
<p class="whs7">node_start_id = mesh.NbNodes()
|
|
+ 1</p>
|
|
|
|
<p class="whs7">dx = 10</p>
|
|
|
|
<p class="whs7">dy = 20</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(0.0
|
|
* dx, 0, 0) # 1</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(1.0
|
|
* dx, 0, 0) # 2</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(2.0
|
|
* dx, 0, 0) # 3</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(3.0
|
|
* dx, 0, 0) # 4</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(4.0
|
|
* dx, 0, 0) # 5</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(5.0
|
|
* dx, 0, 0) # 6</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(0.0
|
|
* dx, dy, 0) # 7</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(1.0
|
|
* dx, dy, 0) # 8</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(2.0
|
|
* dx, dy, 0) # 9</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(3.0
|
|
* dx, dy, 0) # 10</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(4.0
|
|
* dx, dy, 0) # 11</p>
|
|
|
|
<p class="whs7">MeshEditor.AddNode(5.0
|
|
* dx, dy, 0) # 12</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">MeshEditor.AddFace([1,
|
|
2, 8, 7])</p>
|
|
|
|
<p class="whs7">MeshEditor.AddFace([2,
|
|
3, 9, 8])</p>
|
|
|
|
<p class="whs7">MeshEditor.AddFace([3,
|
|
4, 10, 9])</p>
|
|
|
|
<p class="whs7">MeshEditor.AddFace([4,
|
|
5, 11, 10])</p>
|
|
|
|
<p class="whs7">MeshEditor.AddFace([5,
|
|
6, 12, 11])</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># Change orientation
|
|
of the second and the fourth faces.</p>
|
|
|
|
<p class="whs7">MeshEditor.Reorient([2,
|
|
4])</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<h3><a name=bookmark7>Cutting Quadrangles</a></h3>
|
|
|
|
<p class="whs7">import SMESH</p>
|
|
|
|
<p class="whs7">import SMESH_mechanic</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs7">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs7">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># unite a set of triangles</p>
|
|
|
|
<p class="whs7">aFilterMgr = smesh.CreateFilterManager()</p>
|
|
|
|
<p class="whs7">aFunctor = aFilterMgr.CreateMinimumAngle()</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs7">aMeshEditor.QuadToTri([405,
|
|
406], aFunctor)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<h3><a name=bookmark8>Smoothing</a></h3>
|
|
|
|
<p class="whs7">import SMESH</p>
|
|
|
|
<p class="whs7">import SMESH_mechanic</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs7">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs7">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># smooth</p>
|
|
|
|
<p class="whs7">FacesSmooth = [911,
|
|
931, 950, 864, 932]</p>
|
|
|
|
<p class="whs7">GroupSmooth = mesh.CreateGroup(SMESH.FACE,"Group
|
|
of faces (smooth)")</p>
|
|
|
|
<p class="whs7">GroupSmooth.Add(FacesSmooth)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs7">aMeshEditor.SmoothObject(GroupSmooth,
|
|
[], 20, 2, SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">salome.sg.updateObjBrowser(1)
|
|
</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<h3><a name=bookmark9>Extrusion</a></h3>
|
|
|
|
<p class="whs7">import SMESH</p>
|
|
|
|
<p class="whs7">import SMESH_mechanic</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs7">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs7">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># extrusion of the group</p>
|
|
|
|
<p class="whs7">point = SMESH.PointStruct(0,
|
|
0, 5)</p>
|
|
|
|
<p class="whs7">vector = SMESH.DirStruct(point)</p>
|
|
|
|
<p class="whs7">FacesTriToQuad = [2381,
|
|
2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393,
|
|
2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405,
|
|
2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417,
|
|
2418, 2419, 2420, 2421, 2422]</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">GroupTriToQuad = mesh.CreateGroup(SMESH.FACE,"Group
|
|
of faces (quad)")</p>
|
|
|
|
<p class="whs7">GroupTriToQuad.Add(FacesTriToQuad)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs7">aMeshEditor.ExtrusionSweepObject(GroupTriToQuad,
|
|
vector, 5)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<h3><a name=bookmark10>Extrusion along a Path</a></h3>
|
|
|
|
<p class="whs7">import math</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">import salome</p>
|
|
|
|
<p class="whs7">salome.salome_init()</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># Geometry</p>
|
|
|
|
<p class="whs7">import geompy</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 1. Create points</p>
|
|
|
|
<p class="whs7">points = [[0, 0],
|
|
[50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]]</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">iv = 1</p>
|
|
|
|
<p class="whs7">vertices = []</p>
|
|
|
|
<p class="whs7">for point in points:</p>
|
|
|
|
<p class="whs9">vert
|
|
= geompy.MakeVertex(point[0], point[1], 0)</p>
|
|
|
|
<p class="whs9">geompy.addToStudy(vert,
|
|
"Vertex_" + `iv`)</p>
|
|
|
|
<p class="whs9">vertices.append(vert)</p>
|
|
|
|
<p class="whs9">iv
|
|
+= 1</p>
|
|
|
|
<p class="whs9">pass</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 2. Create edges and
|
|
wires</p>
|
|
|
|
<p class="whs7">Edge_straight = geompy.MakeEdge(vertices[0],
|
|
vertices[4])</p>
|
|
|
|
<p class="whs7">Edge_bezierrr = geompy.MakeBezier(vertices)</p>
|
|
|
|
<p class="whs7">Wire_polyline = geompy.MakePolyline(vertices)</p>
|
|
|
|
<p class="whs7">Edge_Circle =
|
|
geompy.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2])</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">geompy.addToStudy(Edge_straight,
|
|
"Edge_straight")</p>
|
|
|
|
<p class="whs7">geompy.addToStudy(Edge_bezierrr,
|
|
"Edge_bezierrr")</p>
|
|
|
|
<p class="whs7">geompy.addToStudy(Wire_polyline,
|
|
"Wire_polyline")</p>
|
|
|
|
<p class="whs7">geompy.addToStudy(Edge_Circle
|
|
, "Edge_Circle")</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 3. Explode wire on
|
|
edges, as they will be used for mesh extrusion</p>
|
|
|
|
<p class="whs7">Wire_polyline_edges
|
|
= geompy.SubShapeAll(Wire_polyline, geompy.ShapeType["EDGE"])</p>
|
|
|
|
<p class="whs7">for ii in range(len(Wire_polyline_edges)):</p>
|
|
|
|
<p class="whs9">geompy.addToStudyInFather(Wire_polyline,
|
|
Wire_polyline_edges[ii], "Edge_" + `ii + 1`)</p>
|
|
|
|
<p class="whs9">pass</p>
|
|
|
|
<p class="whs10"> </p>
|
|
|
|
<p class="whs8"># Mesh</p>
|
|
|
|
<p class="whs7">import smesh</p>
|
|
|
|
<p class="whs7">import SMESH</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">gen = smesh.smesh</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">smeshgui = salome.ImportComponentGUI("SMESH")</p>
|
|
|
|
<p class="whs7">smeshgui.Init(salome.myStudyId)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 1D algorithm and three
|
|
1D hypotheses</p>
|
|
|
|
<p class="whs7">Wire_discretisation
|
|
= gen.CreateHypothesis('Regular_1D', 'libStdMeshersEngine.so')</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">Nb_Segments_3 = gen.CreateHypothesis('NumberOfSegments',
|
|
'libStdMeshersEngine.so')</p>
|
|
|
|
<p class="whs7">Nb_Segments_7 = gen.CreateHypothesis('NumberOfSegments',
|
|
'libStdMeshersEngine.so')</p>
|
|
|
|
<p class="whs7">Nb_Segments_8 = gen.CreateHypothesis('NumberOfSegments',
|
|
'libStdMeshersEngine.so')</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">Nb_Segments_3.SetNumberOfSegments(3)</p>
|
|
|
|
<p class="whs7">Nb_Segments_7.SetNumberOfSegments(7)</p>
|
|
|
|
<p class="whs7">Nb_Segments_8.SetNumberOfSegments(8)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># Mesh given shape with
|
|
given 1d hypothesis</p>
|
|
|
|
<p class="whs7">def Mesh1D(shape1d,
|
|
hyp1d, name):</p>
|
|
|
|
<p class="whs9">mesh1d_tool
|
|
= smesh.Mesh(shape1d)</p>
|
|
|
|
<p class="whs9">mesh1d
|
|
= mesh1d_tool.GetMesh()</p>
|
|
|
|
<p class="whs9">status
|
|
= mesh1d.AddHypothesis(shape1d, hyp1d)</p>
|
|
|
|
<p class="whs9">status
|
|
= mesh1d.AddHypothesis(shape1d, Wire_discretisation)</p>
|
|
|
|
<p class="whs9">isDone
|
|
= mesh1d_tool.Compute()</p>
|
|
|
|
<p class="whs9">if
|
|
not isDone: print 'Mesh ', name, ': computation failed'</p>
|
|
|
|
<p class="whs9">return
|
|
mesh1d</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># Create mesh with six
|
|
nodes, seven edges and two quadrangle faces</p>
|
|
|
|
<p class="whs7">def MakeQuadMesh2(mesh_name):</p>
|
|
|
|
<p class="whs9">quad_1
|
|
= gen.CreateEmptyMesh()</p>
|
|
|
|
<p class="whs9">smeshgui.SetName(salome.ObjectToID(quad_1),
|
|
mesh_name)</p>
|
|
|
|
<p class="whs9">editor_1
|
|
= quad_1.GetMeshEditor()</p>
|
|
|
|
<p class="whs10"> </p>
|
|
|
|
<p class="whs10"># six nodes</p>
|
|
|
|
<p class="whs9">n1
|
|
= editor_1.AddNode(0, 20, 10)</p>
|
|
|
|
<p class="whs9">n2
|
|
= editor_1.AddNode(0, 40, 10)</p>
|
|
|
|
<p class="whs9">n3
|
|
= editor_1.AddNode(0, 40, 30)</p>
|
|
|
|
<p class="whs9">n4
|
|
= editor_1.AddNode(0, 20, 30)</p>
|
|
|
|
<p class="whs9">n5
|
|
= editor_1.AddNode(0, 0,
|
|
30)</p>
|
|
|
|
<p class="whs9">n6
|
|
= editor_1.AddNode(0, 0,
|
|
10)</p>
|
|
|
|
<p class="whs10"> </p>
|
|
|
|
<p class="whs10"># seven edges</p>
|
|
|
|
<p class="whs9">editor_1.AddEdge([n1,
|
|
n2]) # 1</p>
|
|
|
|
<p class="whs9">editor_1.AddEdge([n2,
|
|
n3]) # 2</p>
|
|
|
|
<p class="whs9">editor_1.AddEdge([n3,
|
|
n4]) # 3</p>
|
|
|
|
<p class="whs9">editor_1.AddEdge([n4,
|
|
n1]) # 4</p>
|
|
|
|
<p class="whs9">editor_1.AddEdge([n4,
|
|
n5]) # 5</p>
|
|
|
|
<p class="whs9">editor_1.AddEdge([n5,
|
|
n6]) # 6</p>
|
|
|
|
<p class="whs9">editor_1.AddEdge([n6,
|
|
n1]) # 7</p>
|
|
|
|
<p class="whs10"> </p>
|
|
|
|
<p class="whs10"># two quadrangle faces</p>
|
|
|
|
<p class="whs9">editor_1.AddFace([n1,
|
|
n2, n3, n4]) # 8</p>
|
|
|
|
<p class="whs9">editor_1.AddFace([n1,
|
|
n4, n5, n6]) # 9</p>
|
|
|
|
<p class="whs9">return
|
|
[quad_1, editor_1, [1,2,3,4,5,6,7], [8,9]]</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># Path meshes</p>
|
|
|
|
<p class="whs7">Edge_straight_mesh
|
|
= Mesh1D(Edge_straight, Nb_Segments_7, "Edge_straight")</p>
|
|
|
|
<p class="whs7">Edge_bezierrr_mesh
|
|
= Mesh1D(Edge_bezierrr, Nb_Segments_7, "Edge_bezierrr")</p>
|
|
|
|
<p class="whs7">Wire_polyline_mesh
|
|
= Mesh1D(Wire_polyline, Nb_Segments_3, "Wire_polyline")</p>
|
|
|
|
<p class="whs7">Edge_Circle_mesh =
|
|
Mesh1D(Edge_Circle ,
|
|
Nb_Segments_8, "Edge_Circle")</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># Initial meshes (to
|
|
be extruded)</p>
|
|
|
|
<p class="whs7">[quad_1, editor_1,
|
|
ee_1, ff_1] = MakeQuadMesh2("quad_1")</p>
|
|
|
|
<p class="whs7">[quad_2, editor_2,
|
|
ee_2, ff_2] = MakeQuadMesh2("quad_2")</p>
|
|
|
|
<p class="whs7">[quad_3, editor_3,
|
|
ee_3, ff_3] = MakeQuadMesh2("quad_3")</p>
|
|
|
|
<p class="whs7">[quad_4, editor_4,
|
|
ee_4, ff_4] = MakeQuadMesh2("quad_4")</p>
|
|
|
|
<p class="whs7">[quad_5, editor_5,
|
|
ee_5, ff_5] = MakeQuadMesh2("quad_5")</p>
|
|
|
|
<p class="whs7">[quad_6, editor_6,
|
|
ee_6, ff_6] = MakeQuadMesh2("quad_6")</p>
|
|
|
|
<p class="whs7">[quad_7, editor_7,
|
|
ee_7, ff_7] = MakeQuadMesh2("quad_7")</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># ExtrusionAlongPath</p>
|
|
|
|
<p class="whs8"># IDsOfElements, PathMesh,
|
|
PathShape, NodeStart,</p>
|
|
|
|
<p class="whs8"># HasAngles, Angles,
|
|
HasRefPoint, RefPoint</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs7">refPoint = SMESH.PointStruct(0,
|
|
0, 0)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">a10 = 10.0*math.pi/180.0</p>
|
|
|
|
<p class="whs7">a45 = 45.0*math.pi/180.0</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 1. Extrusion of two
|
|
mesh edges along straight path</p>
|
|
|
|
<p class="whs7">error = editor_1.ExtrusionAlongPath([1,2],
|
|
Edge_straight_mesh, Edge_straight, 1,</p>
|
|
|
|
<p class="whs11"> 0,
|
|
[], 0, refPoint)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 2. Extrusion of one
|
|
mesh edge along curved path</p>
|
|
|
|
<p class="whs7">error = editor_2.ExtrusionAlongPath([2],
|
|
Edge_bezierrr_mesh, Edge_bezierrr, 1,</p>
|
|
|
|
<p class="whs11"> 0,
|
|
[], 0, refPoint)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 3. Extrusion of one
|
|
mesh edge along curved path with angles usage</p>
|
|
|
|
<p class="whs7">error = editor_3.ExtrusionAlongPath([2],
|
|
Edge_bezierrr_mesh, Edge_bezierrr, 1,</p>
|
|
|
|
<p class="whs11"> 1,
|
|
[a45, a45, a45, 0, -a45, -a45, -a45], 0, refPoint)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 4. Extrusion of one
|
|
mesh edge along path, which is a part of meshed wire</p>
|
|
|
|
<p class="whs7">error = editor_4.ExtrusionAlongPath([4],
|
|
Wire_polyline_mesh, Wire_polyline_edges[0], 1,</p>
|
|
|
|
<p class="whs11"> 1,
|
|
[a10, a10, a10], 0, refPoint)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 5. Extrusion of two
|
|
mesh faces along path, which is a part of meshed wire</p>
|
|
|
|
<p class="whs7">error = editor_5.ExtrusionAlongPath(ff_5
|
|
, Wire_polyline_mesh, Wire_polyline_edges[2], 4,</p>
|
|
|
|
<p class="whs11"> 0,
|
|
[], 0, refPoint)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 6. Extrusion of two
|
|
mesh faces along closed path</p>
|
|
|
|
<p class="whs7">error = editor_6.ExtrusionAlongPath(ff_6
|
|
, Edge_Circle_mesh, Edge_Circle, 1,</p>
|
|
|
|
<p class="whs11"> 0,
|
|
[], 0, refPoint)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># 7. Extrusion of two
|
|
mesh faces along closed path with angles usage</p>
|
|
|
|
<p class="whs7">error = editor_7.ExtrusionAlongPath(ff_7,
|
|
Edge_Circle_mesh, Edge_Circle, 1,</p>
|
|
|
|
<p class="whs11"> 1,
|
|
[a45, -a45, a45, -a45, a45, -a45, a45, -a45], 0, refPoint)</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs7">if salome.sg.hasDesktop():</p>
|
|
|
|
<p class="whs12">salome.sg.updateObjBrowser(1)</p>
|
|
|
|
<p class="whs12">pass</p>
|
|
|
|
<h3><a name=bookmark11>Revolution</a></h3>
|
|
|
|
<p class="whs7">import SMESH</p>
|
|
|
|
<p class="whs7">import SMESH_mechanic</p>
|
|
|
|
<p class="whs7">import math</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">smesh =
|
|
SMESH_mechanic.smesh</p>
|
|
|
|
<p class="whs7">mesh =
|
|
SMESH_mechanic.mesh</p>
|
|
|
|
<p class="whs7">salome = SMESH_mechanic.salome</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<p class="whs8"># rotate a sweep object</p>
|
|
|
|
<p class="whs7">FacesRotate = [492,
|
|
493, 502, 503]</p>
|
|
|
|
<p class="whs7">GroupRotate = mesh.CreateGroup(SMESH.FACE,"Group
|
|
of faces (rotate)")</p>
|
|
|
|
<p class="whs7">GroupRotate.Add(FacesRotate)</p>
|
|
|
|
<p class="whs7">angle45 = 45*math.pi/180</p>
|
|
|
|
<p class="whs7">axisXYZ = SMESH.AxisStruct(-38.3128,
|
|
-73.3658, -23.321, -13.3402, -13.3265, 6.66632)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">aMeshEditor = mesh.GetMeshEditor()</p>
|
|
|
|
<p class="whs7">aMeshEditor.RotationSweepObject(GroupRotate,
|
|
axisXYZ, angle45, 4, 1e-5)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<p class="whs8"> </p>
|
|
|
|
<h3><a name=bookmark13>Pattern Mapping</a></h3>
|
|
|
|
<p class="whs7">import salome</p>
|
|
|
|
<p class="whs7">import geompy</p>
|
|
|
|
<p class="whs7">import SMESH, smesh</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">geompy.init_geom(salome.myStudy)</p>
|
|
|
|
<p class="whs7">smesh.smesh.SetCurrentStudy(salome.myStudy)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># define geometry</p>
|
|
|
|
<p class="whs7">Box_1 = geompy.MakeBoxDXDYDZ(200,
|
|
200, 200)</p>
|
|
|
|
<p class="whs7">geompy.addToStudy(Box_1,
|
|
"Box_1")</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">faces = geompy.SubShapeAll(Box_1,
|
|
geompy.ShapeType["FACE"])</p>
|
|
|
|
<p class="whs7">Face_1 = faces[0]</p>
|
|
|
|
<p class="whs7">Face_2 = faces[1]</p>
|
|
|
|
<p class="whs7">geompy.addToStudyInFather(Box_1,
|
|
Face_1, "Face_1")</p>
|
|
|
|
<p class="whs7">geompy.addToStudyInFather(Box_1,
|
|
Face_2, "Face_2")</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># build quadrangle mesh
|
|
3x3 on Face_1</p>
|
|
|
|
<p class="whs7">Mesh_1 = smesh.Mesh(Face_1)</p>
|
|
|
|
<p class="whs7">Wire_discretisation
|
|
= Mesh_1.Segment()</p>
|
|
|
|
<p class="whs7">Wire_discretisation.NumberOfSegments(3)</p>
|
|
|
|
<p class="whs7">Mesh_1.Quadrangle()</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">isDone = Mesh_1.Compute()</p>
|
|
|
|
<p class="whs7">if not isDone: print
|
|
'Mesh Mesh_1 : computation failed'</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># pattern the mesh</p>
|
|
|
|
<p class="whs7">Mesh_2 = smesh.Mesh(Face_2)</p>
|
|
|
|
<p class="whs7">Nb_Segments_1 = smesh.smesh.CreateHypothesis('NumberOfSegments',
|
|
'libStdMeshersEngine.so')</p>
|
|
|
|
<p class="whs7">Nb_Segments_1.SetNumberOfSegments(1)</p>
|
|
|
|
<p class="whs7">status = Mesh_2.GetMesh().AddHypothesis(Face_2,
|
|
Nb_Segments_1)</p>
|
|
|
|
<p class="whs7">status = Mesh_2.GetMesh().AddHypothesis(Face_2,
|
|
Wire_discretisation.GetAlgorithm())</p>
|
|
|
|
<p class="whs7">Triangle_Mefisto =
|
|
Mesh_2.Triangle()</p>
|
|
|
|
<p class="whs7">Max_Element_Area =
|
|
Triangle_Mefisto.MaxElementArea(240)</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs7">isDone = Mesh_2.Compute()</p>
|
|
|
|
<p class="whs7">if not isDone: print
|
|
'Mesh Mesh_2 : computation failed'</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># create a pattern</p>
|
|
|
|
<p class="whs7">pattern = smesh.smesh.GetPattern()</p>
|
|
|
|
<p class="whs7">isDone = pattern.LoadFromFace(Mesh_2.GetMesh(),
|
|
Face_2, 0)</p>
|
|
|
|
<p class="whs7">if (isDone != 1):</p>
|
|
|
|
<p class="whs13">print
|
|
'LoadFromFace :', pattern.GetErrorCode()</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"># apply the pattern to
|
|
a face of the first mesh</p>
|
|
|
|
<p class="whs7">pattern.ApplyToMeshFaces(Mesh_1.GetMesh(),
|
|
[17], 0, 0)</p>
|
|
|
|
<p class="whs7">isDone = pattern.MakeMesh(Mesh_1.GetMesh(),
|
|
0, 0)</p>
|
|
|
|
<p class="whs7">if (isDone != 1):</p>
|
|
|
|
<p class="whs13">print
|
|
'MakeMesh :', pattern.GetErrorCode()</p>
|
|
|
|
<p class="whs7"> </p>
|
|
|
|
<p class="whs8"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
|
|
</p>
|
|
|
|
<script type="text/javascript" language="javascript1.2">
|
|
<!--
|
|
if (window.writeIntopicBar)
|
|
writeIntopicBar(0);
|
|
//-->
|
|
</script>
|
|
</body>
|
|
</html>
|