3 \page tui_grouping_elements_page Grouping Elements
6 \anchor tui_create_standalone_group
7 <h2>Create a Standalone Group</h2>
12 smesh = SMESH_mechanic.smesh
13 mesh = SMESH_mechanic.mesh
14 salome = SMESH_mechanic.salome
16 # Get ids of all faces with area > 100
17 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
19 anIds = mesh.GetIdsFromFilter(aFilter)
21 # create a group consisting of faces with area > 100
22 aGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
24 # create a group that contains all nodes from the mesh
25 aGroup2 = mesh.CreateEmptyGroup(smesh.NODE, "all nodes")
26 aGroup2.AddFrom(mesh.mesh)
28 salome.sg.updateObjBrowser(1)
31 \image html create_group.png
34 \anchor tui_create_group_on_geometry
35 <h2>Create a Group on Geometry</h2>
43 box = geompy.MakeBox(0., 0., 0., 100., 100., 100.)
44 geompy.addToStudy(box, "box")
46 # add the first face of the box to the study
47 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
48 face = subShapeList[0]
49 geompy.addToStudyInFather(box, face, "face 1")
51 # create group of edges on the face
52 aGeomGroupE = geompy.CreateGroup(face, geompy.ShapeType["EDGE"])
53 geompy.AddObject(aGeomGroupE, 3)
54 geompy.AddObject(aGeomGroupE, 6)
55 geompy.AddObject(aGeomGroupE, 8)
56 geompy.AddObject(aGeomGroupE, 10)
57 geompy.addToStudyInFather(face, aGeomGroupE, "Group of Edges")
59 # create quadrangle 2D mesh on the box
60 quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh")
61 algo1D = quadra.Segment()
63 algo1D.NumberOfSegments(7)
68 # create SMESH group on the face with name "SMESHGroup1"
69 aSmeshGroup1 = quadra.GroupOnGeom(face, "SMESHGroup1")
71 # create SMESH group on <aGeomGroupE> with default name
72 aSmeshGroup2 = quadra.GroupOnGeom(aGeomGroupE)
74 salome.sg.updateObjBrowser(1)
78 \anchor tui_create_group_on_filter
80 <h2>Create a Group on Filter</h2>
84 SetCurrentStudy(salome.myStudy)
86 box = geompy.MakeBoxDXDYDZ(10,10,10)
88 # make a mesh with quadrangles of different area in range [1,16]
89 mesh = Mesh(box,"Quad mesh")
90 hyp1D = mesh.Segment().StartEndLength( 1, 4 )
94 # create a group on filter selecting faces of medium size
96 GetCriterion(FACE, FT_Area, ">", 1.1, BinaryOp=FT_LogicalAND ),
97 GetCriterion(FACE, FT_Area, "<", 15.0 )
99 filt = GetFilterFromCriteria( critaria )
100 filtGroup = mesh.GroupOnFilter( FACE, "group on filter", filt )
101 print "Group on filter contains %s elemens" % filtGroup.Size()
103 # group on filter is updated if the mesh is modified
104 hyp1D.SetStartLength( 2.5 )
105 hyp1D.SetEndLength( 2.5 )
107 print "After mesh change, group on filter contains %s elemens" % filtGroup.Size()
109 # set a new filter defining the group
110 filt2 = GetFilter( FACE, FT_RangeOfIds, "1-50" )
111 filtGroup.SetFilter( filt2 )
112 print "With a new filter, group on filter contains %s elemens" % filtGroup.Size()
114 # group is updated at modification of the filter
115 filt2.SetCriteria( [ GetCriterion( FACE, FT_RangeOfIds, "1-70" )])
116 filtIDs3 = filtGroup.GetIDs()
117 print "After filter modification, group on filter contains %s elemens" % filtGroup.Size()
119 salome.sg.updateObjBrowser(1)
123 \anchor tui_edit_group
124 <h2>Edit a Group</h2>
127 import SMESH_mechanic
129 smesh = SMESH_mechanic.smesh
130 mesh = SMESH_mechanic.mesh
131 salome = SMESH_mechanic.salome
133 # Get ids of all faces with area > 35
134 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 35.)
136 anIds = mesh.GetIdsFromFilter(aFilter)
138 print "Criterion: Area > 35, Nb = ", len(anIds)
140 # create a group by adding elements with area > 35
141 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > 35")
144 # Get ids of all faces with area > 40
145 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 40.)
147 anIds = mesh.GetIdsFromFilter(aFilter)
149 print "Criterion: Area > 40, Nb = ", len(anIds)
151 # create a group of elements with area [35; 40] by removing elements with area > 40 from group aGroup
155 aGroupElemIDs = aGroup.GetListOfID()
157 print "Criterion: 35 < Area < 40, Nb = ", len(aGroupElemIDs)
160 for i in range(len(aGroupElemIDs)):
161 if j > 20: j = 1; print ""
162 print aGroupElemIDs[i],
167 salome.sg.updateObjBrowser(1)
170 \image html editing_groups1.png
172 \image html editing_groups2.png
175 \anchor tui_union_of_groups
176 <h2>Union of groups</h2>
179 import SMESH_mechanic
181 smesh = SMESH_mechanic.smesh
182 mesh = SMESH_mechanic.mesh
183 salome = SMESH_mechanic.salome
185 # Criterion : AREA > 20
186 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
188 anIds = mesh.GetIdsFromFilter(aFilter)
190 print "Criterion: Area > 20, Nb = ", len( anIds )
192 # create a group by adding elements with area > 20
193 aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
196 # Criterion : AREA = 20
197 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_EqualTo, 20.)
199 anIds = mesh.GetIdsFromFilter(aFilter)
201 print "Criterion: Area = 20, Nb = ", len( anIds )
203 # create a group by adding elements with area = 20
204 aGroup2 = mesh.CreateEmptyGroup( smesh.FACE, "Area = 20" )
208 # create union group : area >= 20
209 aGroup3 = mesh.UnionListOfGroups([aGroup1, aGroup2], "Area >= 20")
210 print "Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID())
211 # Please note that also there is UnionGroups() method which works with two groups only
213 # Criterion : AREA < 20
214 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 20.)
216 anIds = mesh.GetIdsFromFilter(aFilter)
218 print "Criterion: Area < 20, Nb = ", len(anIds)
220 # create a group by adding elements with area < 20
221 aGroup4 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 20")
224 # create union group : area >= 20 and area < 20
225 aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area")
226 print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())
228 salome.sg.updateObjBrowser(1)
231 \image html union_groups1.png
233 \image html union_groups2.png
235 \image html union_groups3.png
238 \anchor tui_intersection_of_groups
239 <h2>Intersection of groups</h2>
242 import SMESH_mechanic
244 smesh = SMESH_mechanic.smesh
245 mesh = SMESH_mechanic.mesh
246 salome = SMESH_mechanic.salome
248 # Criterion : AREA > 20
249 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
251 anIds = mesh.GetIdsFromFilter(aFilter)
253 print "Criterion: Area > 20, Nb = ", len(anIds)
255 # create a group by adding elements with area > 20
256 aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
259 # Criterion : AREA < 60
260 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
262 anIds = mesh.GetIdsFromFilter(aFilter)
264 print "Criterion: Area < 60, Nb = ", len(anIds)
266 # create a group by adding elements with area < 60
267 aGroup2 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 60")
270 # create an intersection of groups : 20 < area < 60
271 aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60")
272 print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())
273 # Please note that also there is IntersectGroups() method which works with two groups only
275 salome.sg.updateObjBrowser(1)
278 \image html intersect_groups1.png
280 \image html intersect_groups2.png
282 \image html intersect_groups3.png
285 \anchor tui_cut_of_groups
286 <h2>Cut of groups</h2>
289 import SMESH_mechanic
291 smesh = SMESH_mechanic.smesh
292 mesh = SMESH_mechanic.mesh
293 salome = SMESH_mechanic.salome
295 # Criterion : AREA > 20
296 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
298 anIds = mesh.GetIdsFromFilter(aFilter)
300 print "Criterion: Area > 20, Nb = ", len(anIds)
302 # create a group by adding elements with area > 20
303 aGroupMain = mesh.MakeGroupByIds("Area > 20", smesh.FACE, anIds)
305 # Criterion : AREA < 60
306 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
308 anIds = mesh.GetIdsFromFilter(aFilter)
310 print "Criterion: Area < 60, Nb = ", len(anIds)
312 # create a group by adding elements with area < 60
313 aGroupTool = mesh.MakeGroupByIds("Area < 60", smesh.FACE, anIds)
315 # create a cut of groups : area >= 60
316 aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
317 print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())
318 # Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths
320 salome.sg.updateObjBrowser(1)
323 \image html cut_groups1.png
325 \image html cut_groups2.png
327 \image html cut_groups3.png
330 \anchor tui_create_dim_group
331 <h2>Creating groups of entities from existing groups of superior dimensions</h2>
334 import SMESH_mechanic
336 smesh = SMESH_mechanic.smesh
337 mesh = SMESH_mechanic.mesh
338 salome = SMESH_mechanic.salome
340 # Criterion : AREA > 100
341 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
343 anIds = mesh.GetIdsFromFilter(aFilter)
345 print "Criterion: Area > 100, Nb = ", len(anIds)
347 # create a group by adding elements with area > 100
348 aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
350 # Criterion : AREA < 30
351 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 30.)
353 anIds = mesh.GetIdsFromFilter(aFilter)
355 print "Criterion: Area < 30, Nb = ", len(anIds)
357 # create a group by adding elements with area < 30
358 aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", smesh.FACE, anIds)
360 # Create group of edges using source groups of faces
361 aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.EDGE, "Edges" )
363 # Create group of nodes using source groups of faces
364 aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.NODE, "Nodes" )
366 salome.sg.updateObjBrowser(1)
369 \image html dimgroup_tui1.png
370 <center>Source groups of faces</center>
372 \image html dimgroup_tui2.png
373 <center>Result groups of edges and nodes</center>