]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Merge from PHASE_25_BR 14/11/2010
authorvsr <vsr@opencascade.com>
Mon, 15 Nov 2010 06:50:20 +0000 (06:50 +0000)
committervsr <vsr@opencascade.com>
Mon, 15 Nov 2010 06:50:20 +0000 (06:50 +0000)
idl/GEOM_Gen.idl
src/GEOM_I/GEOM_Object_i.cc
src/GEOM_I/GEOM_Object_i.hh
src/GEOM_SWIG/geompyDC.py
src/OperationGUI/OperationGUI_PartitionDlg.cxx

index 7f37c359b065a22b0f91cff177541a0679c9ea61..6bf18e931fbf05619db8613809122a805b56fb40 100644 (file)
@@ -175,6 +175,15 @@ module GEOM
      */
     shape_type GetTopologyType();
 
+    /*!
+     *  Get a minimal type of the top-level shapes contained in the object.
+     *  This function is useful for the compounds only; for simple shapes it
+     *  exactly the same value as GetShapeType().
+     *  Note, that compounds are procesed recursively.
+     *  \sa GetShapeType(), GetTopologyType()
+     */
+    shape_type GetMinShapeType();
+
     /*!
      *  Set name of the object.
      *  \param theName is a name which will be associated with this object.
index 0adae06321aa9c953f32c1684fd132f26dd41c10..ad139cb773e8b6136d4b72849cb5e6669ab867a6 100644 (file)
@@ -141,6 +141,37 @@ GEOM::shape_type GEOM_Object_i::GetTopologyType()
   return (GEOM::shape_type)shape.ShapeType();
 }
 
+static GEOM::shape_type getMinShapeType( const TopoDS_Shape& shape )
+{
+  if ( shape.IsNull() )
+    return GEOM::SHAPE;
+
+  GEOM::shape_type ret = (GEOM::shape_type)shape.ShapeType();
+
+  if ( shape.ShapeType() == TopAbs_COMPOUND || shape.ShapeType() == TopAbs_COMPSOLID ) {
+    TopoDS_Iterator it(shape, Standard_True, Standard_False);
+    for (; it.More(); it.Next()) {
+      TopoDS_Shape sub_shape = it.Value();
+      if ( sub_shape.IsNull() ) continue;
+      GEOM::shape_type stype = (GEOM::shape_type)sub_shape.ShapeType();
+      if ( stype != GEOM::SHAPE && stype > ret )
+       ret = stype;
+    }
+  }
+
+  return ret;
+}
+
+//=============================================================================
+/*!
+ *  GetMinShapeType
+ */
+//=============================================================================
+GEOM::shape_type GEOM_Object_i::GetMinShapeType()
+{
+  return getMinShapeType( _impl->GetValue() );
+}
+
 //=============================================================================
 /*!
  *  SetName
index 7b56a603c3c49136c8cf0a61ea99e337caa6d691..d47306aada225cf868ffdd3ea0ea1751024e6821 100644 (file)
@@ -53,6 +53,8 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public
 
   virtual GEOM::shape_type GetTopologyType();
 
+  virtual GEOM::shape_type GetMinShapeType();
+
   virtual void SetName(const char* theName);
 
   virtual char* GetName();
index 86ebc2a67d307b1f60551a539518ecaff840bb94..7a6cff7040acfbec654cd115954df3bc99675ff8 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
@@ -2454,6 +2454,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
@@ -2475,9 +2477,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,
@@ -2500,8 +2508,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,
@@ -2514,7 +2528,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,
index a1866115892c0b10d40d393497b8fb259076037f..6c4ad4bda12e58796508dc768ab6c80d13c48773 100644 (file)
@@ -120,11 +120,17 @@ void OperationGUI_PartitionDlg::Init()
 {
   /* type for sub shape selection */
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SOLID" ) );
+  GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::SOLID);
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SHELL" ) );
+  GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::SHELL);
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_FACE" ) );
+  GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::FACE);
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_WIRE" ) );
+  GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::WIRE);
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_EDGE" ) );
+  GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::EDGE);
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) );
+  GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::VERTEX);
   GroupPoints->CheckButton1->setChecked( false );
   
   mainFrame()->GroupBoxPublish->show();
@@ -286,6 +292,13 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument()
   if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
     GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true);
     //myListMaterials.length( 0 ); // obsolete
+    
+    GEOM::shape_type type = GEOM::SOLID;
+    for (int i = 0; i < myListShapes.length(); i++)
+      type = qMax( type, myListShapes[i]->GetMinShapeType() );
+    int idx = qMax( 0, GroupPoints->ComboBox1->findData( type ) );
+    GroupPoints->ComboBox1->setCurrentIndex( idx );
+
     if ( !myListShapes.length() )
       return;
   }
@@ -305,7 +318,7 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument()
       }
     }
   }
-  
+
   myEditCurrentArgument->setText( aString );
 }