1 # Create a Group on Filter
4 salome.salome_init_without_session()
7 from salome.geom import geomBuilder
8 from salome.smesh import smeshBuilder
10 geom_builder = geomBuilder.New()
11 smesh_builder = smeshBuilder.New()
13 box = geom_builder.MakeBoxDXDYDZ(10,10,10)
15 # make a mesh with quadrangles of different area in range [1,16]
16 mesh = smesh_builder.Mesh(box,"Quad mesh")
17 hyp1D = mesh.Segment().StartEndLength( 1, 4 )
19 if not mesh.Compute(): raise Exception("Error when computing Mesh")
21 # create a group on filter selecting faces of medium size
23 smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, ">", 1.1, BinaryOp=SMESH.FT_LogicalAND ),
24 smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, "<", 15.0 )
26 filt = smesh_builder.GetFilterFromCriteria( critaria )
27 filtGroup = mesh.GroupOnFilter( SMESH.FACE, "group on filter", filt )
28 print("Group on filter contains %s elements" % filtGroup.Size())
30 # group on filter is updated if the mesh is modified
31 hyp1D.SetStartLength( 2.5 )
32 hyp1D.SetEndLength( 2.5 )
33 if not mesh.Compute(): raise Exception("Error when computing Mesh")
34 print("After mesh change, group on filter contains %s elements" % filtGroup.Size())
36 # set a new filter defining the group
37 filt2 = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_RangeOfIds, "1-50" )
38 filtGroup.SetFilter( filt2 )
39 print("With a new filter, group on filter contains %s elements" % filtGroup.Size())
41 # group is updated at modification of the filter
42 filt2.SetCriteria( [ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )])
43 filtIDs3 = filtGroup.GetIDs()
44 print("After filter modification, group on filter contains %s elements" % filtGroup.Size())