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

850 lines
23 KiB
HTML
Raw Normal View History

2005-11-28 14:57:47 +05:00
<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
<html>
<head>
<title>Grouping Elements</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; font-weight:bold; color:#ff0000; }
2005-11-28 14:57:47 +05:00
p.whs2 { margin-top:0pt; margin-bottom:0pt; }
p.whs3 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }
p.whs4 { margin-top:0pt; margin-bottom:0pt; font-family:'Times New Roman' , serif; }
img_whs5 { border:none; width:430px; height:391px; float:none; border-style:none; }
p.whs6 { margin-top:0pt; margin-bottom:0pt; color:#ff0000; font-weight:bold; }
img_whs7 { border:none; float:none; width:463px; height:417px; border-style:none; }
img_whs8 { border:none; width:541px; height:417px; float:none; border-style:none; }
img_whs9 { border:none; width:394px; height:425px; float:none; border-style:none; }
img_whs10 { border:none; float:none; width:368px; height:379px; border-style:none; }
img_whs11 { border:none; float:none; width:344px; height:381px; border-style:none; }
img_whs12 { border:none; width:314px; height:351px; float:none; border-style:none; }
img_whs13 { border:none; float:none; width:319px; height:351px; border-style:none; }
img_whs14 { border:none; float:none; width:304px; height:352px; border-style:none; }
img_whs15 { border:none; width:318px; height:355px; float:none; border-style:none; }
img_whs16 { border:none; float:none; width:318px; height:355px; border-style:none; }
img_whs17 { border:none; float:none; width:320px; height:354px; border-style:none; }
2005-11-28 14:57:47 +05:00
-->
</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 += "p.whs4 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs6 {margin-top:1pt;margin-bottom:1pt; }";
2005-11-28 14:57:47 +05:00
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; }
2005-11-28 14:57:47 +05:00
-->
</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">
2005-11-28 14:57:47 +05:00
<!--
if (window.gbWhTopic)
{
if (window.setRelStartPage)
2005-11-28 14:57:47 +05:00
{
addTocInfo("MESH module\nTUI Scripts\nGrouping Elements");
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");
2005-11-28 14:57:47 +05:00
}
if (window.setRelStartPage)
{
setRelStartPage("index.htm");
2005-11-28 14:57:47 +05:00
autoSync(1);
sendSyncInfo();
sendAveInfoOut();
}
2005-11-28 14:57:47 +05:00
}
else
if (window.gbIE4)
document.location.reload();
//-->
</script>
</head>
<body><script type="text/javascript" language="javascript1.2">
<!--
if (window.writeIntopicBar)
writeIntopicBar(4);
//-->
</script>
2005-11-28 14:57:47 +05:00
<h1>Grouping Elements</h1>
2005-11-30 19:59:56 +05:00
<h3><a name=bookmark>Create a Standalone Group</a></h3>
2005-11-28 14:57:47 +05:00
<p class="whs1"># Attention! This script has been written
using the old approach basing on direct usage of SMESH idl interface.</p>
2005-11-28 14:57:47 +05:00
<p class="whs1"># For the moment smesh package doesn't provide
methods to create a standalone group. </p>
2005-11-28 14:57:47 +05:00
<p class="whs1"># In the next SALOME version the scripts will
be updated to use only the commands from smesh package.</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">&nbsp;</p>
<p class="whs3">import SMESH</p>
<p class="whs3">import SMESH_mechanic</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
<p class="whs3">smesh &nbsp;=
2005-11-28 14:57:47 +05:00
SMESH_mechanic.smesh</p>
<p class="whs3">mesh &nbsp;&nbsp;=
2005-11-28 14:57:47 +05:00
SMESH_mechanic.mesh</p>
<p class="whs3">salome = SMESH_mechanic.salome</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Get ids of all faces
with area &gt; 100 </p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilterMgr = smesh.CreateFilterManager()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateMoreThan()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(
2005-11-28 14:57:47 +05:00
aFunctor )</p>
<p class="whs3">aPredicate.SetMargin(
2005-11-28 14:57:47 +05:00
100 )</p>
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(
2005-11-28 14:57:47 +05:00
aPredicate )</p>
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(
2005-11-28 14:57:47 +05:00
mesh )</p>
<p class="whs2">&nbsp;</p>
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs2"># create a group consisting
of faces with area &gt; 100</p>
<p class="whs3">aGroup = mesh.CreateGroup(
2005-11-28 14:57:47 +05:00
SMESH.FACE, &quot;Area &gt; 100&quot; )</p>
<p class="whs3">aGroup.Add( anIds
2005-11-28 14:57:47 +05:00
)</p>
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"><img src="pics/create_group.png" x-maintain-ratio="TRUE" width="430px" height="391px" border="0" class="img_whs5"></p>
2005-11-30 19:59:56 +05:00
<h3><a name=bookmark5>Create a Group on Geometry</a></h3>
2005-11-30 19:59:56 +05:00
<p class="whs3">import salome</p>
<p class="whs3">import geompy</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">import smesh</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs4"># create a box</p>
<p class="whs3">box = geompy.MakeBox(0.,
2005-11-30 19:59:56 +05:00
0., 0., 100., 100., 100.)</p>
<p class="whs3">geompy.addToStudy(box,
2005-11-30 19:59:56 +05:00
&quot;box&quot;)</p>
<p class="whs3">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs4"># add the first face
of the box to the study</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">subShapeList = geompy.SubShapeAll(box,
2005-11-30 19:59:56 +05:00
geompy.ShapeType[&quot;FACE&quot;])</p>
<p class="whs3">face = subShapeList[0]</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">geompy.addToStudyInFather(box,
face, &quot;face 1&quot;)</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs4"># create group of edges
on the face</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">aGeomGroupE = geompy.CreateGroup(face,
geompy.ShapeType[&quot;EDGE&quot;])</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">geompy.AddObject(aGeomGroupE,
3)</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">geompy.AddObject(aGeomGroupE,
6)</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">geompy.AddObject(aGeomGroupE,
8)</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">geompy.AddObject(aGeomGroupE,
10)</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">geompy.addToStudyInFather(face,
aGeomGroupE, &quot;Group of Edges&quot;)</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">&nbsp;</p>
<p class="whs4"># create quadrangle
2D mesh on the box</p>
<p class="whs3">quadra = smesh.Mesh(box,
&quot;Box : quadrangle 2D mesh&quot;)</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">algo1D = quadra.Segment()</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">quadra.Quadrangle()</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">algo1D.NumberOfSegments(7)</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs4"># compute the mesh</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">quadra.Compute()</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs4"># create SMESH group
on the face with name &quot;SMESHGroup1&quot;</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">aSmeshGroup1 = quadra.Group(face,
&quot;SMESHGroup1&quot;)</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs4"># create SMESH group
on &lt;aGeomGroupE&gt; with default name</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">aSmeshGroup2 = quadra.Group(aGeomGroupE)</p>
2005-11-30 19:59:56 +05:00
<p class="whs2">&nbsp;</p>
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
</p>
2005-11-30 19:59:56 +05:00
<h3><a name=bookmark1>Edit a Group</a></h3>
2005-11-30 19:59:56 +05:00
<p class="whs6"># Attention! This script has been written
using the old approach basing on direct usage of SMESH idl interface.</p>
2005-11-30 19:59:56 +05:00
<p class="whs6"># For the moment smesh package doesn't
provide methods to edit a group. </p>
2005-11-30 19:59:56 +05:00
<p class="whs6"># In the next SALOME version the scripts
will be updated to use only the commands from smesh package.</p>
2005-11-30 19:59:56 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">import SMESH</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">import SMESH_mechanic</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">smesh &nbsp;=
2005-11-28 14:57:47 +05:00
SMESH_mechanic.smesh</p>
<p class="whs3">mesh &nbsp;&nbsp;=
2005-11-28 14:57:47 +05:00
SMESH_mechanic.mesh</p>
<p class="whs3">salome = SMESH_mechanic.salome</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Get ids of all faces
with area &gt; 35</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilterMgr = smesh.CreateFilterManager()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateMoreThan()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(aFunctor)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetMargin(35.)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(aPredicate)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(mesh)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
Area &gt; 35, Nb = &quot;, len(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a group by
adding elements with area &gt; 35</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup = mesh.CreateGroup(SMESH.FACE,
&quot;Area &gt; 35&quot;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup.Add(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Get ids of all faces
with area &gt; 40</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateMoreThan()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(aFunctor)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetMargin(40.)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(aPredicate)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(mesh)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
Area &gt; 40, Nb = &quot;, len(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a group of
elements with area [35; 40] by removing elements with area &gt; 40 from
group aGroup</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup.Remove(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># print the result</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroupElemIDs =
aGroup.GetListOfID()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
35 &lt; Area &lt; 40, Nb = &quot;, len(aGroupElemIDs)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">j = 1</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">for i in range(len(aGroupElemIDs)):</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;&nbsp;if
j &gt; 20: j = 1; print &quot;&quot;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;&nbsp;print
aGroupElemIDs[i],</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;&nbsp;j
= j + 1</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;&nbsp;pass</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;&quot;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">salome.sg.updateObjBrowser(1)
2005-11-28 14:57:47 +05:00
</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"><img src="pics/editing_groups1.png" x-maintain-ratio="TRUE" width="463px" height="417px" border="0" class="img_whs7"> &nbsp;<img src="pics/editing_groups2.png" x-maintain-ratio="TRUE" width="541px" height="417px" border="0" class="img_whs8"></p>
2005-11-30 19:59:56 +05:00
2005-11-28 14:57:47 +05:00
<h3><a name=bookmark2>Union of two groups</a></h3>
<p class="whs1"># Attention! This script has been written
using the old approach basing on direct usage of SMESH idl interface.</p>
2005-11-28 14:57:47 +05:00
<p class="whs1"># For the moment smesh package doesn't provide
methods to create a union of two groups. </p>
2005-11-28 14:57:47 +05:00
<p class="whs1"># In the next SALOME version the scripts will
be updated to use only the commands from smesh package.</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3"><span style="font-family: 'Lucida Console', monospace;">import
SMESH</span></p>
2005-11-28 14:57:47 +05:00
<p class="whs3">import SMESH_mechanic</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">smesh &nbsp;=
SMESH_mechanic.smesh</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">mesh &nbsp;&nbsp;=
SMESH_mechanic.mesh</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">salome = SMESH_mechanic.salome</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilterMgr = smesh.CreateFilterManager()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Criterion : AREA
&gt; 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateMoreThan()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(aFunctor)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetMargin(20.)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(aPredicate)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(mesh)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
Area &gt; 20, Nb = &quot;, len( anIds )</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a group by
adding elements with area &gt; 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup1 = mesh.CreateGroup(SMESH.FACE,
&quot;Area &gt; 20&quot;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup1.Add(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Criterion : AREA
= 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateEqualTo()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(aFunctor)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetMargin(20.)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(aPredicate)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(mesh)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
Area = 20, Nb = &quot;, len( anIds )</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a group by
adding elements with area = 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup2 = mesh.CreateGroup(
SMESH.FACE, &quot;Area = 20&quot; )</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup2.Add(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create union group
: area &gt;= 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup3 = mesh.UnionGroups(aGroup1,
2005-11-28 14:57:47 +05:00
aGroup2, &quot;Area &gt;= 20&quot;)</p>
<p class="whs3">print &quot;Criterion:
Area &gt;= 20, Nb = &quot;, len(aGroup3.GetListOfID())</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Criterion : AREA
&lt; 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateLessThan()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(aFunctor)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetMargin(20.)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(aPredicate)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(mesh)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
Area &lt; 20, Nb = &quot;, len(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a group by
adding elements with area &lt; 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup4 = mesh.CreateGroup(SMESH.FACE,
&quot;Area &lt; 20&quot;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup4.Add(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create union group
: area &gt;= 20 and area &lt; 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup5 = mesh.UnionGroups(aGroup3,
2005-11-28 14:57:47 +05:00
aGroup4, &quot;Any Area&quot;)</p>
<p class="whs3">print &quot;Criterion:
Any Area, Nb = &quot;, len(aGroup5.GetListOfID())</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">salome.sg.updateObjBrowser(1)
2005-11-28 14:57:47 +05:00
</p>
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3"><img src="pics/union_groups1.png" x-maintain-ratio="TRUE" width="394px" height="425px" border="0" class="img_whs9"></p>
2005-11-30 19:59:56 +05:00
<p class="whs3">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs3"><img src="pics/union_groups2.png" x-maintain-ratio="TRUE" width="368px" height="379px" border="0" class="img_whs10"> <img src="pics/union_groups3.png" x-maintain-ratio="TRUE" width="344px" height="381px" border="0" class="img_whs11"></p>
2005-11-30 19:59:56 +05:00
<p class="whs3">&nbsp;</p>
2005-11-30 19:59:56 +05:00
2005-11-28 14:57:47 +05:00
<h3><a name=bookmark3>Intersection of two groups</a></h3>
<p class="whs6"># Attention! This script has been written
using the old approach basing on direct usage of SMESH idl interface.</p>
2005-11-28 14:57:47 +05:00
<p class="whs6"># For the moment smesh package doesn't
provide methods to create an intersection of two groups. </p>
2005-11-28 14:57:47 +05:00
<p class="whs6"># In the next SALOME version the scripts
will be updated to use only the commands from smesh package.</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">import SMESH</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">import SMESH_mechanic</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">smesh &nbsp;=
SMESH_mechanic.smesh</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">mesh &nbsp;&nbsp;=
SMESH_mechanic.mesh</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">salome = SMESH_mechanic.salome</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilterMgr = smesh.CreateFilterManager()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Criterion : AREA
&gt; 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateMoreThan()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(aFunctor)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetMargin(20.)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(aPredicate)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(mesh)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
Area &gt; 20, Nb = &quot;, len(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a group by
adding elements with area &gt; 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup1 = mesh.CreateGroup(SMESH.FACE,
&quot;Area &gt; 20&quot;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup1.Add(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Criterion : AREA
&lt; 60</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateLessThan()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(aFunctor)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetMargin(60)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(aPredicate)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(mesh)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
Area &lt; 60, Nb = &quot;, len(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a group by
adding elements with area &lt; 60</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup2 = mesh.CreateGroup(SMESH.FACE,
&quot;Area &lt; 60&quot;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroup2.Add(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create an intersection
2005-11-28 14:57:47 +05:00
of groups : 20 &lt; area &lt; 60</p>
<p class="whs3">aGroup3 = mesh.IntersectGroups(aGroup1,
2005-11-28 14:57:47 +05:00
aGroup2, &quot;20 &lt; Area &lt; 60&quot;)</p>
<p class="whs3">print &quot;Criterion:
20 &lt; Area &lt; 60, Nb = &quot;, len(aGroup3.GetListOfID())</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">salome.sg.updateObjBrowser(1)
2005-11-28 14:57:47 +05:00
</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"><img src="pics/intersect_groups1.png" x-maintain-ratio="TRUE" width="314px" height="351px" border="0" class="img_whs12"> &nbsp;<img src="pics/intersect_groups2.png" x-maintain-ratio="TRUE" width="319px" height="351px" border="0" class="img_whs13"> &nbsp;<img src="pics/intersect_groups3.png" x-maintain-ratio="TRUE" width="304px" height="352px" border="0" class="img_whs14"></p>
2005-11-30 19:59:56 +05:00
2005-11-28 14:57:47 +05:00
<h3><a name=bookmark4>Cut of two groups</a></h3>
<p class="whs1"># Attention! This script has been written
using the old approach basing on direct usage of SMESH idl interface.</p>
2005-11-28 14:57:47 +05:00
<p class="whs1"># For the moment smesh package doesn't provide
methods to create a cut of two groups. </p>
2005-11-28 14:57:47 +05:00
<p class="whs1"># In the next SALOME version the scripts will
be updated to use only the commands from smesh package.</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">import SMESH</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">import SMESH_mechanic</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">smesh &nbsp;=
SMESH_mechanic.smesh</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">mesh &nbsp;&nbsp;=
SMESH_mechanic.mesh</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">salome = SMESH_mechanic.salome</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilterMgr = smesh.CreateFilterManager()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Criterion : AREA
&gt; 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateMoreThan()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(aFunctor)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetMargin(20.)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(aPredicate)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(mesh)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
Area &gt; 20, Nb = &quot;, len(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a group by
adding elements with area &gt; 20</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroupMain = mesh.CreateGroup(SMESH.FACE,
&quot;Area &gt; 20&quot;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroupMain.Add(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># Criterion : AREA
&lt; 60</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFunctor = aFilterMgr.CreateArea()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate = aFilterMgr.CreateLessThan()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetNumFunctor(aFunctor)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aPredicate.SetMargin(60.)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter = aFilterMgr.CreateFilter()</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aFilter.SetPredicate(aPredicate)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">anIds = aFilter.GetElementsId(mesh)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">print &quot;Criterion:
Area &lt; 60, Nb = &quot;, len(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a group by
adding elements with area &lt; 60</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroupTool = mesh.CreateGroup(SMESH.FACE,
&quot;Area &lt; 60&quot;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroupTool.Add(anIds)</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs4"># create a cut of groups
: area &gt;= 60</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">aGroupRes = mesh.CutGroups(aGroupMain,
2005-11-28 14:57:47 +05:00
aGroupTool, &quot;Area &gt;= 60&quot;)</p>
<p class="whs3">print &quot;Criterion:
Area &gt;= 60, Nb = &quot;, len(aGroupRes.GetListOfID())</p>
2005-11-28 14:57:47 +05:00
<p class="whs3">salome.sg.updateObjBrowser(1)
2005-11-28 14:57:47 +05:00
</p>
<p class="whs3">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<p class="whs2"><img src="pics/cut_groups1.png" x-maintain-ratio="TRUE" width="318px" height="355px" border="0" class="img_whs15"> &nbsp;<img src="pics/cut_groups2.png" x-maintain-ratio="TRUE" width="318px" height="355px" border="0" class="img_whs16"> &nbsp;<img src="pics/cut_groups3.png" x-maintain-ratio="TRUE" width="320px" height="354px" border="0" class="img_whs17"></p>
2005-11-28 14:57:47 +05:00
<script type="text/javascript" language="javascript1.2">
<!--
if (window.writeIntopicBar)
writeIntopicBar(0);
//-->
</script>
</body>
</html>