Back to index

salome-smesh  6.5.0
SMESH_GroupLyingOnGeom.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 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 import salome
00025 import smesh
00026 
00027 smesh.SetCurrentStudy(salome.myStudy)
00028 
00029 def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
00030     aFilterMgr = smesh.smesh.CreateFilterManager()
00031     aFilter = aFilterMgr.CreateFilter()
00032    
00033     aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
00034     aLyingOnGeom.SetGeom(theShape)
00035     aLyingOnGeom.SetElementType(theElemType)
00036     
00037     aFilter.SetPredicate(aLyingOnGeom)
00038     anIds = aFilter.GetElementsId(theMesh)
00039     aFilterMgr.UnRegister()
00040 
00041     aGroup = theMesh.CreateGroup(theElemType, theName)
00042     aGroup.Add(anIds)
00043 
00044 #Example
00045 from SMESH_test1 import *
00046 
00047 mesh.Compute()
00048 
00049 # First way
00050 BuildGroupLyingOn(mesh.GetMesh(), smesh.FACE, "Group of faces lying on edge #1", edge )
00051 
00052 # Second way
00053 mesh.MakeGroup("Group of faces lying on edge #2", smesh.FACE, smesh.FT_LyingOnGeom, edge)
00054 
00055 salome.sg.updateObjBrowser(1);