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_two_groups
127 <h2>Union of two 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.UnionGroups(aGroup1, aGroup2, "Area >= 20")
161 print "Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID())
163 # Criterion : AREA < 20
164 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 20.)
166 anIds = mesh.GetIdsFromFilter(aFilter)
168 print "Criterion: Area < 20, Nb = ", len(anIds)
170 # create a group by adding elements with area < 20
171 aGroup4 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 20")
174 # create union group : area >= 20 and area < 20
175 aGroup5 = mesh.UnionGroups(aGroup3, aGroup4, "Any Area")
176 print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())
178 salome.sg.updateObjBrowser(1)
181 \image html union_groups1.png
183 \image html union_groups2.png
185 \image html union_groups3.png
188 \anchor tui_intersection_of_two_groups
189 <h2>Intersection of two groups</h2>
192 import SMESH_mechanic
194 smesh = SMESH_mechanic.smesh
195 mesh = SMESH_mechanic.mesh
196 salome = SMESH_mechanic.salome
198 # Criterion : AREA > 20
199 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
201 anIds = mesh.GetIdsFromFilter(aFilter)
203 print "Criterion: Area > 20, Nb = ", len(anIds)
205 # create a group by adding elements with area > 20
206 aGroup1 = mesh.CreateEmptyGroup(SMESH.FACE, "Area > 20")
209 # Criterion : AREA < 60
210 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
212 anIds = mesh.GetIdsFromFilter(aFilter)
214 print "Criterion: Area < 60, Nb = ", len(anIds)
216 # create a group by adding elements with area < 60
217 aGroup2 = mesh.CreateEmptyGroup(SMESH.FACE, "Area < 60")
220 # create an intersection of groups : 20 < area < 60
221 aGroup3 = mesh.IntersectGroups(aGroup1, aGroup2, "20 < Area < 60")
222 print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())
224 salome.sg.updateObjBrowser(1)
227 \image html intersect_groups1.png
229 \image html intersect_groups2.png
231 \image html intersect_groups3.png
234 \anchor tui_cut_of_two_groups
235 <h2>Cut of two groups</h2>
238 import SMESH_mechanic
240 smesh = SMESH_mechanic.smesh
241 mesh = SMESH_mechanic.mesh
242 salome = SMESH_mechanic.salome
244 # Criterion : AREA > 20
245 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
247 anIds = mesh.GetIdsFromFilter(aFilter)
249 print "Criterion: Area > 20, Nb = ", len(anIds)
251 # create a group by adding elements with area > 20
252 aGroupMain = mesh.MakeGroupByIds("Area > 20", smesh.FACE, anIds)
254 # Criterion : AREA < 60
255 aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
257 anIds = mesh.GetIdsFromFilter(aFilter)
259 print "Criterion: Area < 60, Nb = ", len(anIds)
261 # create a group by adding elements with area < 60
262 aGroupTool = mesh.MakeGroupByIds("Area < 60", smesh.FACE, anIds)
264 # create a cut of groups : area >= 60
265 aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
266 print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())
268 salome.sg.updateObjBrowser(1)
271 \image html cut_groups1.png
273 \image html cut_groups2.png
275 \image html cut_groups3.png