From: eap Date: Mon, 2 Sep 2013 10:47:47 +0000 (+0000) Subject: More examples of filter usage X-Git-Tag: V7_3_0a1~173 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=273e825aa2dcad11d9a07a3c37451d62685545ff;p=modules%2Fsmesh.git More examples of filter usage --- diff --git a/doc/salome/examples/filters_ex01.py b/doc/salome/examples/filters_ex01.py index 86be38182..03f6c7477 100644 --- a/doc/salome/examples/filters_ex01.py +++ b/doc/salome/examples/filters_ex01.py @@ -2,7 +2,27 @@ # create mesh from SMESH_mechanic import * -# get faces with aspect ratio > 6.5 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 6.5) + +# get faces with aspect ratio > 1.5 +filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 1.5) ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with aspect ratio > 6.5:", len(ids) +print "Number of faces with aspect ratio > 1.5:", len(ids) + +# copy the faces with aspect ratio > 1.5 to another mesh; +# this demostrates that a filter can be used where usually a group or submesh is acceptable +filter.SetMesh( mesh.GetMesh() ) +mesh2 = smesh.CopyMesh( filter, "AR > 1.5" ) +print "Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces() + +# create a Group of faces with Aspect Ratio < 1.5 +group = mesh.MakeGroup("AR < 1.5", SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5) +print "Number of faces with aspect ratio < 1.5:", group.Size() + +# combine several criteria to Create a Group of only Triangular faces with Aspect Ratio < 1.5; +# note that contents of a GroupOnFilter is dynamically updated as the mesh changes +crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5, BinaryOp=SMESH.FT_LogicalAND ), + smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) ] +filter = smesh.GetFilterFromCriteria( crit ) +triaGroup = mesh.GroupOnFilter( SMESH.FACE, "Tria AR < 1.5", filter ) +print "Number of triangles with aspect ratio < 1.5:", triaGroup.Size() +