]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0020744: EDF 1272 GEOM : Get(Real?)type of an object
authorinv <inv@opencascade.com>
Mon, 27 Dec 2010 11:50:29 +0000 (11:50 +0000)
committerinv <inv@opencascade.com>
Mon, 27 Dec 2010 11:50:29 +0000 (11:50 +0000)
Additional point: add EnumToLong() function to convert enumerator values to the long values

src/GEOM_SWIG/geompy.py
src/GEOM_SWIG/geompyDC.py

index 7c656279595a79eebce8efa8541c8eaf8e5b8c8f..40b66e8d0dffc1fc90ecf7c9089a2527fdaca6b9 100644 (file)
@@ -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
 
index 9a5e3fa4a8c5b4a32b97eda5820e5a75bb3f9a03..cb32ac012f57f3f7659945e3d8a635426a4e8631 100644 (file)
@@ -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