Salome HOME
updated copyright message
[modules/smesh.git] / test / ex30_groupsOp.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import salome
22 salome.salome_init()
23 import GEOM
24 from salome.geom import geomBuilder
25 geompy = geomBuilder.New()
26
27 import SMESH, SALOMEDS
28 from salome.smesh import smeshBuilder
29 smesh =  smeshBuilder.New()
30 import math
31
32 global Face_1
33 Face_1 = geompy.MakeFaceHW(100, 100, 1)
34 geompy.addToStudy( Face_1, "Face_1" )
35
36 smesh.UpdateStudy()
37 from salome.StdMeshers import StdMeshersBuilder
38 pattern = smesh.GetPattern()
39 Mesh_1 = smesh.Mesh(Face_1)
40 Regular_1D = Mesh_1.Segment()
41 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
42 Nb_Segments_1.SetDistrType( 0 )
43 Quadrangle_2D = Mesh_1.Quadrangle()
44 isDone = Mesh_1.Compute()
45 if not isDone:
46     raise Exception("Error when computing Mesh")
47
48 # groups creation
49
50 aListOfElems = [ 52, 53, 54, 55, 56, 57,
51                  62, 63, 64, 65, 66, 67,
52                  72, 73, 74, 75, 76, 77,
53                  82, 83, 84, 85, 86, 87 ]
54                  
55 aRedGroup = Mesh_1.GetMesh().CreateGroup( SMESH.FACE, "Red" )
56 aRedGroup.Add( aListOfElems );
57 aRedGroup.SetColor( SALOMEDS.Color( 1, 0, 0 ) )
58
59 aListOfElems = [ 55, 56, 57, 58, 59,
60                  65, 66, 67, 68, 69,
61                  75, 76, 77, 78, 79,
62                  85, 86, 87, 88, 89,
63                  95, 96, 97, 98, 99,
64                  105, 106, 107, 108, 109,
65                  115, 116, 117, 118, 119,
66                  125, 126, 127, 128, 129 ]
67                  
68 aGreenGroup = Mesh_1.GetMesh().CreateGroup( SMESH.FACE, "Green" )
69 aGreenGroup.Add( aListOfElems );
70 aGreenGroup.SetColor( SALOMEDS.Color( 0, 1, 0 ) )
71
72 aListOfElems = [ 63, 64, 65, 66, 67, 68, 
73                  73, 74, 75, 76, 77, 78,
74                  83, 84, 85, 86, 87, 88, 
75                  93, 94, 95, 96, 97, 98, 
76                  103, 104, 105, 106, 107, 108, 
77                  113, 114, 115, 116, 117, 118 ]
78                  
79 aBlueGroup = Mesh_1.GetMesh().CreateGroup( SMESH.FACE, "Blue" )
80 aBlueGroup.Add( aListOfElems );
81 aBlueGroup.SetColor( SALOMEDS.Color( 0, 0, 1 ) )
82
83 # UnionListOfGroups()
84 aUnGrp = Mesh_1.UnionListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "UnionGrp" )
85
86 # IntersectListOfGroups()
87 aIntGrp=Mesh_1.IntersectListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "IntGrp" )
88
89 # CutListOfGroups()
90 aCutGrp=Mesh_1.CutListOfGroups([aRedGroup],[aGreenGroup,aBlueGroup],"CutGrp")
91
92 salome.sg.updateObjBrowser()
93