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 aGroup = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
24 salome.sg.updateObjBrowser(1)
27 \image html create_group.png
30 \anchor tui_create_group_on_geometry
31 <h2>Create a Group on Geometry</h2>
39 box = geompy.MakeBox(0., 0., 0., 100., 100., 100.)
40 geompy.addToStudy(box, "box")
42 # add the first face of the box to the study
43 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
44 face = subShapeList[0]
45 geompy.addToStudyInFather(box, face, "face 1")
47 # create group of edges on the face
48 aGeomGroupE = geompy.CreateGroup(face, geompy.ShapeType["EDGE"])
49 geompy.AddObject(aGeomGroupE, 3)
50 geompy.AddObject(aGeomGroupE, 6)
51 geompy.AddObject(aGeomGroupE, 8)
52 geompy.AddObject(aGeomGroupE, 10)
53 geompy.addToStudyInFather(face, aGeomGroupE, "Group of Edges")
55 # create quadrangle 2D mesh on the box
56 quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh")
57 algo1D = quadra.Segment()
59 algo1D.NumberOfSegments(7)
64 # create SMESH group on the face with name "SMESHGroup1"
65 aSmeshGroup1 = quadra.GroupOnGeom(face, "SMESHGroup1")
67 # create SMESH group on <aGeomGroupE> with default name
68 aSmeshGroup2 = quadra.GroupOnGeom(aGeomGroupE)
70 salome.sg.updateObjBrowser(1)
74 \anchor tui_edit_group
80 smesh = SMESH_mechanic.smesh
81 mesh = SMESH_mechanic.mesh
82 salome = SMESH_mechanic.salome
84 # Get ids of all faces with area > 35
85 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 35.)
87 anIds = mesh.GetIdsFromFilter(aFilter)
89 print "Criterion: Area > 35, Nb = ", len(anIds)
91 # create a group by adding elements with area > 35
92 aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > 35")
95 # Get ids of all faces with area > 40
96 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 40.)
98 anIds = mesh.GetIdsFromFilter(aFilter)
100 print "Criterion: Area > 40, Nb = ", len(anIds)
102 # create a group of elements with area [35; 40] by removing elements with area > 40 from group aGroup
106 aGroupElemIDs = aGroup.GetListOfID()
108 print "Criterion: 35 < Area < 40, Nb = ", len(aGroupElemIDs)
111 for i in range(len(aGroupElemIDs)):
112 if j > 20: j = 1; print ""
113 print aGroupElemIDs[i],
118 salome.sg.updateObjBrowser(1)
121 \image html editing_groups1.png
123 \image html editing_groups2.png
126 \anchor tui_union_of_groups
127 <h2>Union of groups</h2>
130 import SMESH_mechanic
132 smesh = SMESH_mechanic.smesh
133 mesh = SMESH_mechanic.mesh
134 salome = SMESH_mechanic.salome
136 # Criterion : AREA > 20
137 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
139 anIds = mesh.GetIdsFromFilter(aFilter)
141 print "Criterion: Area > 20, Nb = ", len( anIds )
143 # create a group by adding elements with area > 20
144 aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
147 # Criterion : AREA = 20
148 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_EqualTo, 20.)
150 anIds = mesh.GetIdsFromFilter(aFilter)
152 print "Criterion: Area = 20, Nb = ", len( anIds )
154 # create a group by adding elements with area = 20
155 aGroup2 = mesh.CreateEmptyGroup( smesh.FACE, "Area = 20" )
159 # create union group : area >= 20
160 aGroup3 = mesh.UnionListOfGroups([aGroup1, aGroup2], "Area >= 20")
161 print "Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID())
162 # Please note that also there is UnionGroups() method which works with two groups only
164 # Criterion : AREA < 20
165 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 20.)
167 anIds = mesh.GetIdsFromFilter(aFilter)
169 print "Criterion: Area < 20, Nb = ", len(anIds)
171 # create a group by adding elements with area < 20
172 aGroup4 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 20")
175 # create union group : area >= 20 and area < 20
176 aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area")
177 print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())
179 salome.sg.updateObjBrowser(1)
182 \image html union_groups1.png
184 \image html union_groups2.png
186 \image html union_groups3.png
189 \anchor tui_intersection_of_groups
190 <h2>Intersection of groups</h2>
193 import SMESH_mechanic
195 smesh = SMESH_mechanic.smesh
196 mesh = SMESH_mechanic.mesh
197 salome = SMESH_mechanic.salome
199 # Criterion : AREA > 20
200 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
202 anIds = mesh.GetIdsFromFilter(aFilter)
204 print "Criterion: Area > 20, Nb = ", len(anIds)
206 # create a group by adding elements with area > 20
207 aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
210 # Criterion : AREA < 60
211 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
213 anIds = mesh.GetIdsFromFilter(aFilter)
215 print "Criterion: Area < 60, Nb = ", len(anIds)
217 # create a group by adding elements with area < 60
218 aGroup2 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 60")
221 # create an intersection of groups : 20 < area < 60
222 aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60")
223 print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())
224 # Please note that also there is IntersectGroups() method which works with two groups only
226 salome.sg.updateObjBrowser(1)
229 \image html intersect_groups1.png
231 \image html intersect_groups2.png
233 \image html intersect_groups3.png
236 \anchor tui_cut_of_groups
237 <h2>Cut of groups</h2>
240 import SMESH_mechanic
242 smesh = SMESH_mechanic.smesh
243 mesh = SMESH_mechanic.mesh
244 salome = SMESH_mechanic.salome
246 # Criterion : AREA > 20
247 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
249 anIds = mesh.GetIdsFromFilter(aFilter)
251 print "Criterion: Area > 20, Nb = ", len(anIds)
253 # create a group by adding elements with area > 20
254 aGroupMain = mesh.MakeGroupByIds("Area > 20", smesh.FACE, anIds)
256 # Criterion : AREA < 60
257 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
259 anIds = mesh.GetIdsFromFilter(aFilter)
261 print "Criterion: Area < 60, Nb = ", len(anIds)
263 # create a group by adding elements with area < 60
264 aGroupTool = mesh.MakeGroupByIds("Area < 60", smesh.FACE, anIds)
266 # create a cut of groups : area >= 60
267 aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
268 print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())
269 # Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths
271 salome.sg.updateObjBrowser(1)
274 \image html cut_groups1.png
276 \image html cut_groups2.png
278 \image html cut_groups3.png
281 \anchor tui_create_dim_group
282 <h2>Creating groups of entities from existing groups of superior dimensions</h2>
285 import SMESH_mechanic
287 smesh = SMESH_mechanic.smesh
288 mesh = SMESH_mechanic.mesh
289 salome = SMESH_mechanic.salome
291 # Criterion : AREA > 100
292 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
294 anIds = mesh.GetIdsFromFilter(aFilter)
296 print "Criterion: Area > 100, Nb = ", len(anIds)
298 # create a group by adding elements with area > 100
299 aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
301 # Criterion : AREA < 30
302 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 30.)
304 anIds = mesh.GetIdsFromFilter(aFilter)
306 print "Criterion: Area < 30, Nb = ", len(anIds)
308 # create a group by adding elements with area < 30
309 aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", smesh.FACE, anIds)
311 # Create group of edges using source groups of faces
312 aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.EDGE, "Edges" )
314 # Create group of nodes using source groups of faces
315 aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.NODE, "Nodes" )
317 salome.sg.updateObjBrowser(1)
320 \image html dimgroup_tui1.png
321 <center>Source groups of faces</center>
323 \image html dimgroup_tui2.png
324 <center>Result groups of edges and nodes</center>