mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-16 10:38:33 +05:00
271 lines
6.7 KiB
HTML
271 lines
6.7 KiB
HTML
|
<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
|
||
|
|
||
|
<html>
|
||
|
|
||
|
<head>
|
||
|
<title>smesh.py_introduction</title>
|
||
|
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
|
||
|
<meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com"><style type="text/css">
|
||
|
<!--
|
||
|
p.whs1 { margin-top:0pt; margin-bottom:0pt; }
|
||
|
p.whs2 { margin-top:0pt; margin-bottom:0pt; 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 +="</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\nIntroduction to MESH module python interface");
|
||
|
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>Introduction to MESH module python interface</h1>
|
||
|
|
||
|
<p class="whs1">Package smesh provides
|
||
|
a standard API for creation and edition of meshes . </p>
|
||
|
|
||
|
<p class="whs1">Below you can see an example
|
||
|
of usage of the package smesh for 3d mesh generation. </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1">Example of 3d mesh generation
|
||
|
with NETGEN</p>
|
||
|
|
||
|
<p class="whs1">from geompy import * </p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
||
|
smesh</span> </p>
|
||
|
|
||
|
<p class="whs1"># Geometry </p>
|
||
|
|
||
|
<p class="whs1"># an assembly of a box,
|
||
|
a cylinder and a truncated cone meshed with tetrahedral. </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Define values </p>
|
||
|
|
||
|
<p class="whs2">name = "ex21_lamp"
|
||
|
</p>
|
||
|
|
||
|
<p class="whs2">cote = 60 </p>
|
||
|
|
||
|
<p class="whs2">section = 20 </p>
|
||
|
|
||
|
<p class="whs2">size = 200 </p>
|
||
|
|
||
|
<p class="whs2">radius_1 = 80 </p>
|
||
|
|
||
|
<p class="whs2">radius_2 = 40 </p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">height
|
||
|
= 100</span> </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Build a box </p>
|
||
|
|
||
|
<p class="whs2">box = MakeBox(-cote,
|
||
|
-cote, -cote, +cote, +cote, +cote) </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Build a cylinder </p>
|
||
|
|
||
|
<p class="whs2">pt1 = MakeVertex(0,
|
||
|
0, cote/3) </p>
|
||
|
|
||
|
<p class="whs2">di1 = MakeVectorDXDYDZ(0,
|
||
|
0, 1) </p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">cyl
|
||
|
= MakeCylinder(pt1, di1, section, size)</span> </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Build a truncated cone
|
||
|
</p>
|
||
|
|
||
|
<p class="whs2">pt2 = MakeVertex(0,
|
||
|
0, size) </p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">cone
|
||
|
= MakeCone(pt2, di1, radius_1, radius_2, height)</span> </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Fuse </p>
|
||
|
|
||
|
<p class="whs2">box_cyl = MakeFuse(box,
|
||
|
cyl) </p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">piece
|
||
|
= MakeFuse(box_cyl, cone)</span> </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Add in study </p>
|
||
|
|
||
|
<p class="whs2">addToStudy(piece,
|
||
|
name) </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Create a group of faces
|
||
|
</p>
|
||
|
|
||
|
<p class="whs2">group = CreateGroup(piece,
|
||
|
ShapeType["FACE"]) </p>
|
||
|
|
||
|
<p class="whs2">group_name = name
|
||
|
+ "_grp" </p>
|
||
|
|
||
|
<p class="whs2">addToStudy(group,
|
||
|
group_name) </p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">group.SetName(group_name)</span>
|
||
|
</p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Add faces in the group
|
||
|
</p>
|
||
|
|
||
|
<p class="whs2">faces = SubShapeAllIDs(piece,
|
||
|
ShapeType["FACE"]) </p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">UnionIDs(group,
|
||
|
faces)</span> </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Create a mesh </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Define a mesh on a geometry
|
||
|
</p>
|
||
|
|
||
|
<p class="whs2">tetra = smesh.Mesh(piece,
|
||
|
name) </p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Define 1D hypothesis
|
||
|
</p>
|
||
|
|
||
|
<p class="whs2">algo1d = tetra.Segment()
|
||
|
</p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">algo1d.LocalLength(10)</span>
|
||
|
</p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Define 2D hypothesis
|
||
|
</p>
|
||
|
|
||
|
<p class="whs2">algo2d = tetra.Triangle()
|
||
|
</p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">algo2d.LengthFromEdges()</span>
|
||
|
</p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Define 3D hypothesis
|
||
|
</p>
|
||
|
|
||
|
<p class="whs2">algo3d = tetra.Tetrahedron(smesh.NETGEN)
|
||
|
</p>
|
||
|
|
||
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">algo3d.MaxElementVolume(100)</span>
|
||
|
</p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Compute the mesh </p>
|
||
|
|
||
|
<p class="whs2">tetra.Compute()
|
||
|
</p>
|
||
|
|
||
|
<p class="whs1"> </p>
|
||
|
|
||
|
<p class="whs1"># Create a groupe of faces
|
||
|
</p>
|
||
|
|
||
|
<p class="whs2">tetra.Group(group)
|
||
|
</p>
|
||
|
|
||
|
<script type="text/javascript" language="javascript1.2">
|
||
|
<!--
|
||
|
if (window.writeIntopicBar)
|
||
|
writeIntopicBar(0);
|
||
|
//-->
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|