Back to index

salome-smesh  6.5.0
ex30_groupsOp.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # This library is free software; you can redistribute it and/or
00005 # modify it under the terms of the GNU Lesser General Public
00006 # License as published by the Free Software Foundation; either
00007 # version 2.1 of the License.
00008 #
00009 # This library is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 # Lesser General Public License for more details.
00013 #
00014 # You should have received a copy of the GNU Lesser General Public
00015 # License along with this library; if not, write to the Free Software
00016 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017 #
00018 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00019 #
00020 
00021 import sys
00022 import salome
00023 import geompy
00024 import math
00025 import SALOMEDS
00026 import SMESH
00027 import smesh
00028 
00029 salome.salome_init()
00030 aStudyId = salome.myStudy._get_StudyId()
00031 
00032 geompy.init_geom(salome.myStudy)
00033 global Face_1
00034 Face_1 = geompy.MakeFaceHW(100, 100, 1)
00035 geompy.addToStudy( Face_1, "Face_1" )
00036 
00037 smesh.SetCurrentStudy(salome.myStudy)
00038 import StdMeshers
00039 pattern = smesh.GetPattern()
00040 Mesh_1 = smesh.Mesh(Face_1)
00041 Regular_1D = Mesh_1.Segment()
00042 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
00043 Nb_Segments_1.SetDistrType( 0 )
00044 Quadrangle_2D = Mesh_1.Quadrangle()
00045 isDone = Mesh_1.Compute()
00046 
00047 # groups creation
00048 
00049 aListOfElems = [ 52, 53, 54, 55, 56, 57,
00050                  62, 63, 64, 65, 66, 67,
00051                  72, 73, 74, 75, 76, 77,
00052                  82, 83, 84, 85, 86, 87 ]
00053                  
00054 aRedGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Red" )
00055 aRedGroup.Add( aListOfElems );
00056 aRedGroup.SetColor( SALOMEDS.Color( 1, 0, 0 ) )
00057 
00058 aListOfElems = [ 55, 56, 57, 58, 59,
00059                  65, 66, 67, 68, 69,
00060                  75, 76, 77, 78, 79,
00061                  85, 86, 87, 88, 89,
00062                  95, 96, 97, 98, 99,
00063                  105, 106, 107, 108, 109,
00064                  115, 116, 117, 118, 119,
00065                  125, 126, 127, 128, 129 ]
00066                  
00067 aGreenGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Green" )
00068 aGreenGroup.Add( aListOfElems );
00069 aGreenGroup.SetColor( SALOMEDS.Color( 0, 1, 0 ) )
00070 
00071 aListOfElems = [ 63, 64, 65, 66, 67, 68, 
00072                  73, 74, 75, 76, 77, 78,
00073                  83, 84, 85, 86, 87, 88, 
00074                  93, 94, 95, 96, 97, 98, 
00075                  103, 104, 105, 106, 107, 108, 
00076                  113, 114, 115, 116, 117, 118 ]
00077                  
00078 aBlueGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Blue" )
00079 aBlueGroup.Add( aListOfElems );
00080 aBlueGroup.SetColor( SALOMEDS.Color( 0, 0, 1 ) )
00081 
00082 # UnionListOfGroups()
00083 aUnGrp = Mesh_1.UnionListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "UnionGrp" )
00084 
00085 # IntersectListOfGroups()
00086 aIntGrp=Mesh_1.IntersectListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "IntGrp" )
00087 
00088 # CutListOfGroups()
00089 aCutGrp=Mesh_1.CutListOfGroups([aRedGroup],[aGreenGroup,aBlueGroup],"CutGrp")
00090 
00091 salome.sg.updateObjBrowser( 1 )
00092