From bd9c3283e5b3a75c90fa521cea3b66957d9a9497 Mon Sep 17 00:00:00 2001 From: akl Date: Thu, 5 Jun 2014 15:17:59 +0400 Subject: [PATCH] Fix upward cycling if two objects depend on each other. --- src/GEOM_I/GEOM_Gen_i.cc | 18 +++++++++++++----- src/GEOM_I/GEOM_Gen_i.hh | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 02bf4be17..09d880306 100755 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -3057,12 +3057,14 @@ SALOMEDS::TMPFile* GEOM_Gen_i::GetDependencyTree( SALOMEDS::Study_ptr theStudy, GEOM::GEOM_BaseObject_var anObj = GetObject( theStudy->StudyId(), entry.c_str() ); if ( anObj->_is_nil() ) continue; + std::set passedEntries; + passedEntries.insert( entry ); GEOMUtils::LevelsList upLevelList; // get objects from which current one depends on recursively - getUpwardDependency( anObj, upLevelList ); + getUpwardDependency( anObj, upLevelList, passedEntries ); GEOMUtils::LevelsList downLevelList; // get objects that depends on current one recursively - getDownwardDependency( anObj, downLevelList ); + //getDownwardDependency( anObj, downLevelList, passedEntries ); tree.insert( std::pair >(entry, std::pair( upLevelList, downLevelList ) ) ); } @@ -3087,14 +3089,18 @@ SALOMEDS::TMPFile* GEOM_Gen_i::GetDependencyTree( SALOMEDS::Study_ptr theStudy, //======================================================================= void GEOM_Gen_i::getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo, GEOMUtils::LevelsList &upLevelList, + std::set &passedEntries, int level ) { std::string aGboEntry = gbo->GetEntry(); + passedEntries.insert( aGboEntry ); + /* for (int i=0; i < upLevelList.size(); i++ ) { GEOMUtils::LevelInfo aMap = upLevelList.at(i); if ( aMap.count( aGboEntry ) > 0 ) // this object has been processed earlier return; } + */ GEOMUtils::NodeLinks anEntries; GEOMUtils::LevelInfo aLevelMap; if ( level > 0 ) { @@ -3118,8 +3124,9 @@ void GEOM_Gen_i::getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo, anEntries.push_back( depList[j]->GetEntry() ); } // get dependencies recursively - if ( !depList[j]->_is_equivalent( gbo ) ) { // avoid self-recursion - getUpwardDependency(depList[j], upLevelList, level+1); + if ( !depList[j]->_is_equivalent( gbo ) && /*avoid self-recursion*/ + passedEntries.count( depList[j]->GetEntry() ) == 0 /*avoid checking the passed objects*/ ) { + getUpwardDependency(depList[j], upLevelList, passedEntries, level+1); } } if ( level > 0 ) { @@ -3134,6 +3141,7 @@ void GEOM_Gen_i::getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo, //======================================================================= void GEOM_Gen_i::getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo, GEOMUtils::LevelsList &downLevelList, + std::set &passedEntries, int level ) { Handle(TDocStd_Document) aDoc = GEOM_Engine::GetEngine()->GetDocument(gbo->GetStudyID()); Handle(TDataStd_TreeNode) aNode, aRoot; @@ -3180,7 +3188,7 @@ void GEOM_Gen_i::getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo, downLevelList[level] = aLevelMap; // get dependencies of the current object recursively if ( !depList[i]->_is_equivalent( geomObj ) ) { // avoid self-recursion - getDownwardDependency(geomObj, downLevelList, level+1); + getDownwardDependency(geomObj, downLevelList, passedEntries, level+1); } break; } diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh index 43c086cdc..94c0b544a 100644 --- a/src/GEOM_I/GEOM_Gen_i.hh +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -374,10 +374,12 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi void getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo, GEOMUtils::LevelsList &upLevelList, + std::set &passedEntries, int level = 0 ); void getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo, GEOMUtils::LevelsList &downLevelList, + std::set &passedEntries, int level = 0 ); private: -- 2.39.2