Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / src / SMESH_SWIG / SMESH_BelongToGeom.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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 from SMESH_test1 import *
22
23 ## Old style
24 def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theElemType):
25     import geompy
26     if theShape != theSubShape:
27         aName = str(theSubShape)
28         geompy.addToStudyInFather(theShape,theSubShape,aName)
29
30     theMeshGen.Compute(theMesh,theShape)
31
32     aFilterMgr = theMeshGen.CreateFilterManager()
33     aFilter = aFilterMgr.CreateFilter()
34    
35     aBelongToGeom = aFilterMgr.CreateBelongToGeom()
36     aBelongToGeom.SetGeom(theSubShape)
37     aBelongToGeom.SetElementType(theElemType)
38     
39     aFilter.SetPredicate(aBelongToGeom)
40     return aFilter.GetElementsId(theMesh)
41
42 ## Current style
43 def CheckBelongToGeomFilter(theMesh, theShape, theSubShape, theElemType):
44     import geompy
45     import smesh
46     if theShape != theSubShape:
47         aName = str(theSubShape)
48         geompy.addToStudyInFather(theShape,theSubShape,aName)
49
50     theMesh.Compute()
51     aFilter = smesh.GetFilter(theElemType, smesh.FT_BelongToGeom, theSubShape)
52     return aFilter.GetElementsId(theMesh.GetMesh())
53     
54
55 anElemType = smesh.FACE;
56 print "anElemType =", anElemType
57 #anIds = CheckBelongToGeomFilter(mesh,box,subShapeList[1],anElemType)
58 anIds = CheckBelongToGeomFilter(mesh,box,box,anElemType)
59 print "Number of ids = ", len(anIds)
60 print "anIds = ", anIds
61 ## Check old version
62 #anIds = CheckBelongToGeomFilterOld(smesh.smesh,mesh.GetMesh(),box,box,anElemType)
63 #print "anIds = ", anIds
64
65 salome.sg.updateObjBrowser(1);