Back to index

salome-smesh  6.5.0
SMESH_BelongToGeom.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 from SMESH_test1 import *
00025 
00026 ## Old style
00027 def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theElemType):
00028     import geompy
00029     if theShape != theSubShape:
00030         aName = str(theSubShape)
00031         geompy.addToStudyInFather(theShape,theSubShape,aName)
00032 
00033     theMeshGen.Compute(theMesh,theShape)
00034 
00035     aFilterMgr = theMeshGen.CreateFilterManager()
00036     aFilter = aFilterMgr.CreateFilter()
00037    
00038     aBelongToGeom = aFilterMgr.CreateBelongToGeom()
00039     aBelongToGeom.SetGeom(theSubShape)
00040     aBelongToGeom.SetElementType(theElemType)
00041     
00042     aFilter.SetPredicate(aBelongToGeom)
00043     aFilterMgr.UnRegister()
00044     return aFilter.GetElementsId(theMesh)
00045 
00046 ## Current style
00047 def CheckBelongToGeomFilter(theMesh, theShape, theSubShape, theElemType):
00048     import geompy
00049     import smesh
00050     if theShape != theSubShape:
00051         aName = str(theSubShape)
00052         geompy.addToStudyInFather(theShape,theSubShape,aName)
00053 
00054     theMesh.Compute()
00055     aFilter = smesh.GetFilter(theElemType, smesh.FT_BelongToGeom, theSubShape)
00056     return aFilter.GetElementsId(theMesh.GetMesh())
00057     
00058 
00059 anElemType = smesh.FACE;
00060 print "anElemType =", anElemType
00061 #anIds = CheckBelongToGeomFilter(mesh,box,subShapeList[1],anElemType)
00062 anIds = CheckBelongToGeomFilter(mesh,box,box,anElemType)
00063 print "Number of ids = ", len(anIds)
00064 print "anIds = ", anIds
00065 ## Check old version
00066 #anIds = CheckBelongToGeomFilterOld(smesh.smesh,mesh.GetMesh(),box,box,anElemType)
00067 #print "anIds = ", anIds
00068 
00069 salome.sg.updateObjBrowser(1);