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

969 lines
24 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-family:'Lucida Console' , monospace; }
p.whs2 { margin-top:0pt; margin-bottom:0pt; }
2005-11-30 19:59:56 +05:00
img_whs3 { border:none; width:430px; height:391px; float:none; border-style:none; }
img_whs4 { border:none; float:none; width:463px; height:417px; border-style:none; }
img_whs5 { border:none; width:541px; height:417px; float:none; border-style:none; }
img_whs6 { border:none; width:394px; height:425px; float:none; border-style:none; }
img_whs7 { border:none; float:none; width:368px; height:379px; border-style:none; }
img_whs8 { border:none; float:none; width:344px; height:381px; border-style:none; }
img_whs9 { border:none; width:314px; height:351px; float:none; border-style:none; }
img_whs10 { border:none; float:none; width:319px; height:351px; border-style:none; }
img_whs11 { border:none; float:none; width:304px; height:352px; border-style:none; }
img_whs12 { border:none; width:318px; height:355px; float:none; border-style:none; }
img_whs13 { border:none; float:none; width:318px; height:355px; border-style:none; }
img_whs14 { 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 +="</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; }
-->
</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>
</head>
<body><script type="text/javascript" language="javascript1.2">
<!--
if (window.gbWhTopic)
{
if (window.addTocInfo)
{
addTocInfo("MESH module\nTUI Scripts\nGrouping Elements");
addButton("show",BTN_TEXT,"Show","","","","",0,0,"","","");
}
if (window.writeBtnStyle)
writeBtnStyle();
if (window.writeIntopicBar)
writeIntopicBar(1);
if (window.setRelStartPage)
{
setRelStartPage("smesh.htm");
autoSync(1);
sendSyncInfo();
sendAveInfoOut();
}
}
else
if (window.gbIE4)
document.location.reload();
//-->
</script>
<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">&nbsp;</p>
<p class="whs1">import SMESH</p>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">smesh &nbsp;=
SMESH_mechanic.smesh</p>
<p class="whs1">mesh &nbsp;&nbsp;=
SMESH_mechanic.mesh</p>
<p class="whs1">salome = SMESH_mechanic.salome</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilterMgr = smesh.CreateFilterManager()</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA &gt;
100</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateMoreThan()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
100 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># print the result</p>
<p class="whs1">print &quot;Criterion:
Area &gt; 100 Nb = &quot;, len( anIds )</p>
<p class="whs1">for i in range(
len( anIds ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
anIds[ i ]</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create a group consisting
of faces with area &gt; 100</p>
<p class="whs1">aGroup = mesh.CreateGroup(
SMESH.FACE, &quot;Area &gt; 100&quot; )</p>
<p class="whs1">aGroup.Add( anIds
)</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
</p>
<p class="whs2">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs2"><img src="pics/create_group.png" x-maintain-ratio="TRUE" width="430px" height="391px" border="0" class="img_whs3"></p>
<h3><a name=bookmark5>Create a Group on Geometry</a></h3>
2005-11-30 19:59:56 +05:00
<p class="whs1">import salome</p>
<p class="whs1">import geompy</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">import SMESH</p>
2005-11-30 19:59:56 +05:00
<p class="whs1">import StdMeshers</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">smesh = salome.lcc.FindOrLoadComponent(&quot;FactoryServer&quot;,
&quot;SMESH&quot;)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># create a box</p>
<p class="whs1">box = geompy.MakeBox(0.,
0., 0., 100., 100., 100.)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># add the box to the study</p>
<p class="whs1">idbox = geompy.addToStudy(box,
&quot;box&quot;)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># add the first face of
the box to the study</p>
<p class="whs1">subShapeList = geompy.SubShapeAll(box,
geompy.ShapeType[&quot;FACE&quot;])</p>
<p class="whs1">face = subShapeList[0]</p>
<p class="whs1">name = geompy.SubShapeName(face,
box)</p>
<p class="whs1">idface = geompy.addToStudyInFather(box,
face, name)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># create a hypothesis</p>
<p class="whs1">numberOfSegments
= 7</p>
<p class="whs1">hypNbSeg = smesh.CreateHypothesis(&quot;NumberOfSegments&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs1">hypNbSeg.SetNumberOfSegments(numberOfSegments)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># create algorithms</p>
<p class="whs1">regular1D = smesh.CreateHypothesis(&quot;Regular_1D&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs1">quad2D = smesh.CreateHypothesis(&quot;Quadrangle_2D&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># initialize a mesh with
the box</p>
<p class="whs1">mesh = smesh.CreateMesh(box)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># add hypotheses and algorithms
to the box</p>
2005-11-30 19:59:56 +05:00
<p class="whs1">mesh.AddHypothesis(box,hypNbSeg)</p>
<p class="whs1">mesh.AddHypothesis(box,regular1D)</p>
<p class="whs1">mesh.AddHypothesis(box,quad2D)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># compute the mesh</p>
<p class="whs1">ret = smesh.Compute(mesh,box)</p>
<p class="whs1">if ret == 0:</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;probleme when computing the mesh&quot;</p>
<p class="whs1">else:</p>
<p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;Computation succeded&quot;</p>
2005-11-30 19:59:56 +05:00
<p class="whs2">&nbsp;</p>
<p class="whs2"># create geometry groups
on the face</p>
2005-11-30 19:59:56 +05:00
<p class="whs1">aGeomGroup1 = geompy.CreateGroup(face,
geompy.ShapeType[&quot;FACE&quot;])</p>
2005-11-30 19:59:56 +05:00
<p class="whs1">geompy.AddObject(aGeomGroup1,
1)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aGeomGroup2 = geompy.CreateGroup(face,
geompy.ShapeType[&quot;EDGE&quot;])</p>
2005-11-30 19:59:56 +05:00
<p class="whs1">geompy.AddObject(aGeomGroup2,
3)</p>
<p class="whs1">geompy.AddObject(aGeomGroup2,
6)</p>
<p class="whs1">geompy.AddObject(aGeomGroup2,
8)</p>
<p class="whs1">geompy.AddObject(aGeomGroup2,
10)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">geompy.addToStudy(aGeomGroup1,
&quot;Group on Faces&quot;)</p>
<p class="whs1">geompy.addToStudy(aGeomGroup2,
&quot;Group on Edges&quot;)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># create SMESH groups</p>
2005-11-30 19:59:56 +05:00
<p class="whs1">aSmeshGroup1 = mesh.CreateGroupFromGEOM(SMESH.FACE,
&quot;SMESHGroup1&quot;,</p>
<p class="whs1">aGeomGroup1)</p>
2005-11-30 19:59:56 +05:00
<p class="whs1">aSmeshGroup2 = mesh.CreateGroupFromGEOM(SMESH.EDGE,
&quot;SMESHGroup2&quot;, aGeomGroup2)</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs2">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<h3><a name=bookmark1>Edit a Group</a></h3>
<p class="whs1">import SMESH</p>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">smesh &nbsp;=
SMESH_mechanic.smesh</p>
<p class="whs1">mesh &nbsp;&nbsp;=
SMESH_mechanic.mesh</p>
<p class="whs1">salome = SMESH_mechanic.salome</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilterMgr = smesh.CreateFilterManager()</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA &gt;
20</p>
<p class="whs2">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateMoreThan()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
30 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create a group by adding
elements with area &gt; 20</p>
<p class="whs1">aGroup = mesh.CreateGroup(
SMESH.FACE, &quot;Area &gt; 20&quot; )</p>
<p class="whs1">aGroup.Add( anIds
)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">print &quot;Criterion:
Area &gt; 20 Nb = &quot;, len( anIds )</p>
<p class="whs1">for i in range(
len( anIds ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
anIds[ i ]</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA &gt;
60</p>
<p class="whs2">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateMoreThan()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
60 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># create a group of elements
with area [20; 60] by removing elements with area &gt; 60 from &nbsp;group
aGroup </p>
<p class="whs1">aGroup.Remove(anIds)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># print the result</p>
<p class="whs1">aGroupElemIDs =
aGroup.GetListOfID()</p>
<p class="whs1">print &quot;Criterion:
20 &lt; Area &lt; 60 = &quot;, len( aGroupElemIDs )</p>
<p class="whs1">for i in range(
len( aGroupElemIDs ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
aGroupElemIDs[ i ]</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
</p>
<p class="whs2">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs2"><img src="pics/editing_groups1.png" x-maintain-ratio="TRUE" width="463px" height="417px" border="0" class="img_whs4"> &nbsp;<img src="pics/editing_groups2.png" x-maintain-ratio="TRUE" width="541px" height="417px" border="0" class="img_whs5"></p>
2005-11-28 14:57:47 +05:00
<h3><a name=bookmark2>Union of two groups</a></h3>
<p class="whs1">import SMESH</p>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">smesh &nbsp;=
SMESH_mechanic.smesh</p>
<p class="whs1">mesh &nbsp;&nbsp;=
SMESH_mechanic.mesh</p>
<p class="whs1">salome = SMESH_mechanic.salome</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilterMgr = smesh.CreateFilterManager()</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA &gt;
20</p>
<p class="whs2">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateMoreThan()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
20 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create a group by adding
elements with area &gt; 20</p>
<p class="whs1">aGroup1 = mesh.CreateGroup(
SMESH.FACE, &quot;Area &gt; 20&quot; )</p>
<p class="whs1">aGroup1.Add( anIds
)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">print &quot;Criterion:
Area &gt; 20 Nb = &quot;, len( anIds )</p>
<p class="whs1">for i in range(
len( anIds ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
anIds[ i ]</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA = 20</p>
<p class="whs2">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateEqualTo()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
20 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># create a group by adding
elements with area &gt; 20</p>
<p class="whs1">aGroup2 = mesh.CreateGroup(
SMESH.FACE, &quot;Area = 20&quot; )</p>
<p class="whs1">aGroup2.Add( anIds
)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">print &quot;Criterion:
Area = 20 Nb = &quot;, len( anIds )</p>
<p class="whs1">for i in range(
len( anIds ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
anIds[ i ]</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"># create union group :
area &gt;= 20</p>
<p class="whs1">aGroup3 = mesh.UnionGroups(aGroup1,
aGroup2, &quot;Area &gt;= 20&quot;)</p>
<p class="whs1">print &quot;Criterion:
Area &gt;= 20 Nb = &quot;, len( aGroup3.GetListOfID() )</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA &lt;
20</p>
<p class="whs2">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateLessThan()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
20 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create a group by adding
elements with area &lt; 20</p>
<p class="whs1">aGroup4 = mesh.CreateGroup(
SMESH.FACE, &quot;Area &lt; 20&quot; )</p>
<p class="whs1">aGroup4.Add( anIds
)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">print &quot;Criterion:
Area &lt; 20 Nb = &quot;, len( anIds )</p>
<p class="whs1">for i in range(
len( anIds ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
anIds[ i ]</p>
<p class="whs2">&nbsp;&nbsp;</p>
<p class="whs2"># create union group :
area &gt;= 20 and area &lt; 20</p>
<p class="whs1">aGroup5 = mesh.UnionGroups(aGroup3,
aGroup4, &quot;Any Area&quot;)</p>
<p class="whs1">print &quot;Criterion:
Any Area Nb = &quot;, len( aGroup5.GetListOfID() )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">salome.sg.updateObjBrowser(1)
</p>
<p class="whs1">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs1"><img src="pics/union_groups1.png" x-maintain-ratio="TRUE" width="394px" height="425px" border="0" class="img_whs6"></p>
<p class="whs1">&nbsp;</p>
<p class="whs1"><img src="pics/union_groups2.png" x-maintain-ratio="TRUE" width="368px" height="379px" border="0" class="img_whs7"> <img src="pics/union_groups3.png" x-maintain-ratio="TRUE" width="344px" height="381px" border="0" class="img_whs8"></p>
<p class="whs1">&nbsp;</p>
2005-11-28 14:57:47 +05:00
<h3><a name=bookmark3>Intersection of two groups</a></h3>
<p class="whs1">import SMESH</p>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">smesh &nbsp;=
SMESH_mechanic.smesh</p>
<p class="whs1">mesh &nbsp;&nbsp;=
SMESH_mechanic.mesh</p>
<p class="whs1">salome = SMESH_mechanic.salome</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilterMgr = smesh.CreateFilterManager()</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA &gt;
20</p>
<p class="whs2">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateMoreThan()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
20 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create a group by adding
elements with area &gt; 20</p>
<p class="whs1">aGroup1 = mesh.CreateGroup(
SMESH.FACE, &quot;Area &gt; 20&quot; )</p>
<p class="whs1">aGroup1.Add( anIds
)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">print &quot;Criterion:
Area &gt; 20 Nb = &quot;, len( anIds )</p>
<p class="whs1">for i in range(
len( anIds ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
anIds[ i ]</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA &lt;
60</p>
<p class="whs2">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateLessThan()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
60 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create a group by adding
elements with area &lt; 60</p>
<p class="whs1">aGroup2 = mesh.CreateGroup(
SMESH.FACE, &quot;Area &lt; 60&quot; )</p>
<p class="whs1">aGroup2.Add( anIds
)</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">print &quot;Criterion:
Area &lt; 60 Nb = &quot;, len( anIds )</p>
<p class="whs1">for i in range(
len( anIds ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
anIds[ i ]</p>
<p class="whs2">&nbsp;&nbsp;</p>
<p class="whs2"># create an intersection
of groups : 20 &lt; area &lt; 60</p>
<p class="whs1">aGroup3 = mesh.IntersectGroups(aGroup1,
aGroup2, &quot;20 &lt; Area &lt; 60&quot;)</p>
<p class="whs1">print &quot;Criterion:
20 &lt; Area &lt; 60 Nb = &quot;, len( aGroup3.GetListOfID() )</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"><span style="font-family: 'Lucida Console', monospace;">salome.sg.updateObjBrowser(1)</span>
</p>
<p class="whs2">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs2"><img src="pics/intersect_groups1.png" x-maintain-ratio="TRUE" width="314px" height="351px" border="0" class="img_whs9"> &nbsp;<img src="pics/intersect_groups2.png" x-maintain-ratio="TRUE" width="319px" height="351px" border="0" class="img_whs10"> &nbsp;<img src="pics/intersect_groups3.png" x-maintain-ratio="TRUE" width="304px" height="352px" border="0" class="img_whs11"></p>
2005-11-28 14:57:47 +05:00
<h3><a name=bookmark4>Cut of two groups</a></h3>
<p class="whs1">import SMESH</p>
<p class="whs1">import SMESH_mechanic</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">smesh &nbsp;=
SMESH_mechanic.smesh</p>
<p class="whs1">mesh &nbsp;&nbsp;=
SMESH_mechanic.mesh</p>
<p class="whs1">salome = SMESH_mechanic.salome</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilterMgr = smesh.CreateFilterManager()</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA &gt;
20</p>
<p class="whs2">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateMoreThan()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
20 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create a group by adding
elements with area &gt; 20</p>
<p class="whs1">aGroupMain = mesh.CreateGroup(
SMESH.FACE, &quot;Area &gt; 20&quot; )</p>
<p class="whs1">aGroupMain.Add(
anIds )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">print &quot;Criterion:
Area &gt; 20 Nb = &quot;, len( anIds )</p>
<p class="whs1">for i in range(
len( anIds ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
anIds[ i ]</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># Criterion : AREA &lt;
60</p>
<p class="whs2">&nbsp;</p>
<p class="whs1">aFunctor = aFilterMgr.CreateArea()</p>
<p class="whs1">aPredicate = aFilterMgr.CreateLessThan()</p>
<p class="whs1">aPredicate.SetNumFunctor(
aFunctor )</p>
<p class="whs1">aPredicate.SetMargin(
60 )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">aFilter = aFilterMgr.CreateFilter()</p>
<p class="whs1">aFilter.SetPredicate(
aPredicate )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">anIds = aFilter.GetElementsId(
mesh )</p>
<p class="whs1">&nbsp;</p>
<p class="whs2"># create a group by adding
elements with area &lt; 60</p>
<p class="whs1">aGroupTool = mesh.CreateGroup(
SMESH.FACE, &quot;Area &lt; 60&quot; )</p>
<p class="whs1">aGroupTool.Add(
anIds )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">print &quot;Criterion:
Area &lt; 60 Nb = &quot;, len( anIds )</p>
<p class="whs1">for i in range(
len( anIds ) ):</p>
<p class="whs1">&nbsp;&nbsp;print
anIds[ i ]</p>
<p class="whs2">&nbsp;&nbsp;</p>
<p class="whs2"># create an intersection
of groups : area &gt;= 60</p>
<p class="whs1">aGroupRes = mesh.CutGroups(aGroupMain,
aGroupTool, &quot;Area &gt;= 60&quot;)</p>
<p class="whs1">print &quot;Criterion:
Area &gt;= 60 Nb = &quot;, len( aGroupRes.GetListOfID() )</p>
<p class="whs1">&nbsp;</p>
<p class="whs1">salome.sg.updateObjBrowser(1)
</p>
<p class="whs1">&nbsp;</p>
2005-11-30 19:59:56 +05:00
<p class="whs2"><img src="pics/cut_groups1.png" x-maintain-ratio="TRUE" width="318px" height="355px" border="0" class="img_whs12"> &nbsp;<img src="pics/cut_groups2.png" x-maintain-ratio="TRUE" width="318px" height="355px" border="0" class="img_whs13"> &nbsp;<img src="pics/cut_groups3.png" x-maintain-ratio="TRUE" width="320px" height="354px" border="0" class="img_whs14"></p>
2005-11-28 14:57:47 +05:00
<script type="text/javascript" language="javascript1.2">
<!--
if (window.writeIntopicBar)
writeIntopicBar(0);
//-->
</script>
</body>
</html>