0021891: EDF 2398 : Error when dumping a study with non historical mode

AddHypothesis() + RemoveHypothesis() pair was not cleared in
  snap-shot mode if a hypothesis was removed
This commit is contained in:
eap 2012-10-08 12:45:03 +00:00
parent ac003a0da5
commit bc65599349
2 changed files with 31 additions and 15 deletions

View File

@ -1541,26 +1541,40 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand )
{ {
_pyID hypID = theCommand->GetArg( 2 ); _pyID hypID = theCommand->GetArg( 2 );
_pyID geomID = theCommand->GetArg( 1 ); _pyID geomID = theCommand->GetArg( 1 );
bool isLocal = ( geomID != GetGeom() );
// check if this mesh still has corresponding addition command // check if this mesh still has corresponding addition command
bool hasAddCmd = false; Handle(_pyCommand) addCmd;
list< Handle(_pyCommand) >::iterator cmd = myAddHypCmds.begin(); list< Handle(_pyCommand) >::iterator cmd;
while ( cmd != myAddHypCmds.end() ) list< Handle(_pyCommand) >* addCmds[2] = { &myAddHypCmds, &myNotConvertedAddHypCmds };
for ( int i = 0; i < 2; ++i )
{ {
// AddHypothesis(geom, hyp) list< Handle(_pyCommand )> & addHypCmds = *(addCmds[i]);
if ( hypID == (*cmd)->GetArg( 2 ) && for ( cmd = addHypCmds.begin(); cmd != addHypCmds.end(); )
geomID == (*cmd)->GetArg( 1 )) { // erase both (add and remove) commands {
theCommand->Clear(); bool sameHyp = true;
(*cmd)->Clear(); if ( hypID != (*cmd)->GetArg( 1 ) && hypID != (*cmd)->GetArg( 2 ))
cmd = myAddHypCmds.erase( cmd ); sameHyp = false; // other hyp
hasAddCmd = true; if ( (*cmd)->GetNbArgs() == 2 &&
} geomID != (*cmd)->GetArg( 1 ) && geomID != (*cmd)->GetArg( 2 ))
else { sameHyp = false; // other geom
++cmd; 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 ); 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 ) // RemoveHypothesis(geom, hyp) --> RemoveHypothesis( hyp, geom=0 )
_pyID geom = theCommand->GetArg( 1 ); _pyID geom = theCommand->GetArg( 1 );
theCommand->RemoveArgs(); theCommand->RemoveArgs();
@ -1742,6 +1756,7 @@ void _pyMesh::Flush()
addCmd->SetArg( 1, algoID ); addCmd->SetArg( 1, algoID );
if ( isLocalAlgo ) if ( isLocalAlgo )
addCmd->SetArg( 2, geom ); addCmd->SetArg( 2, geom );
myNotConvertedAddHypCmds.push_back( addCmd );
} }
} }
@ -1762,6 +1777,7 @@ void _pyMesh::Flush()
addCmd->SetArg( 1, hypID ); addCmd->SetArg( 1, hypID );
if ( geom != GetGeom() ) if ( geom != GetGeom() )
addCmd->SetArg( 2, geom ); addCmd->SetArg( 2, geom );
myNotConvertedAddHypCmds.push_back( addCmd );
} }
} }

View File

@ -296,7 +296,7 @@ private:
class _pyMesh: public _pyObject class _pyMesh: public _pyObject
{ {
std::list< Handle(_pyHypothesis) > myHypos; std::list< Handle(_pyHypothesis) > myHypos;
std::list< Handle(_pyCommand) > myAddHypCmds; std::list< Handle(_pyCommand) > myAddHypCmds, myNotConvertedAddHypCmds;
std::list< Handle(_pySubMesh) > mySubmeshes; std::list< Handle(_pySubMesh) > mySubmeshes;
std::list< Handle(_pyGroup) > myGroups; std::list< Handle(_pyGroup) > myGroups;
std::list< Handle(_pyMeshEditor)> myEditors; std::list< Handle(_pyMeshEditor)> myEditors;