Salome HOME
Minor DOC changes
[modules/smesh.git] / doc / salome / examples / filters_ex01.py
index 88305c97f9523b52ad8809b37456bf7bf1d031a1..812e9428878883a49f86ffef2189c7bc7c2d6cc5 100644 (file)
@@ -1,16 +1,22 @@
 # Aspect ratio
+# This script demonstrates various usages of filters
 
 # create mesh
 from SMESH_mechanic import *
 
-# get faces with aspect ratio > 1.5
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 1.5)
+# get faces with aspect ratio > 2.5
+filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 2.5)
 ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with aspect ratio > 2.5:", len(ids)
+
+# get faces with aspect ratio > 1.5
+filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, '>', 1.5, mesh=mesh)
+ids = filter.GetIDs()
 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 sub-mesh is acceptable
-filter.SetMesh( mesh.GetMesh() )
+filter.SetMesh( mesh.GetMesh() ) # - actually non necessary as mesh is set at filter creation
 mesh2 = smesh.CopyMesh( filter, "AR > 1.5" )
 print "Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces()
 
@@ -32,3 +38,7 @@ 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]
+
+# get Aspect Ratio of an element
+aspect = mesh.FunctorValue( SMESH.FT_AspectRatio, ids[0] )
+print "Aspect ratio of the face %s = %s" % ( ids[0], aspect )