2013-02-12 20:37:44 +06:00
|
|
|
# Create a Standalone Group
|
|
|
|
|
|
|
|
import SMESH_mechanic
|
2013-04-04 13:08:19 +06:00
|
|
|
import SMESH
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
smesh = SMESH_mechanic.smesh
|
|
|
|
mesh = SMESH_mechanic.mesh
|
|
|
|
salome = SMESH_mechanic.salome
|
|
|
|
|
|
|
|
# Get ids of all faces with area > 100
|
2013-04-04 13:08:19 +06:00
|
|
|
aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
anIds = mesh.GetIdsFromFilter(aFilter)
|
|
|
|
|
|
|
|
# create a group consisting of faces with area > 100
|
2013-04-04 13:08:19 +06:00
|
|
|
aGroup1 = mesh.MakeGroupByIds("Area > 100", SMESH.FACE, anIds)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# create a group that contains all nodes from the mesh
|
2013-04-04 13:08:19 +06:00
|
|
|
aGroup2 = mesh.CreateEmptyGroup(SMESH.NODE, "all nodes")
|
2013-02-12 20:37:44 +06:00
|
|
|
aGroup2.AddFrom(mesh.mesh)
|
|
|
|
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# ====================================
|
|
|
|
# Various methods of the Group object
|
|
|
|
# ====================================
|
|
|
|
|
|
|
|
aGroup = mesh.CreateEmptyGroup(SMESH.NODE, "aGroup")
|
|
|
|
|
|
|
|
# set/get group name
|
|
|
|
aGroup.SetName( "new name" )
|
2017-03-20 17:27:30 +05:00
|
|
|
print("name", aGroup.GetName())
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# get group type (type of entities in the group, SMESH.NODE in our case)
|
2017-03-20 17:27:30 +05:00
|
|
|
print("type", aGroup.GetType())
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# get number of entities (nodes in our case) in the group
|
2017-03-20 17:27:30 +05:00
|
|
|
print("size", aGroup.Size())
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# check of emptiness
|
2017-03-20 17:27:30 +05:00
|
|
|
print("is empty", aGroup.IsEmpty())
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# check of presence of an entity in the group
|
2016-05-24 22:37:08 +05:00
|
|
|
aGroup.Add([1,2]) # Add() method is specific to the standalone group
|
2017-03-20 17:27:30 +05:00
|
|
|
print("contains node 2", aGroup.Contains(2))
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# get an entity by index
|
2017-03-20 17:27:30 +05:00
|
|
|
print("1st node", aGroup.GetID(1))
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# get all entities
|
2017-03-20 17:27:30 +05:00
|
|
|
print("all", aGroup.GetIDs())
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# get number of nodes (actual for groups of elements)
|
2017-03-20 17:27:30 +05:00
|
|
|
print("nb nodes", aGroup.GetNumberOfNodes())
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# get underlying nodes (actual for groups of elements)
|
2017-03-20 17:27:30 +05:00
|
|
|
print("nodes", aGroup.GetNodeIDs())
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# set/get color
|
|
|
|
import SALOMEDS
|
|
|
|
aGroup.SetColor( SALOMEDS.Color(1.,1.,0.));
|
2017-03-20 17:27:30 +05:00
|
|
|
print("color", aGroup.GetColor())
|
2016-03-11 18:32:07 +05:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# methods specific to the standalone group and not present in GroupOnGeometry
|
|
|
|
# and GroupOnFilter
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# clear the group's contents
|
|
|
|
aGroup.Clear()
|
|
|
|
|
|
|
|
# add contents of other object (group, sub-mesh, filter)
|
|
|
|
aGroup.AddFrom( aGroup2 )
|
|
|
|
|
|
|
|
# removes entities
|
|
|
|
aGroup.Remove( [2,3,4] )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-06 13:20:14 +05:00
|
|
|
salome.sg.updateObjBrowser(True)
|