From 0fd903e83ee17ffc9f010bcd65d9286172ec40c8 Mon Sep 17 00:00:00 2001 From: akl Date: Fri, 23 May 2014 09:11:17 +0400 Subject: [PATCH] Debug of GetDependencyTree. --- src/DependencyTree/CMakeLists.txt | 7 +- src/DependencyTree/DependencyTree_View.cxx | 20 ++++-- src/GEOMUtils/GEOMUtils.cxx | 60 +++++++--------- src/GEOM_I/GEOM_Gen_i.cc | 81 ++++++++++++++-------- 4 files changed, 97 insertions(+), 71 deletions(-) diff --git a/src/DependencyTree/CMakeLists.txt b/src/DependencyTree/CMakeLists.txt index ac2b89353..9a1fb4398 100644 --- a/src/DependencyTree/CMakeLists.txt +++ b/src/DependencyTree/CMakeLists.txt @@ -26,13 +26,13 @@ INCLUDE(${QT_USE_FILE}) INCLUDE_DIRECTORIES( ${QT_INCLUDES} ${GUI_INCLUDE_DIRS} - ${CAS_INCLUDE_DIRS} - ${OMNIORB_INCLUDE_DIR} + ${CAS_INCLUDE_DIRS} + ${OMNIORB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src/GEOMGUI ${PROJECT_SOURCE_DIR}/src/GEOMBase - ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOM ${PROJECT_BINARY_DIR}/idl @@ -40,6 +40,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/OBJECT ${PROJECT_SOURCE_DIR}/src/GEOMClient ${PROJECT_SOURCE_DIR}/src/GEOMImpl + ${PROJECT_SOURCE_DIR}/src/GEOMUtils ${PROJECT_SOURCE_DIR}/src/DlgRef ${PROJECT_BINARY_DIR}/src/DlgRef diff --git a/src/DependencyTree/DependencyTree_View.cxx b/src/DependencyTree/DependencyTree_View.cxx index 7c6270f56..82efb1ef2 100644 --- a/src/DependencyTree/DependencyTree_View.cxx +++ b/src/DependencyTree/DependencyTree_View.cxx @@ -58,6 +58,7 @@ #include #include #include +#include "GEOMUtils.hxx" @@ -85,7 +86,7 @@ myIsUpdate( true ) LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( !aSelMgr ) return; - + SALOME_ListIO aSelList; aSelMgr->selectedObjects(aSelList); @@ -106,7 +107,8 @@ myIsUpdate( true ) GEOM::GEOM_Object_var myObject = GEOM::GEOM_Object::_nil(); myObject = GEOMBase::ConvertIOinGEOMObject( io ); - QString ior = GEOMBase::GetIORFromObject(myObject); + //QString ior = GEOMBase::GetIORFromObject(myObject); + QString ior = myObject->GetEntry(); ObjectIORs[aaa] = ior.toLatin1().constData(); aaa++; @@ -133,12 +135,18 @@ myIsUpdate( true ) // // } + // get dependencies tree as a stream SALOMEDS::TMPFile_var SeqFile = - GeometryGUI::GetGeomGen()->GetDependencyTree( aStudyDS, ObjectIORs ); - char* buf; - buf = (char*) &SeqFile[0]; + GeometryGUI::GetGeomGen()->GetDependencyTree( aStudyDS, ObjectIORs ); + // convert stream into string + char* treeStr; + treeStr = (char*) &SeqFile[0]; + + std::cout << "\n TREE = " << treeStr << std::endl; - std::cout << "\n\n\n\n\n TREE = " << buf << std::endl; + // parse string to deal with 'TreeModel' object + GEOMUtils::TreeModel tree; + GEOMUtils::ConvertStringToTree( treeStr, tree ); } DependencyTree_View::~DependencyTree_View() diff --git a/src/GEOMUtils/GEOMUtils.cxx b/src/GEOMUtils/GEOMUtils.cxx index 95aca3a39..9412e55e3 100644 --- a/src/GEOMUtils/GEOMUtils.cxx +++ b/src/GEOMUtils/GEOMUtils.cxx @@ -963,6 +963,30 @@ gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) aView ) return ResultPoint; } +void parseWard( const LevelsList &theLevelList, std::string &treeStr ) +{ + treeStr.append( "{" ); + for( LevelsList::const_iterator j = theLevelList.begin(); + j != theLevelList.end(); ++j ) { + if ( j != theLevelList.begin() ) { + treeStr.append( ";" ); + } + LevelInfo level = (*j); + LevelInfo::iterator upIter; + for ( upIter = level.begin(); upIter != level.end(); ++upIter ) { + if ( upIter != level.begin() ) { + treeStr.append( "," ); + } + treeStr.append( upIter->first ); + for ( std::vector::iterator k = upIter->second.begin(); k != upIter->second.end(); ++k ) { + treeStr.append( "_" ); + treeStr.append( *k ); + } + } + } + treeStr.append( "}" ); +} + //======================================================================= // function : ConvertTreeToString() // purpose : Returns the string representation of dependency tree @@ -976,42 +1000,10 @@ void ConvertTreeToString( const TreeModel &tree, treeStr.append( "-" ); std::vector upLevelList = i->second.first; treeStr.append( "upward" ); - treeStr.append( "{" ); - for( std::vector::iterator j = upLevelList.begin(); - j != upLevelList.end(); ++j ) { - LevelInfo level = (*j); - LevelInfo::iterator upIter; - for ( upIter = level.begin(); upIter != level.end(); ++upIter ) { - treeStr.append( upIter->first ); - for ( std::vector::iterator k = upIter->second.begin(); - k != upIter->second.end(); ++k ) { - treeStr.append( "_" ); - treeStr.append( *k ); - } - treeStr.append( upIter++ == level.end() ? ";" : "," ); - upIter--; - } - } - treeStr.append( "}" ); + parseWard( upLevelList, treeStr ); std::vector downLevelList = i->second.second; treeStr.append( "downward" ); - treeStr.append( "{" ); - for( std::vector::iterator j = downLevelList.begin(); - j != downLevelList.end(); ++j ) { - LevelInfo level = (*j); - LevelInfo::iterator downIter; - for ( downIter = level.begin(); downIter != level.end(); ++downIter ) { - treeStr.append( downIter->first ); - for ( std::vector::iterator k = downIter->second.begin(); - k != downIter->second.end(); ++k ) { - treeStr.append( "_" ); - treeStr.append( *k ); - } - treeStr.append( downIter++ == level.end() ? ";" : "," ); - downIter--; - } - } - treeStr.append("}"); + parseWard( downLevelList, treeStr ); } } diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index eca0f4336..cd667ba7f 100755 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -3052,7 +3052,7 @@ SALOMEDS::TMPFile* GEOM_Gen_i::GetDependencyTree( SALOMEDS::Study_ptr theStudy, std::string ior; for ( int i = 0; i < theObjectIORs.length(); i++ ) { ior = theObjectIORs[i].in(); - GEOM::GEOM_Object_ptr anObj = GetIORFromString( ior.c_str() ); + GEOM::GEOM_BaseObject_var anObj = GetObject( theStudy->StudyId(), ior.c_str() ); GEOMUtils::LevelsList upLevelList; getUpwardDependency( anObj, upLevelList ); GEOMUtils::LevelsList downLevelList; @@ -3081,23 +3081,38 @@ SALOMEDS::TMPFile* GEOM_Gen_i::GetDependencyTree( SALOMEDS::Study_ptr theStudy, void GEOM_Gen_i::getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo, GEOMUtils::LevelsList &upLevelList, int level ) { - std::string aGboIOR = GetStringFromIOR(GEOM::GEOM_Object::_narrow(gbo)); + std::string aGboIOR = gbo->GetEntry(); + //std::cout << "\n\nAKL: upnode IOR: " << aGboIOR << endl; + //std::cout << "AKL: level: " << level << endl; + GEOMUtils::NodeLinks anIORs; + GEOMUtils::LevelInfo aLevelMap; + if ( level > 0 ) { + if ( level-1 >= upLevelList.size() ) { + upLevelList.push_back( aLevelMap ); + //std::cout << "AKL: new map" << endl; + } else { + aLevelMap = upLevelList.at(level-1); + if ( aLevelMap.count( aGboIOR ) > 0 ) { + anIORs = aLevelMap[ aGboIOR ]; + //std::cout << "AKL: get already added iors list: " << endl; + } + } + } GEOM::ListOfGBO_var depList = gbo->GetDependency(); for( int j = 0; j < depList->length(); j++ ) { if ( level > 0 ) { - GEOMUtils::NodeLinks anIORs; - GEOMUtils::LevelInfo aLevelMap; - if ( level-1 >= upLevelList.size() ) { - upLevelList.push_back( aLevelMap ); - } else { - aLevelMap = upLevelList.at(level-1); - if ( aLevelMap.count( aGboIOR ) > 0 ) - anIORs = aLevelMap[ aGboIOR ]; - } - anIORs.push_back( GetStringFromIOR(GEOM::GEOM_Object::_narrow(depList[j])) ); - aLevelMap.insert( std::pair(aGboIOR, anIORs) ); + anIORs.push_back( depList[j]->GetEntry() ); + //std::cout << "AKL: add link ior: " << depList[j]->GetEntry() << endl; } - getUpwardDependency(depList[j], upLevelList, level++); + //std::cout << "AKL: <<<<<<<< start next step: " << endl; + getUpwardDependency(depList[j], upLevelList, level+1); + //std::cout << "AKL: end next step >>>>>>>> : " << endl; + } + if ( level > 0 ) { + //std::cout << "AKL: insert links for node: " << aGboIOR << endl; + aLevelMap.insert( std::pair(aGboIOR, anIORs) ); + //std::cout << "AKL: insert level map: " << endl; + upLevelList[level-1] = aLevelMap; } } @@ -3113,6 +3128,21 @@ void GEOM_Gen_i::getDownwardDependency( SALOMEDS::Study_ptr theStudy, if ( !comp ) return; + GEOMUtils::NodeLinks anIORs; + GEOMUtils::LevelInfo aLevelMap; + std::string aGboIOR = gbo->GetEntry(); + if ( level > 0 ) { + if ( level-1 >= downLevelList.size() ) { + downLevelList.push_back( aLevelMap ); + //std::cout << "AKL: new map" << endl; + } else { + aLevelMap = downLevelList.at(level-1); + if ( aLevelMap.count( aGboIOR ) > 0 ) { + anIORs = aLevelMap[ aGboIOR ]; + //std::cout << "AKL: get already added iors list: " << endl; + } + } + } SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator( comp ); for ( it->InitEx( true ); it->More(); it->Next() ) { SALOMEDS::SObject_var child = it->Value(); @@ -3124,25 +3154,20 @@ void GEOM_Gen_i::getDownwardDependency( SALOMEDS::Study_ptr theStudy, GEOM::ListOfGBO_var depList = geomObj->GetDependency(); if( depList->length() == 0 ) continue; - std::string aGoIOR = GetStringFromIOR( geomObj ); + std::string aGoIOR = geomObj->GetEntry(); for( int i = 0; i < depList->length(); i++ ) { if ( depList[i]->IsSame( gbo ) ) { - GEOMUtils::NodeLinks anIORs; - GEOMUtils::LevelInfo aLevelMap; - if ( level >= downLevelList.size() ) { - aLevelMap = GEOMUtils::LevelInfo(); - downLevelList.push_back( aLevelMap ); - } else { - aLevelMap = downLevelList.at(level); - if ( aLevelMap.count( aGoIOR ) > 0 ) - anIORs = aLevelMap[ aGoIOR ]; - } - anIORs.push_back( GetStringFromIOR(GEOM::GEOM_Object::_narrow(depList[i]))); - aLevelMap.insert( std::pair(aGoIOR, anIORs) ); + if ( level > 0 ) { + anIORs.push_back( geomObj->GetEntry()); + } + getDownwardDependency(theStudy, geomObj, downLevelList, level+1); } } - getDownwardDependency(theStudy, geomObj, downLevelList, level++); + } + if ( level > 0 ) { + aLevelMap.insert( std::pair(aGboIOR, anIORs) ); + downLevelList[level-1] = aLevelMap; } } -- 2.39.2