Salome HOME
0021891: EDF 2398 : Error when dumping a study with non historical mode
authoreap <eap@opencascade.com>
Mon, 8 Oct 2012 12:45:03 +0000 (12:45 +0000)
committereap <eap@opencascade.com>
Mon, 8 Oct 2012 12:45:03 +0000 (12:45 +0000)
  AddHypothesis() + RemoveHypothesis() pair was not cleared in
  snap-shot mode if a hypothesis was removed

src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_2smeshpy.hxx

index 91f6e7effd1d6482db1de829fd9aaa67fac89d1d..28bc3cfd429bf33678e1ce74f214607189805428 100644 (file)
@@ -1541,26 +1541,40 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand )
   {
     _pyID hypID  = theCommand->GetArg( 2 );
     _pyID geomID = theCommand->GetArg( 1 );
+    bool isLocal = ( geomID != GetGeom() );
 
     // check if this mesh still has corresponding addition command
-    bool hasAddCmd = false;
-    list< Handle(_pyCommand) >::iterator cmd = myAddHypCmds.begin();
-    while ( cmd != myAddHypCmds.end() )
+    Handle(_pyCommand) addCmd;
+    list< Handle(_pyCommand) >::iterator cmd;
+    list< Handle(_pyCommand) >* addCmds[2] = { &myAddHypCmds, &myNotConvertedAddHypCmds };
+    for ( int i = 0; i < 2; ++i )
     {
-      // AddHypothesis(geom, hyp)
-      if ( hypID  == (*cmd)->GetArg( 2 ) &&
-           geomID == (*cmd)->GetArg( 1 )) { // erase both (add and remove) commands
-        theCommand->Clear();
-        (*cmd)->Clear();
-        cmd = myAddHypCmds.erase( cmd );
-        hasAddCmd = true;
-      }
-      else {
-        ++cmd;
+      list< Handle(_pyCommand )> & addHypCmds = *(addCmds[i]);
+      for ( cmd = addHypCmds.begin(); cmd != addHypCmds.end(); )
+      {
+        bool sameHyp = true;
+        if ( hypID != (*cmd)->GetArg( 1 ) && hypID != (*cmd)->GetArg( 2 ))
+          sameHyp = false; // other hyp
+        if ( (*cmd)->GetNbArgs() == 2 &&
+             geomID != (*cmd)->GetArg( 1 ) && geomID != (*cmd)->GetArg( 2 ))
+          sameHyp = false; // other geom
+        if ( (*cmd)->GetNbArgs() == 1 && isLocal )
+          sameHyp = false; // other geom
+        if ( sameHyp )
+        {
+          addCmd = *cmd;
+          addCmd->Clear();
+          theCommand->Clear();
+          cmd = addHypCmds.erase( cmd );
+        }
+        else
+        {
+          ++cmd;
+        }
       }
     }
     Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID );
-    if ( ! hasAddCmd && hypID.Length() != 0 ) { // hypo addition already wrapped
+    if ( addCmd.IsNull() && !hypID.IsEmpty() ) { // hypo addition already wrapped
       // RemoveHypothesis(geom, hyp) --> RemoveHypothesis( hyp, geom=0 )
       _pyID geom = theCommand->GetArg( 1 );
       theCommand->RemoveArgs();
@@ -1742,6 +1756,7 @@ void _pyMesh::Flush()
       addCmd->SetArg( 1, algoID );
       if ( isLocalAlgo )
         addCmd->SetArg( 2, geom );
+      myNotConvertedAddHypCmds.push_back( addCmd );
     }
   }
 
@@ -1762,6 +1777,7 @@ void _pyMesh::Flush()
       addCmd->SetArg( 1, hypID );
       if ( geom != GetGeom() )
         addCmd->SetArg( 2, geom );
+      myNotConvertedAddHypCmds.push_back( addCmd );
     }
   }
 
index 36212e0686a3bffbe5ff3bb02f3dae63d229db1b..fed8d1e7e5b2562c7cb84b5234a385e83a260526 100644 (file)
@@ -296,7 +296,7 @@ private:
 class _pyMesh: public _pyObject
 {
   std::list< Handle(_pyHypothesis) > myHypos;
-  std::list< Handle(_pyCommand) >    myAddHypCmds;
+  std::list< Handle(_pyCommand) >    myAddHypCmds, myNotConvertedAddHypCmds;
   std::list< Handle(_pySubMesh) >    mySubmeshes;
   std::list< Handle(_pyGroup) >      myGroups;
   std::list< Handle(_pyMeshEditor)>  myEditors;