Salome HOME
23156: EDF 9626 SMESH: Dump study produces a non-working script
authoreap <eap@opencascade.com>
Fri, 25 Sep 2015 18:15:51 +0000 (21:15 +0300)
committereap <eap@opencascade.com>
Fri, 25 Sep 2015 18:15:51 +0000 (21:15 +0300)
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
src/SMESHGUI/SMESHGUI_Add0DElemsOnAllNodesDlg.cxx
src/SMESHGUI/SMESHGUI_MeshInfo.cxx
src/SMESH_I/SMESH_2smeshpy.cxx

index fc83430d08f181b6df11003eaafd3cf1b411fa0e..146e8c12a2eccbbaa4df2033f7a1ea46c680b1b9 100644 (file)
@@ -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<const SMDS_MeshNode*>& nodes = *groupIt;
+    SMDS_ElemIteratorPtr segIt = nodes.front()->GetInverseElementIterator( SMDSAbs_Edge );
+    while ( segIt->more() )
+      segments.insert( segIt->next() );
+  }
+
   // find coincident
   TListOfListOfElementsID equalGroups;
   if ( !segments.empty() )
index 3ee1841ba693d852fa8ef951766bcc8da1e7fef7..295f5c52ee5c5a51caf30abcc6d1850b0d467ffc 100644 (file)
@@ -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() )
       {
index 7bf088b0a95ac9a6dadb6d373b22d417c27c751c..6fb07fb4fa16e5da7914cfcfa1a2c6da541a2acc 100644 (file)
@@ -2912,8 +2912,8 @@ void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO
 {
   SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( 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() );
index bb9106fe61d50a0bf7216948f460dd3d043b8898..e86fa26bb67156e52528e76c3d1adf092c2a9481 100644 (file)
@@ -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 );