]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix upward cycling if two objects depend on each other.
authorakl <akl@opencascade.com>
Thu, 5 Jun 2014 11:17:59 +0000 (15:17 +0400)
committerakl <akl@opencascade.com>
Thu, 5 Jun 2014 11:17:59 +0000 (15:17 +0400)
src/GEOM_I/GEOM_Gen_i.cc
src/GEOM_I/GEOM_Gen_i.hh

index 02bf4be179e0a3c0da886100375022bc33ff6dc0..09d8803060b4cd9c6e62babf652da81e382ba845 100755 (executable)
@@ -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<std::string> 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<std::string, std::pair<GEOMUtils::LevelsList,GEOMUtils::LevelsList> >(entry, std::pair<GEOMUtils::LevelsList,GEOMUtils::LevelsList>( 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<std::string> &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<std::string> &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;
         }
index 43c086cdc2db5f789fc23b2c9a4f85382deb1f8e..94c0b544aa77ba1fb6a589b38254fb898fd84cc9 100644 (file)
@@ -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<std::string> &passedEntries,
                             int level = 0 );
 
   void getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo, 
                               GEOMUtils::LevelsList &downLevelList, 
+                             std::set<std::string> &passedEntries,
                               int level = 0 );
 
  private: