Salome HOME
PR: merged from V5_1_4rc1
[modules/smesh.git] / src / SMESH_SWIG / ex30_groupsOp.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2010  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.
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 sys
22 import salome
23 import geompy
24 import math
25 import SALOMEDS
26 import SMESH
27 import smesh
28
29 salome.salome_init()
30 aStudyId = salome.myStudy._get_StudyId()
31
32 geompy.init_geom(salome.myStudy)
33 global Face_1
34 Face_1 = geompy.MakeFaceHW(100, 100, 1)
35 geompy.addToStudy( Face_1, "Face_1" )
36
37 smesh.SetCurrentStudy(salome.myStudy)
38 import StdMeshers
39 pattern = smesh.GetPattern()
40 Mesh_1 = smesh.Mesh(Face_1)
41 Regular_1D = Mesh_1.Segment()
42 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
43 Nb_Segments_1.SetDistrType( 0 )
44 Quadrangle_2D = Mesh_1.Quadrangle()
45 isDone = Mesh_1.Compute()
46
47 # groups creation
48
49 aListOfElems = [ 52, 53, 54, 55, 56, 57,
50                  62, 63, 64, 65, 66, 67,
51                  72, 73, 74, 75, 76, 77,
52                  82, 83, 84, 85, 86, 87 ]
53                  
54 aRedGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Red" )
55 aRedGroup.Add( aListOfElems );
56 aRedGroup.SetColor( SALOMEDS.Color( 1, 0, 0 ) )
57
58 aListOfElems = [ 55, 56, 57, 58, 59,
59                  65, 66, 67, 68, 69,
60                  75, 76, 77, 78, 79,
61                  85, 86, 87, 88, 89,
62                  95, 96, 97, 98, 99,
63                  105, 106, 107, 108, 109,
64                  115, 116, 117, 118, 119,
65                  125, 126, 127, 128, 129 ]
66                  
67 aGreenGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Green" )
68 aGreenGroup.Add( aListOfElems );
69 aGreenGroup.SetColor( SALOMEDS.Color( 0, 1, 0 ) )
70
71 aListOfElems = [ 63, 64, 65, 66, 67, 68, 
72                  73, 74, 75, 76, 77, 78,
73                  83, 84, 85, 86, 87, 88, 
74                  93, 94, 95, 96, 97, 98, 
75                  103, 104, 105, 106, 107, 108, 
76                  113, 114, 115, 116, 117, 118 ]
77                  
78 aBlueGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Blue" )
79 aBlueGroup.Add( aListOfElems );
80 aBlueGroup.SetColor( SALOMEDS.Color( 0, 0, 1 ) )
81
82 # UnionListOfGroups()
83 aUnGrp = Mesh_1.UnionListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "UnionGrp" )
84
85 # IntersectListOfGroups()
86 aIntGrp=Mesh_1.IntersectListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "IntGrp" )
87
88 # CutListOfGroups()
89 aCutGrp=Mesh_1.CutListOfGroups([aRedGroup],[aGreenGroup,aBlueGroup],"CutGrp")
90
91 salome.sg.updateObjBrowser( 1 )
92