From: inv Date: Mon, 27 Dec 2010 11:50:29 +0000 (+0000) Subject: 0020744: EDF 1272 GEOM : Get(Real?)type of an object X-Git-Tag: Start_BR_19998_21191~106 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e9605e4e5ba041999f42bf4df77e595a9ce41a5b;p=modules%2Fgeom.git 0020744: EDF 1272 GEOM : Get(Real?)type of an object Additional point: add EnumToLong() function to convert enumerator values to the long values --- diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index 7c6562795..40b66e8d0 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -39,5 +39,5 @@ for k in dir(geom): if k[0] == '_':continue globals()[k]=getattr(geom,k) del k -from geompyDC import ShapeType,GEOM,kind, info, PackData, ReadTexture +from geompyDC import ShapeType, GEOM, kind, info, PackData, ReadTexture, EnumToLong diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 9a5e3fa4a..cb32ac012 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -259,6 +259,14 @@ def ReadTexture(fname): pass return 0, 0, "" +## Returns a long value from enumeration type +# Can be used for CORBA enumerator types like GEOM.shape_type +# @ingroup l1_geompy_auxiliary +def EnumToLong(theItem): + ret = theItem + if hasattr(theItem, "_v"): ret = theItem._v + return ret + ## Kinds of shape enumeration # @ingroup l1_geompy_auxiliary kind = GEOM.GEOM_IKindOfShape @@ -2256,8 +2264,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param aType shape type def ExtractShapes(self, aShape, aType, sorted = False): ret = [] - t = aShape.GetShapeType()._v - if hasattr(aType, "_v"): aType = aType._v + t = EnumToLong(aShape.GetShapeType()) + aType = EnumToLong(aType) if t == aType: ret.append(aShape ) elif sorted: @@ -2583,7 +2591,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # automatic detection of the most appropriate shape limit type lim = GEOM.SHAPE for s in ListShapes: lim = min( lim, s.GetMaxShapeType() ) - Limit = lim._v + Limit = EnumToLong(lim) pass anObj = self.BoolOp.MakePartition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, @@ -2613,7 +2621,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # automatic detection of the most appropriate shape limit type lim = GEOM.SHAPE for s in ListShapes: lim = min( lim, s.GetMaxShapeType() ) - Limit = lim._v + Limit = EnumToLong(lim) pass anObj = self.BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools, ListKeepInside, ListRemoveInside, @@ -3450,7 +3458,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestMeasures.py listSh = self.SubShapeAllIDs(theShape, theType) Nb = len(listSh) - if theShape.GetShapeType()._v == theType: + t = EnumToLong(theShape.GetShapeType()) + theType = EnumToLong(theType) + if t == theType: Nb = Nb + 1 pass return Nb @@ -3465,14 +3475,13 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestMeasures.py aDict = {} for typeSh in ShapeType: - if typeSh != "AUTO" and typeSh != "SHAPE": - listSh = self.SubShapeAllIDs(theShape, ShapeType[typeSh]) - Nb = len(listSh) - if theShape.GetShapeType()._v == ShapeType[typeSh]: - Nb = Nb + 1 - pass - aDict[typeSh] = Nb + if typeSh in ( "AUTO", "SHAPE" ): continue + listSh = self.SubShapeAllIDs(theShape, ShapeType[typeSh]) + Nb = len(listSh) + if EnumToLon(theShape.GetShapeType()) == ShapeType[typeSh]: + Nb = Nb + 1 pass + aDict[typeSh] = Nb pass return aDict