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_edit_group
84 smesh = SMESH_mechanic.smesh
85 mesh = SMESH_mechanic.mesh
86 salome = SMESH_mechanic.salome
88 # Get ids of all faces with area > 35
89 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 35.)
91 anIds = mesh.GetIdsFromFilter(aFilter)
93 print "Criterion: Area > 35, Nb = ", len(anIds)
95 # create a group by adding elements with area > 35
96 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > 35")
99 # Get ids of all faces with area > 40
100 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 40.)
102 anIds = mesh.GetIdsFromFilter(aFilter)
104 print "Criterion: Area > 40, Nb = ", len(anIds)
106 # create a group of elements with area [35; 40] by removing elements with area > 40 from group aGroup
110 aGroupElemIDs = aGroup.GetListOfID()
112 print "Criterion: 35 < Area < 40, Nb = ", len(aGroupElemIDs)
115 for i in range(len(aGroupElemIDs)):
116 if j > 20: j = 1; print ""
117 print aGroupElemIDs[i],
122 salome.sg.updateObjBrowser(1)
125 \image html editing_groups1.png
127 \image html editing_groups2.png
130 \anchor tui_union_of_groups
131 <h2>Union of groups</h2>
134 import SMESH_mechanic
136 smesh = SMESH_mechanic.smesh
137 mesh = SMESH_mechanic.mesh
138 salome = SMESH_mechanic.salome
140 # Criterion : AREA > 20
141 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
143 anIds = mesh.GetIdsFromFilter(aFilter)
145 print "Criterion: Area > 20, Nb = ", len( anIds )
147 # create a group by adding elements with area > 20
148 aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
151 # Criterion : AREA = 20
152 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_EqualTo, 20.)
154 anIds = mesh.GetIdsFromFilter(aFilter)
156 print "Criterion: Area = 20, Nb = ", len( anIds )
158 # create a group by adding elements with area = 20
159 aGroup2 = mesh.CreateEmptyGroup( smesh.FACE, "Area = 20" )
163 # create union group : area >= 20
164 aGroup3 = mesh.UnionListOfGroups([aGroup1, aGroup2], "Area >= 20")
165 print "Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID())
166 # Please note that also there is UnionGroups() method which works with two groups only
168 # Criterion : AREA < 20
169 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 20.)
171 anIds = mesh.GetIdsFromFilter(aFilter)
173 print "Criterion: Area < 20, Nb = ", len(anIds)
175 # create a group by adding elements with area < 20
176 aGroup4 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 20")
179 # create union group : area >= 20 and area < 20
180 aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area")
181 print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())
183 salome.sg.updateObjBrowser(1)
186 \image html union_groups1.png
188 \image html union_groups2.png
190 \image html union_groups3.png
193 \anchor tui_intersection_of_groups
194 <h2>Intersection of groups</h2>
197 import SMESH_mechanic
199 smesh = SMESH_mechanic.smesh
200 mesh = SMESH_mechanic.mesh
201 salome = SMESH_mechanic.salome
203 # Criterion : AREA > 20
204 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
206 anIds = mesh.GetIdsFromFilter(aFilter)
208 print "Criterion: Area > 20, Nb = ", len(anIds)
210 # create a group by adding elements with area > 20
211 aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
214 # Criterion : AREA < 60
215 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
217 anIds = mesh.GetIdsFromFilter(aFilter)
219 print "Criterion: Area < 60, Nb = ", len(anIds)
221 # create a group by adding elements with area < 60
222 aGroup2 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 60")
225 # create an intersection of groups : 20 < area < 60
226 aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60")
227 print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())
228 # Please note that also there is IntersectGroups() method which works with two groups only
230 salome.sg.updateObjBrowser(1)
233 \image html intersect_groups1.png
235 \image html intersect_groups2.png
237 \image html intersect_groups3.png
240 \anchor tui_cut_of_groups
241 <h2>Cut of groups</h2>
244 import SMESH_mechanic
246 smesh = SMESH_mechanic.smesh
247 mesh = SMESH_mechanic.mesh
248 salome = SMESH_mechanic.salome
250 # Criterion : AREA > 20
251 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
253 anIds = mesh.GetIdsFromFilter(aFilter)
255 print "Criterion: Area > 20, Nb = ", len(anIds)
257 # create a group by adding elements with area > 20
258 aGroupMain = mesh.MakeGroupByIds("Area > 20", smesh.FACE, anIds)
260 # Criterion : AREA < 60
261 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
263 anIds = mesh.GetIdsFromFilter(aFilter)
265 print "Criterion: Area < 60, Nb = ", len(anIds)
267 # create a group by adding elements with area < 60
268 aGroupTool = mesh.MakeGroupByIds("Area < 60", smesh.FACE, anIds)
270 # create a cut of groups : area >= 60
271 aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
272 print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())
273 # Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths
275 salome.sg.updateObjBrowser(1)
278 \image html cut_groups1.png
280 \image html cut_groups2.png
282 \image html cut_groups3.png
285 \anchor tui_create_dim_group
286 <h2>Creating groups of entities from existing groups of superior dimensions</h2>
289 import SMESH_mechanic
291 smesh = SMESH_mechanic.smesh
292 mesh = SMESH_mechanic.mesh
293 salome = SMESH_mechanic.salome
295 # Criterion : AREA > 100
296 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
298 anIds = mesh.GetIdsFromFilter(aFilter)
300 print "Criterion: Area > 100, Nb = ", len(anIds)
302 # create a group by adding elements with area > 100
303 aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
305 # Criterion : AREA < 30
306 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 30.)
308 anIds = mesh.GetIdsFromFilter(aFilter)
310 print "Criterion: Area < 30, Nb = ", len(anIds)
312 # create a group by adding elements with area < 30
313 aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", smesh.FACE, anIds)
315 # Create group of edges using source groups of faces
316 aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.EDGE, "Edges" )
318 # Create group of nodes using source groups of faces
319 aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.NODE, "Nodes" )
321 salome.sg.updateObjBrowser(1)
324 \image html dimgroup_tui1.png
325 <center>Source groups of faces</center>
327 \image html dimgroup_tui2.png
328 <center>Result groups of edges and nodes</center>