Salome HOME
52976: Find Elements by Point - All does not find Ball element
[modules/smesh.git] / doc / salome / examples / filters_ex01.py
index 03f6c7477913aa069c759aa77bb7d1e718815952..8af735e71aaed8ecfc5dc037c417d4bba0d52c94 100644 (file)
@@ -1,4 +1,5 @@
 # Aspect ratio
+# This script demonstrates various usages of filters
 
 # create mesh
 from SMESH_mechanic import *
@@ -9,12 +10,12 @@ ids = mesh.GetIdsFromFilter(filter)
 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
+# this demostrates that a filter can be used where usually a group or sub-mesh 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
+# create a group (Group on Filter) 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()
 
@@ -22,7 +23,13 @@ print "Number of faces with aspect ratio < 1.5:", group.Size()
 # 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 )
+triaGroup = mesh.MakeGroupByCriteria( "Tria AR < 1.5", crit )
 print "Number of triangles with aspect ratio < 1.5:", triaGroup.Size()
 
+# get range of values of Aspect Ratio of all faces in the mesh
+aspects = mesh.GetMinMax( SMESH.FT_AspectRatio )
+print "MESH: Min aspect = %s, Max aspect = %s" % ( aspects[0], aspects[1] )
+
+# get max value of Aspect Ratio of faces in triaGroup
+grAspects = mesh.GetMinMax( SMESH.FT_AspectRatio, triaGroup )
+print "GROUP: Max aspect = %s" % grAspects[1]