Salome HOME
IMP19942 - Convert group on geometry into group of elements
authorptv <ptv@opencascade.com>
Mon, 15 Dec 2008 12:33:24 +0000 (12:33 +0000)
committerptv <ptv@opencascade.com>
Mon, 15 Dec 2008 12:33:24 +0000 (12:33 +0000)
15 files changed:
doc/salome/gui/SMESH/input/editing_groups.doc
idl/SMESH_Mesh.idl
src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_GroupDlg.cxx
src/SMESHGUI/SMESHGUI_GroupDlg.h
src/SMESHGUI/SMESHGUI_Selection.cxx
src/SMESHGUI/SMESHGUI_Selection.h
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_Group_i.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx
src/SMESH_SWIG/smeshDC.py

index 3a69e757aa8969df1491a6a3e40964fb9051297c..b5031468ae0ad0e2387ff0da04a87eaf08439b0a 100644 (file)
@@ -21,7 +21,21 @@ remove the elements forming it. For more information see
 group.</li>
 </ol>
 
+\n <em>To convert an existing group on geometry into standalone group
+of elements and modify:</em>
+<ol>
+<li>Select your group on geometry in the Object Browser and in the \b Mesh menu click
+the <b>Edit Group as Standalone</b> item.</li>
+
+\image html image74.gif
+<center><em>"Edit Group as Standalone" button</em></center>
+
+The group on geometry will be converted into standalone group and can
+be modified as group of elements
+<li>Click the \b Apply or <b>Apply and Close</b> button to confirm modification of the
+group.</li>
+
 <br><b>See Also</b> a sample TUI Script of an 
 \ref tui_edit_group "Edit Group" operation.  
 
-*/
\ No newline at end of file
+*/
index 76859da1461442f5a7e721369babc920f153ec86..d55204ef4cae34162fc3190771517dcf7370aeb6 100644 (file)
@@ -358,6 +358,12 @@ module SMESH
                                 in string       name )
       raises (SALOME::SALOME_Exception);
 
+    /*!
+     * Convert group on geometry into standalone group
+     */
+    SMESH_Group ConvertToStandalone( in SMESH_GroupOnGeom theGeomGroup )
+      raises (SALOME::SALOME_Exception);
+
     /*!
      * Add hypothesis to the mesh, under a particular subShape
      * (or the main shape itself)
index d8d8ea780598e550155d496a8b4113258277b8aa..a07089b8dcf9cfbc4cdf44fa640982315c2d47a0 100644 (file)
@@ -1479,3 +1479,41 @@ SMDSAbs_ElementType SMESH_Mesh::GetElementType( const int id, const bool iselem
 {
   return _myMeshDS->GetElementType( id, iselem );
 }
+
+//=============================================================================
+/*!
+ *  \brief Convert group on geometry into standalone group
+ */
+//=============================================================================
+
+SMESH_Group* SMESH_Mesh::ConvertToStandalone ( int theGroupID )
+{
+  SMESH_Group* aGroup = 0;
+  std::map < int, SMESH_Group * >::iterator itg = _mapGroup.find( theGroupID );
+  if ( itg == _mapGroup.end() )
+    return aGroup;
+
+  SMESH_Group* anOldGrp = (*itg).second;
+  SMESHDS_GroupBase* anOldGrpDS = anOldGrp->GetGroupDS();
+  if ( !anOldGrp || !anOldGrpDS )
+    return aGroup;
+
+  // create new standalone group
+  aGroup = new SMESH_Group (theGroupID, this, anOldGrpDS->GetType(), anOldGrp->GetName() );
+  _mapGroup[theGroupID] = aGroup;
+
+  SMESHDS_Group* aNewGrpDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
+  GetMeshDS()->RemoveGroup( anOldGrpDS );
+  GetMeshDS()->AddGroup( aNewGrpDS );
+
+  // add elements (or nodes) into new created group
+  SMDS_ElemIteratorPtr anItr = anOldGrpDS->GetElements();
+  while ( anItr->more() )
+    aNewGrpDS->Add( (anItr->next())->GetID() );
+
+  // remove old group
+  delete anOldGrp;
+
+  return aGroup;
+}
+
index c07961fa8deb51b021a36bdf1fd51390c1577080..8ba8f082cfe5977fce80c97afea904a983d1497c 100644 (file)
@@ -236,6 +236,7 @@ public:
 
   void RemoveGroup (const int theGroupID);
 
+  SMESH_Group* ConvertToStandalone ( int theGroupID );
 
   SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
 
index aa9d98862c2a49215f1f99c5e85cc022b8fee1d4..5d40a3c72297040a1cf34b8f98747db398e64b73 100644 (file)
@@ -1876,6 +1876,36 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       break;
     }
 
+  case 815:                                     // Edit GEOM GROUP as standalone
+    {
+      if ( !vtkwnd )
+      {
+        SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
+                                 tr( "NOT_A_VTK_VIEWER" ) );
+        break;
+      }
+
+      if(checkLock(aStudy)) break;
+      EmitSignalDeactivateDialog();
+
+      LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+      SALOME_ListIO selected;
+      if( aSel )
+        aSel->selectedObjects( selected );
+
+      SALOME_ListIteratorOfListIO It (selected);
+      for ( ; It.More(); It.Next() )
+      {
+        SMESH::SMESH_GroupOnGeom_var aGroup =
+          SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
+        if (!aGroup->_is_nil()) {
+          SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
+          aDlg->show();
+       }
+      }
+      break;
+    }
+
     case 810: // Union Groups
     case 811: // Intersect groups
     case 812: // Cut groups
@@ -2606,6 +2636,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction(  801, "CREATE_GROUP",    "ICON_CREATE_GROUP" );
   createSMESHAction(  802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
   createSMESHAction(  803, "EDIT_GROUP",      "ICON_EDIT_GROUP" );
+  createSMESHAction(  815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
   createSMESHAction(  804, "ADD" );
   createSMESHAction(  805, "REMOVE" );
   createSMESHAction(  810, "UN_GROUP",        "ICON_UNION" );
@@ -2744,6 +2775,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 806, meshId, -1 );
   createMenu( 802, meshId, -1 );
   createMenu( 803, meshId, -1 );
+  createMenu( 815, meshId, -1 );
   createMenu( separator(), meshId, -1 );
   createMenu( 810, meshId, -1 );
   createMenu( 811, meshId, -1 );
@@ -2842,6 +2874,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( 806, meshTb );
   createTool( 802, meshTb );
   createTool( 803, meshTb );
+  //createTool( 815, meshTb );
   createTool( separator(), meshTb );
   createTool( 900, meshTb );
   createTool( 902, meshTb );
@@ -2942,6 +2975,8 @@ void SMESHGUI::initialize( CAM_Application* app )
   createPopupItem( 704, OB, mesh, "&& isComputable");      // EDIT_MESHSUBMESH
   createPopupItem( 704, OB, subMesh, "&& isComputable" );  // EDIT_MESHSUBMESH
   createPopupItem( 803, OB, group );                       // EDIT_GROUP
+  createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
+
   popupMgr()->insert( separator(), -1, 0 );
   createPopupItem( 701, OB, mesh, "&& isComputable" );     // COMPUTE
   createPopupItem( 711, OB, mesh, "&& isComputable" );     // PRECOMPUTE
@@ -2974,6 +3009,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createPopupItem( 803, View, group ); // EDIT_GROUP
   createPopupItem( 804, View, elems ); // ADD
   createPopupItem( 805, View, elems ); // REMOVE
+
   popupMgr()->insert( separator(), -1, 0 );
   createPopupItem( 214, View, mesh_group ); // UPDATE
   createPopupItem( 900, View, mesh_group ); // ADV_INFO
index 884373dcfa66d5837de45830dfd3654942872244..74176f0bc77664f1c9048b6fb3d6e052655c6959 100644 (file)
@@ -126,7 +126,8 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
 // purpose  :
 //=================================================================================
 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
-                                     SMESH::SMESH_GroupBase_ptr theGroup )
+                                     SMESH::SMESH_GroupBase_ptr theGroup,
+                                      const bool theIsConvert )
   : QDialog( SMESH::GetDesktop( theModule ) ),
     mySMESHGUI( theModule ),
     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
@@ -136,7 +137,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
 {
   initDialog( false );
   if ( !theGroup->_is_nil() )
-    init( theGroup );
+    init( theGroup, theIsConvert );
   else
   {
     mySelectSubMesh->setEnabled( false );
@@ -510,7 +511,8 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
 // function : Init()
 // purpose  :
 //=================================================================================
-void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
+void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup,
+                              const bool theIsConvert)
 {
   restoreShowEntityMode();
   myMesh = theGroup->GetMesh();
@@ -537,23 +539,27 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
   myTypeGroup->button(aType)->setChecked(true);
 
   myGroup = SMESH::SMESH_Group::_narrow( theGroup );
+  myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
 
-  if (!myGroup->_is_nil())
-  {
-    // NPAL19389: create a group with a selection in another group
-    // set actor of myMesh, if it is visible, else set
-    // actor of myGroup, if it is visible, else try
-    // any visible actor of group or submesh of myMesh
-    // commented, because an attempt to set selection on not displayed cells leads to error
-    //SetAppropriateActor();
-    myActor = SMESH::FindActorByObject(myMesh);
-    if ( !myActor )
-      myActor = SMESH::FindActorByObject(myGroup);
-    SMESH::SetPickable(myActor);
+  if (myGroup->_is_nil() && myGroupOnGeom->_is_nil())
+    return;
+
+  // NPAL19389: create a group with a selection in another group
+  // set actor of myMesh, if it is visible, else set
+  // actor of theGroup, if it is visible, else try
+  // any visible actor of group or submesh of myMesh
+  // commented, because an attempt to set selection on not displayed cells leads to error
+  //SetAppropriateActor();
+  myActor = SMESH::FindActorByObject(myMesh);
+  if ( !myActor )
+    myActor = SMESH::FindActorByObject(theGroup);
+  SMESH::SetPickable(myActor);
 
-    myGrpTypeGroup->button(0)->setChecked(true);
-    onGrpTypeChanged(0);
+  int grpType = (!myGroup->_is_nil() ? 0 : (theIsConvert ? 0 : 1));
+  myGrpTypeGroup->button(grpType)->setChecked(true);
+  onGrpTypeChanged(grpType);
 
+  if ( grpType == 0 ) {
     myCurrentLineEdit = 0;
     myElements->clear();
     setSelectionMode(aType);
@@ -562,8 +568,8 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
     setShowEntityMode(); // depends on myTypeId
 
     myIdList.clear();
-    if (!myGroup->IsEmpty()) {
-      SMESH::long_array_var anElements = myGroup->GetListOfID();
+    if (!theGroup->IsEmpty()) {
+      SMESH::long_array_var anElements = theGroup->GetListOfID();
       int k = anElements->length();
       for (int i = 0; i < k; i++) {
         myIdList.append(anElements[i]);
@@ -574,38 +580,19 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
   }
   else
   {
-    myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
-
-    if ( !myGroupOnGeom->_is_nil() )
+    QString aShapeName( "" );
+    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+    GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
+    if (!aGroupShape->_is_nil())
     {
-      // NPAL19389: create a group with a selection in another group
-      // set actor of myMesh, if it is visible, else set
-      // actor of myGroupOnGeom, if it is visible, else try
-      // any visible actor of group or submesh of myMesh
-      // commented, because an attempt to set selection on not displayed cells leads to error
-      //SetAppropriateActor();
-      myActor = SMESH::FindActorByObject(myMesh);
-      if ( !myActor )
-        myActor = SMESH::FindActorByObject(myGroupOnGeom);
-      SMESH::SetPickable(myActor);
-
-      myGrpTypeGroup->button(1)->setChecked(true);
-      onGrpTypeChanged(1);
-
-      QString aShapeName( "" );
-      _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
-      GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
-      if (!aGroupShape->_is_nil())
-      {
-        _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
-        aShapeName = aGroupShapeSO->GetName().c_str();
-      }
-      myGeomGroupLine->setText( aShapeName );
-      myNameChanged = true;
-      myName->blockSignals(true);
-      myName->setText( "Group On " + aShapeName);
-      myName->blockSignals(false);
+      _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
+      aShapeName = aGroupShapeSO->GetName().c_str();
     }
+    myGeomGroupLine->setText( aShapeName );
+    myNameChanged = true;
+    myName->blockSignals(true);
+    myName->setText( "Group On " + aShapeName);
+    myName->blockSignals(false);
   }
 }
 
@@ -755,6 +742,17 @@ bool SMESHGUI_GroupDlg::onApply()
 
     mySelectionMgr->clearSelected();
 
+    if (myGroup->_is_nil()) { // creation or conversion
+      // check if group on geometry is not null
+      if (!CORBA::is_nil(myGroupOnGeom)) {
+        if (myMesh->_is_nil())
+          return false;
+        myGroup = myMesh->ConvertToStandalone( myGroupOnGeom );
+       // nullify pointer, because object become dead
+        myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
+      }
+    }
+
     if (myGroup->_is_nil()) { // creation
       if (myMesh->_is_nil())
         return false;
index 76c34f686be2f843774e481a3177d547fec0f2b3..fb6b9dcf02ec481aa6a902ba4b127285a3dda9d2 100644 (file)
@@ -69,7 +69,8 @@ public:
   SMESHGUI_GroupDlg( SMESHGUI*,
                     SMESH::SMESH_Mesh_ptr = SMESH::SMESH_Mesh::_nil() );
   SMESHGUI_GroupDlg( SMESHGUI*,
-                    SMESH::SMESH_GroupBase_ptr );
+                    SMESH::SMESH_GroupBase_ptr,
+                     const bool theIsConvert = false );
   ~SMESHGUI_GroupDlg();
   
   static QString                GetDefaultName( const QString& );
@@ -112,7 +113,8 @@ private slots:
 private:
   void                          initDialog( bool );
   void                          init( SMESH::SMESH_Mesh_ptr );
-  void                          init( SMESH::SMESH_GroupBase_ptr );
+  void                          init( SMESH::SMESH_GroupBase_ptr,
+                                      const bool theIsConvert = false );
   void                          closeEvent( QCloseEvent* );
   void                          enterEvent( QEvent* );
   void                          hideEvent( QHideEvent* );   /* ESC key */
index 4711f1d10fc8d5f557bc86c98da643bd1b055592..7fc015a751180b1addfde6486e555b8370f3ef94 100644 (file)
@@ -116,6 +116,7 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
   else if ( p=="hasReference" )  val = QVariant( hasReference( ind ) );
   else if ( p=="isImported" )    val = QVariant( isImported( ind ) );
   else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
+  else if ( p=="groupType" )     val = QVariant( groupType( ind ) );
 
   if( val.isValid() )
     return val;
@@ -523,3 +524,27 @@ bool SMESHGUI_Selection::isImported( const int ind ) const
   */
   return res;
 }
+
+//=======================================================================
+//function : groupType
+//purpose  : 
+//=======================================================================
+
+QString SMESHGUI_Selection::groupType( int ind ) const
+{
+  QString e = entry( ind );
+  _PTR(SObject) SO = SMESH::GetActiveStudyDocument()->FindObjectID( e.toLatin1().constData() );
+  QString type;
+  if( SO )
+  {
+    CORBA::Object_var obj = SMESH::SObjectToObject( SO );
+  
+    SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( obj );
+    SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( obj );
+    if( !aGroup->_is_nil() )
+      type = QString( "Group" );
+    else if ( !aGroupOnGeom->_is_nil() )
+      type = QString( "GroupOnGeom" );
+  }
+  return type;
+}
index dfcac17f65176a611c767d7a0a2466931778bfd2..4bb5144e845b9c39d6951a0b962d79d5fd7d22af 100644 (file)
@@ -65,6 +65,7 @@ public:
   virtual QList<QVariant> entityMode( int ) const;
   virtual QString         controlMode( int ) const;
   virtual QString         facesOrientationMode( int ) const;
+  virtual QString         groupType( int ) const;
   
   SMESH_Actor*            getActor( int ) const;
 
index f99e4cb4dda9bcce4afc8bd45a3421e912d860c5..1d4854fa56661f9db2c6d99fd70a608731d51daa 100644 (file)
             <source>MEN_EDIT_GROUP</source>
             <translation>Edit Group</translation>
         </message>
+        <message>
+            <source>MEN_EDIT_GEOMGROUP_AS_GROUP</source>
+            <translation>Edit Group as Standalone</translation>
+        </message>
         <message>
             <source>MEN_EDIT_HYPO</source>
             <translation>Edit Hypothesis</translation>
@@ -1020,6 +1024,10 @@ so that the application may crash. Do you wish to continue visualization?</trans
             <source>SMESH_EDIT_GROUP_TITLE</source>
             <translation>Edit Group</translation>
         </message>
+        <message>
+            <source>SMESH_EDIT_GEOMGROUP_AS_GROUP_TITLE</source>
+            <translation>Edit Group as Standalone</translation>
+        </message>
         <message>
             <source>SMESH_EDIT_HYPOTHESES</source>
             <translation>Hypotheses Assignation</translation>
@@ -2004,6 +2012,10 @@ Consider saving your work before application crash</translation>
             <source>STB_EDIT_GROUP</source>
             <translation>Edit Group</translation>
         </message>
+        <message>
+            <source>STB_EDIT_GEOMGROUP_AS_GROUP</source>
+            <translation>Edit Group as Standalone</translation>
+        </message>
         <message>
             <source>STB_EDIT_HYPO</source>
             <translation>Edit Hypothesis</translation>
@@ -2472,6 +2484,10 @@ Consider saving your work before application crash</translation>
             <source>TOP_EDIT_GROUP</source>
             <translation>Edit Group</translation>
         </message>
+        <message>
+            <source>TOP_EDIT_GEOMGROUP_AS_GROUP</source>
+            <translation>Edit Group as Standalone</translation>
+        </message>
         <message>
             <source>TOP_EDIT_HYPO</source>
             <translation>Edit Hypothesis</translation>
index 4a9979ea83d79721d9c442d900a0c4045c14be61..17927530525276fc1394a27b2aec23a95a532a81 100644 (file)
@@ -830,7 +830,13 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand )
       theCommand->SetArg( 1, grp );
     }
     else {
-      AddMeshAccess( theCommand );
+      _pyID type = theCommand->GetArg( 1 );
+      _pyID name = theCommand->GetArg( 2 );
+      theCommand->SetMethod( "GroupOnGeom" );
+      theCommand->RemoveArgs();
+      theCommand->SetArg( 1, grp );
+      theCommand->SetArg( 2, name );
+      theCommand->SetArg( 3, type );
     }
   }
   // ----------------------------------------------------------------------
@@ -908,7 +914,7 @@ bool _pyMesh::NeedMeshAccess( const Handle(_pyCommand)& theCommand )
         "GetNodeInverseElements","GetShapeID","GetShapeIDForElem","GetElemNbNodes",
         "GetElemNode","IsMediumNode","IsMediumNodeOfAnyElem","ElemNbEdges","ElemNbFaces",
         "IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor",
-        "Clear"
+        "Clear", "ConvertToStandalone"
         ,"" }; // <- mark of end
     sameMethods.Insert( names );
   }
index 35276984d5301a2c436cc2c77797e9249147aaef..254c38751fe2581af117403162120fe6821bff7f 100644 (file)
@@ -119,20 +119,24 @@ SMESHDS_GroupBase* SMESH_GroupBase_i::GetGroupDS() const
 
 void SMESH_GroupBase_i::SetName( const char* theName )
 {
-  // Update Python script
-  TPythonDump() <<  _this() << ".SetName( '" << theName << "' )";
-
   // Perform renaming
   ::SMESH_Group* aGroup = GetSmeshGroup();
-  if (aGroup) {
-    aGroup->SetName(theName);
-
-    // Update group name in a study
-    SMESH_Gen_i* aGen = myMeshServant->GetGen();
-    aGen->SetName( aGen->ObjectToSObject( aGen->GetCurrentStudy(), _this() ), theName );
+  if (!aGroup) {
+    MESSAGE("can't set name of a vague group");
     return;
   }
-  MESSAGE("can't set name of a vague group");
+
+  if ( aGroup->GetName() && !strcmp( aGroup->GetName(), theName ) )
+    return; // nothing to rename
+
+  aGroup->SetName(theName);
+
+  // Update group name in a study
+  SMESH_Gen_i* aGen = myMeshServant->GetGen();
+  aGen->SetName( aGen->ObjectToSObject( aGen->GetCurrentStudy(), _this() ), theName );
+  
+  // Update Python script
+  TPythonDump() <<  _this() << ".SetName( '" << theName << "' )";
 }
 
 //=============================================================================
index ed84d70f066d156b00647d56f57b64a7582c3cb7..8d5d8278300a198e2f7fe930d91e29f68588f948 100644 (file)
@@ -1629,6 +1629,74 @@ void SMESH_Mesh_i::CheckGeomGroupModif()
   }
 }
 
+//=============================================================================
+/*!
+ * \brief Create standalone group instead if group on geometry
+ * 
+ */
+//=============================================================================
+
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupOnGeom_ptr theGroup )
+{
+  SMESH::SMESH_Group_var aGroup;
+  if ( theGroup->_is_nil() )
+    return aGroup._retn();
+
+  Unexpect aCatch(SALOME_SalomeException);
+
+  SMESH_GroupBase_i* aGroupToRem =
+    dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
+  if ( !aGroupToRem )
+    return aGroup._retn();
+
+  int anId = aGroupToRem->GetLocalID();
+  if ( !_impl->ConvertToStandalone( anId ) )
+    return aGroup._retn();
+
+    SMESH_GroupBase_i* aGroupImpl;
+      aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
+
+
+  // remove old instance of group from own map
+  _mapGroups.erase( anId );
+
+  SALOMEDS::StudyBuilder_var builder;
+  SALOMEDS::SObject_var aGroupSO;
+  SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+  if ( !aStudy->_is_nil() )  {
+    builder = aStudy->NewBuilder();
+    aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
+    if ( !aGroupSO->_is_nil() ) {
+
+    // remove reference to geometry
+    SALOMEDS::ChildIterator_var chItr = aStudy->NewChildIterator(aGroupSO);
+    for ( ; chItr->More(); chItr->Next() )
+      // Remove group's child SObject
+      builder->RemoveObject( chItr->Value() );
+
+      // Update Python script
+      TPythonDump() << aGroupSO << " = " << _this() << ".ConvertToStandalone( "
+                    << aGroupSO << " )";
+    }
+  }
+
+  // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
+  SMESH_Gen_i::GetPOA()->activate_object( aGroupImpl );
+  aGroupImpl->Register();
+  // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
+
+  // remember new group in own map
+  aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
+  _mapGroups[anId] = SMESH::SMESH_GroupBase::_duplicate( aGroup );
+
+  // register CORBA object for persistence
+  //int nextId = _gen_i->RegisterObject( aGroup );
+  //if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);
+  builder->SetIOR( aGroupSO, _gen_i->GetORB()->object_to_string( aGroup ) );
+
+  return aGroup._retn();
+}
+
 //=============================================================================
 /*!
  *
index 684cbd534c7dc57cd9a7898d694184992f0d541e..a26c6e0f6573ac88a5b036c398e9be63b149be80 100644 (file)
@@ -151,6 +151,8 @@ public:
   throw (SALOME::SALOME_Exception);
   
 
+  SMESH::SMESH_Group_ptr ConvertToStandalone( SMESH::SMESH_GroupOnGeom_ptr theGeomGroup );
+
 //    SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
 //      throw (SALOME::SALOME_Exception);
 
index faa079cee08a6f7bccaf6505cc9bdfb15c99b853..f5d53e574c316a41c5f757767d0d7bed2b6aced0 100644 (file)
@@ -1310,6 +1310,11 @@ class Mesh:
       return self.mesh.CreateDimGroup(groups, elem_type, name)
 
 
+    ## Convert group on geom into standalone group
+    #  @ingroup l2_grps_delete
+    def ConvertToStandalone(self, group):
+        return self.mesh.ConvertToStandalone(group)
+
     # Get some info about mesh:
     # ------------------------