2013-02-12 20:37:44 +06:00
|
|
|
# Create a Group on Filter
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
2021-08-12 14:38:10 +05:00
|
|
|
salome.salome_init_without_session()
|
2013-04-04 13:08:19 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
import SMESH
|
|
|
|
from salome.geom import geomBuilder
|
2013-04-04 13:08:19 +06:00
|
|
|
from salome.smesh import smeshBuilder
|
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
geom_builder = geomBuilder.New()
|
|
|
|
smesh_builder = smeshBuilder.New()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
box = geom_builder.MakeBoxDXDYDZ(10,10,10)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# make a mesh with quadrangles of different area in range [1,16]
|
2022-04-11 18:28:01 +05:00
|
|
|
mesh = smesh_builder.Mesh(box,"Quad mesh")
|
2013-02-12 20:37:44 +06:00
|
|
|
hyp1D = mesh.Segment().StartEndLength( 1, 4 )
|
|
|
|
mesh.Quadrangle()
|
|
|
|
mesh.Compute()
|
|
|
|
|
|
|
|
# create a group on filter selecting faces of medium size
|
|
|
|
critaria = [ \
|
2022-04-11 18:28:01 +05:00
|
|
|
smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, ">", 1.1, BinaryOp=SMESH.FT_LogicalAND ),
|
|
|
|
smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, "<", 15.0 )
|
2013-02-12 20:37:44 +06:00
|
|
|
]
|
2022-04-11 18:28:01 +05:00
|
|
|
filt = smesh_builder.GetFilterFromCriteria( critaria )
|
2013-04-04 13:08:19 +06:00
|
|
|
filtGroup = mesh.GroupOnFilter( SMESH.FACE, "group on filter", filt )
|
2017-12-29 18:20:32 +05:00
|
|
|
print("Group on filter contains %s elements" % filtGroup.Size())
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# group on filter is updated if the mesh is modified
|
|
|
|
hyp1D.SetStartLength( 2.5 )
|
|
|
|
hyp1D.SetEndLength( 2.5 )
|
|
|
|
mesh.Compute()
|
2017-12-29 18:20:32 +05:00
|
|
|
print("After mesh change, group on filter contains %s elements" % filtGroup.Size())
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# set a new filter defining the group
|
2022-04-11 18:28:01 +05:00
|
|
|
filt2 = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_RangeOfIds, "1-50" )
|
2013-02-12 20:37:44 +06:00
|
|
|
filtGroup.SetFilter( filt2 )
|
2017-12-29 18:20:32 +05:00
|
|
|
print("With a new filter, group on filter contains %s elements" % filtGroup.Size())
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# group is updated at modification of the filter
|
2022-04-11 18:28:01 +05:00
|
|
|
filt2.SetCriteria( [ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )])
|
2013-02-12 20:37:44 +06:00
|
|
|
filtIDs3 = filtGroup.GetIDs()
|
2017-12-29 18:20:32 +05:00
|
|
|
print("After filter modification, group on filter contains %s elements" % filtGroup.Size())
|