#include <GEOM_InteractiveObject.hxx>
#include <GeometryGUI.h>
#include <GEOMBase.h>
+#include "GEOMUtils.hxx"
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( !aSelMgr ) return;
-
+
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
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++;
//
// }
+ // 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()
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<std::string>::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
treeStr.append( "-" );
std::vector<LevelInfo> upLevelList = i->second.first;
treeStr.append( "upward" );
- treeStr.append( "{" );
- for( std::vector<LevelInfo>::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<std::string>::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<LevelInfo> downLevelList = i->second.second;
treeStr.append( "downward" );
- treeStr.append( "{" );
- for( std::vector<LevelInfo>::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<std::string>::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 );
}
}
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;
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<std::string, GEOMUtils::NodeLinks>(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<std::string, GEOMUtils::NodeLinks>(aGboIOR, anIORs) );
+ //std::cout << "AKL: insert level map: " << endl;
+ upLevelList[level-1] = aLevelMap;
}
}
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();
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<std::string, GEOMUtils::NodeLinks>(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<std::string, GEOMUtils::NodeLinks>(aGboIOR, anIORs) );
+ downLevelList[level-1] = aLevelMap;
}
}