smesh/doc/salome/examples/grouping_elements_ex03.py

50 lines
1.6 KiB
Python
Raw Normal View History

2013-02-12 20:37:44 +06:00
# Create a Group on Filter
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
2017-06-13 15:01:10 +05:00
geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
2017-06-13 15:01:10 +05:00
smesh = smeshBuilder.New()
import salome_notebook
2013-02-12 20:37:44 +06:00
box = geompy.MakeBoxDXDYDZ(10,10,10)
# make a mesh with quadrangles of different area in range [1,16]
mesh = smesh.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 = [ \
smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, ">", 1.1, BinaryOp=SMESH.FT_LogicalAND ),
smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, "<", 15.0 )
2013-02-12 20:37:44 +06:00
]
filt = smesh.GetFilterFromCriteria( critaria )
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
filt2 = smesh.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
filt2.SetCriteria( [ smesh.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())
2013-02-12 20:37:44 +06:00
2017-06-13 15:01:10 +05:00
salome.sg.updateObjBrowser()