From 8682ebb1ebbf9c8392c8fa4adcce76d37e171859 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 25 Sep 2015 21:15:51 +0300 Subject: [PATCH] 23156: EDF 9626 SMESH: Dump study produces a non-working script 52874: List of available groups in 'Group' combo-box is empty for sub-mesh and group. 52871: Mesh Information dialog shows different number of nodes for group of elements Regression of Grids/smesh/sewing_00/A5 --- src/SMESH/SMESH_MeshEditor.cxx | 10 ++++++ .../SMESHGUI_Add0DElemsOnAllNodesDlg.cxx | 7 ++-- src/SMESHGUI/SMESHGUI_MeshInfo.cxx | 4 +-- src/SMESH_I/SMESH_2smeshpy.cxx | 34 +++++++++++++++---- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index fc83430d0..146e8c12a 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -8751,6 +8751,16 @@ SMESH_MeshEditor::SewFreeBorder (const SMDS_MeshNode* theBordFirstNode, else newFaces.Append( myLastCreatedElems(i) ); } + // get segments adjacent to merged nodes + TListOfListOfNodes::iterator groupIt = nodeGroupsToMerge.begin(); + for ( ; groupIt != nodeGroupsToMerge.end(); groupIt++ ) + { + const list& nodes = *groupIt; + SMDS_ElemIteratorPtr segIt = nodes.front()->GetInverseElementIterator( SMDSAbs_Edge ); + while ( segIt->more() ) + segments.insert( segIt->next() ); + } + // find coincident TListOfListOfElementsID equalGroups; if ( !segments.empty() ) diff --git a/src/SMESHGUI/SMESHGUI_Add0DElemsOnAllNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_Add0DElemsOnAllNodesDlg.cxx index 3ee1841ba..295f5c52e 100644 --- a/src/SMESHGUI/SMESHGUI_Add0DElemsOnAllNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Add0DElemsOnAllNodesDlg.cxx @@ -298,11 +298,12 @@ void SMESHGUI_Add0DElemsOnAllNodesOp::selectionDone() myDlg->myGroupListCmBox->clear(); myDlg->myGroupListCmBox->addItem( QString() ); if ( !myIO.IsNull() && myIO->hasEntry()) { - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - _PTR(SObject) meshSO = aStudy->FindObjectID( myIO->getEntry() ); + SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO( myIO ); + _PTR(SObject) meshSO = SMESH::ObjectToSObject( mesh ); _PTR(SObject) group0DRoot; - if ( meshSO->FindSubObject( SMESH::Tag_0DElementsGroups, group0DRoot )) + if ( meshSO && meshSO->FindSubObject( SMESH::Tag_0DElementsGroups, group0DRoot )) { + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); _PTR(ChildIterator) group0DIter = aStudy->NewChildIterator( group0DRoot ); for ( ; group0DIter->More(); group0DIter->Next() ) { diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx index 7bf088b0a..6fb07fb4f 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx @@ -2912,8 +2912,8 @@ void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO { SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface( IO ); if ( !CORBA::is_nil( obj ) ) { - myBaseInfo->showInfo( obj ); - myAddInfo->showInfo( obj ); + myAddInfo->showInfo( obj ); // nb of nodes in a group can be computed by myAddInfo, + myBaseInfo->showInfo( obj ); // and it will be used by myBaseInfo (IPAL52871) myCtrlInfo->showInfo( obj ); myActor = SMESH::FindActorByEntry( IO->getEntry() ); diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index bb9106fe6..e86fa26bb 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -692,6 +692,23 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand { //id_mesh->second->AddProcessedCmd( aCommand ); + // Wrap Export*() into try-except + if ( aCommand->MethodStartsFrom("Export")) + { + _AString tab = "\t"; + _AString indent = aCommand->GetIndentation(); + _AString tryStr = indent + "try:"; + _AString newCmd = indent + tab + ( aCommand->GetString().ToCString() + indent.Length() ); + _AString excStr = indent + "except:"; + _AString msgStr = indent + "\tprint '"; msgStr += method + "() failed. Invalid file name?'"; + + myCommands.insert( --myCommands.end(), new _pyCommand( tryStr, myNbCommands )); + aCommand->Clear(); + aCommand->GetString() = newCmd; + aCommand->SetOrderNb( ++myNbCommands ); + myCommands.push_back( new _pyCommand( excStr, ++myNbCommands )); + myCommands.push_back( new _pyCommand( msgStr, ++myNbCommands )); + } // check for mesh editor object if ( aCommand->GetMethod() == "GetMeshEditor" ) { // MeshEditor creation _pyID editorID = aCommand->GetResultValue(); @@ -1880,6 +1897,10 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) } } // ---------------------------------------------------------------------- + else if ( method == "GetSubMeshes" ) { // clear as the command does nothing (0023156) + theCommand->Clear(); + } + // ---------------------------------------------------------------------- else if ( method == "AddHypothesis" ) { // mesh.AddHypothesis(geom, HYPO ) myAddHypCmds.push_back( theCommand ); // set mesh to hypo @@ -3564,11 +3585,9 @@ void _pyCommand::SetBegPos( int thePartIndex, int thePosition ) TCollection_AsciiString _pyCommand::GetIndentation() { int end = 1; - if ( GetBegPos( RESULT_IND ) == UNKNOWN ) - GetWord( myString, end, true ); - else - end = GetBegPos( RESULT_IND ); - return myString.SubString( 1, Max( end - 1, 1 )); + while ( end <= Length() && isblank( myString.Value( end ))) + ++end; + return ( end == 1 ) ? _AString("") : myString.SubString( 1, end - 1 ); } //================================================================================ @@ -3723,12 +3742,15 @@ const TCollection_AsciiString & _pyCommand::GetMethod() if ( GetBegPos( METHOD_IND ) == UNKNOWN ) { // beginning - int begPos = GetBegPos( OBJECT_IND ) + myObj.Length(); + int begPos = GetBegPos( OBJECT_IND ); bool forward = true; if ( begPos < 1 ) { begPos = myString.Location( "(", 1, Length() ) - 1; forward = false; } + else { + begPos += myObj.Length(); + } // store myMeth = GetWord( myString, begPos, forward ); SetBegPos( METHOD_IND, begPos ); -- 2.39.2