]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
PAL20980 EDF 1226 GEOM: Detect the Resulting Type by default
authorvsr <vsr@opencascade.com>
Wed, 6 Oct 2010 19:50:35 +0000 (19:50 +0000)
committervsr <vsr@opencascade.com>
Wed, 6 Oct 2010 19:50:35 +0000 (19:50 +0000)
idl/GEOM_Gen.idl
src/GEOM_I/GEOM_Object_i.cc
src/GEOM_I/GEOM_Object_i.hh
src/OperationGUI/OperationGUI_PartitionDlg.cxx

index 4cef6701aaa9ea7126cd11313a213b11301ca0ea..7b27e134ac14d6a3b09cbadaff517b6d36456f34 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 b6fac51c725384b350fa1f979eef7c7648377367..f5b02efa723e7552f238a932890707e19975c8a4 100644 (file)
@@ -119,11 +119,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();
@@ -270,6 +276,13 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument()
   if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
     GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true);
     myListMaterials.length( 0 );
+    
+    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;
   }
@@ -278,7 +291,7 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument()
     if ( !myListTools.length() )
       return;
   }
-  
+
   myEditCurrentArgument->setText( aString );
 }