]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0020980: EDF 1226 GEOM: Detect the Resulting Type by default
authorvsr <vsr@opencascade.com>
Thu, 7 Oct 2010 07:32:20 +0000 (07:32 +0000)
committervsr <vsr@opencascade.com>
Thu, 7 Oct 2010 07:32:20 +0000 (07:32 +0000)
src/GEOM_SWIG/geompyDC.py

index 954896f5eeccd6f505eeaf368fbf66a0fc3bc4cd..a3dc47c0e3cab5354c81483b9b90b60a482df993 100644 (file)
@@ -84,7 +84,7 @@ import math
 
 ## Enumeration ShapeType as a dictionary
 #  @ingroup l1_geompy_auxiliary
-ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
+ShapeType = {"AUTO":-1, "COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
 
 ## Raise an Error, containing the Method_name, if Operation is Failed
 ## @ingroup l1_geompy_auxiliary
@@ -2441,6 +2441,8 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #           in order to avoid possible intersection between shapes from
         #           this compound.
         #  @param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum).
+        #         If this parameter is set to -1 ("Auto"), most appropriate shape limit
+        #         type will be detected automatically.
         #  @param KeepNonlimitShapes: if this parameter == 0, then only shapes of
         #                             target type (equal to Limit) are kept in the result,
         #                             else standalone shapes of lower dimension
@@ -2462,9 +2464,15 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #
         #  @ref tui_partition "Example"
         def MakePartition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
-                          Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
+                          Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[],
                           KeepNonlimitShapes=0):
             # Example: see GEOM_TestAll.py
+            if Limit == ShapeType["AUTO"]:
+                # automatic detection of the most appropriate shape limit type
+                lim = GEOM.SOLID
+                for s in ListShapes: lim = max( lim, s.GetMinShapeType() )
+                Limit = lim._v
+                pass
             anObj = self.BoolOp.MakePartition(ListShapes, ListTools,
                                               ListKeepInside, ListRemoveInside,
                                               Limit, RemoveWebs, ListMaterials,
@@ -2487,8 +2495,14 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  @ref swig_todo "Example"
         def MakePartitionNonSelfIntersectedShape(self, ListShapes, ListTools=[],
                                                  ListKeepInside=[], ListRemoveInside=[],
-                                                 Limit=ShapeType["SHAPE"], RemoveWebs=0,
+                                                 Limit=ShapeType["AUTO"], RemoveWebs=0,
                                                  ListMaterials=[], KeepNonlimitShapes=0):
+            if Limit == ShapeType["AUTO"]:
+                # automatic detection of the most appropriate shape limit type
+                lim = GEOM.SOLID
+                for s in ListShapes: lim = max( lim, s.GetMinShapeType() )
+                Limit = lim._v
+                pass
             anObj = self.BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
                                                                      ListKeepInside, ListRemoveInside,
                                                                      Limit, RemoveWebs, ListMaterials,
@@ -2501,7 +2515,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  @ref tui_partition "Example 1"
         #  \n @ref swig_Partition "Example 2"
         def Partition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[],
-                      Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[],
+                      Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[],
                       KeepNonlimitShapes=0):
             # Example: see GEOM_TestOthers.py
             anObj = self.MakePartition(ListShapes, ListTools,