mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 17:30:35 +05:00
IMP19942 - Convert group on geometry into group of elements
This commit is contained in:
parent
6e01637051
commit
78fb42dc3e
@ -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.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -236,6 +236,7 @@ public:
|
||||
|
||||
void RemoveGroup (const int theGroupID);
|
||||
|
||||
SMESH_Group* ConvertToStandalone ( int theGroupID );
|
||||
|
||||
SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
myGrpTypeGroup->button(0)->setChecked(true);
|
||||
onGrpTypeChanged(0);
|
||||
// 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);
|
||||
|
||||
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;
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -250,6 +250,10 @@
|
||||
<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>
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -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 << "' )";
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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:
|
||||
# ------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user