OCAF tree traversal to get the downward dependencies including 'unpublished' objects.

This commit is contained in:
akl 2014-06-02 10:56:14 +04:00
parent f084f3e3cd
commit 3acd20a785

View File

@ -60,6 +60,8 @@
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopTools_SequenceOfShape.hxx> #include <TopTools_SequenceOfShape.hxx>
#include <OSD.hxx> #include <OSD.hxx>
#include <TDataStd_ChildNodeIterator.hxx>
#include <TDocStd_Owner.hxx>
#include <SALOMEDS_Tool.hxx> #include <SALOMEDS_Tool.hxx>
#include <SALOMEDS_wrap.hxx> #include <SALOMEDS_wrap.hxx>
@ -3149,45 +3151,65 @@ void GEOM_Gen_i::getDownwardDependency( SALOMEDS::Study_ptr theStudy,
} }
} }
}*/ }*/
SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator( comp ); Handle(TDocStd_Document) aDoc = GEOM_Engine::GetEngine()->GetDocument(gbo->GetStudyID());
for ( it->InitEx( true ); it->More(); it->Next() ) { Handle(TDataStd_TreeNode) aNode, aRoot;
SALOMEDS::SObject_var child = it->Value(); Handle(GEOM_Function) aFunction;
CORBA::Object_var corbaObj = child->GetObject(); if (aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) {
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj ); TDataStd_ChildNodeIterator Itr( aRoot );
if( CORBA::is_nil( geomObj ) ) for (; Itr.More(); Itr.Next()) {
continue; aNode = Itr.Value();
aFunction = GEOM_Function::GetFunction(aNode->Label());
if (aFunction.IsNull()) {
//MESSAGE ( "Null function !!!!" );
continue;
}
TDF_Label aLabel = aFunction->GetOwnerEntry();
if(aLabel.IsNull()) continue;
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aLabel, anEntry);
GEOM::GEOM_BaseObject_var geomObj = GetObject( gbo->GetStudyID(), anEntry.ToCString() );
/*
SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator( comp );
for ( it->InitEx( true ); it->More(); it->Next() ) {
SALOMEDS::SObject_var child = it->Value();
CORBA::Object_var corbaObj = child->GetObject();
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
*/
if( CORBA::is_nil( geomObj ) )
continue;
GEOM::ListOfGBO_var depList = geomObj->GetDependency(); GEOM::ListOfGBO_var depList = geomObj->GetDependency();
if( depList->length() == 0 ) if( depList->length() == 0 )
continue; continue;
std::string aGoIOR = geomObj->GetEntry(); std::string aGoIOR = geomObj->GetEntry();
//cout << "check " << aGoIOR << endl; //cout << "check " << aGoIOR << endl;
for( int i = 0; i < depList->length(); i++ ) { for( int i = 0; i < depList->length(); i++ ) {
//cout << "depends on " << depList[i]->GetEntry() << endl; //cout << "depends on " << depList[i]->GetEntry() << endl;
if ( depList[i]->IsSame( gbo ) ) { if ( depList[i]->IsSame( gbo ) ) {
//cout << " the same! " << endl; //cout << " the same! " << endl;
//if ( level > 0 ) { //if ( level > 0 ) {
GEOMUtils::NodeLinks anIORs; GEOMUtils::NodeLinks anIORs;
GEOMUtils::LevelInfo aLevelMap; GEOMUtils::LevelInfo aLevelMap;
anIORs.push_back( gbo->GetEntry()); anIORs.push_back( gbo->GetEntry());
if ( level >= downLevelList.size() ) { if ( level >= downLevelList.size() ) {
downLevelList.push_back( aLevelMap ); downLevelList.push_back( aLevelMap );
//std::cout << "AKL: new map" << endl; //std::cout << "AKL: new map" << endl;
} else { } else {
aLevelMap = downLevelList.at(level); aLevelMap = downLevelList.at(level);
if ( aLevelMap.count( aGoIOR ) > 0 ) { if ( aLevelMap.count( aGoIOR ) > 0 ) {
anIORs = aLevelMap[ aGoIOR ]; anIORs = aLevelMap[ aGoIOR ];
//std::cout << "AKL: get already added iors list: " << endl; //std::cout << "AKL: get already added iors list: " << endl;
} }
} }
aLevelMap.insert( std::pair<std::string, GEOMUtils::NodeLinks>(aGoIOR, anIORs) ); aLevelMap.insert( std::pair<std::string, GEOMUtils::NodeLinks>(aGoIOR, anIORs) );
downLevelList[level] = aLevelMap; downLevelList[level] = aLevelMap;
//} //}
if ( !depList[i]->IsSame( geomObj ) ) { if ( !depList[i]->IsSame( geomObj ) ) {
//cout << " go on! " << endl; //cout << " go on! " << endl;
getDownwardDependency(theStudy, geomObj, downLevelList, level+1); getDownwardDependency(theStudy, geomObj, downLevelList, level+1);
} }
}
} }
} }
} }