From: akl Date: Mon, 23 Jun 2014 14:12:26 +0000 (+0400) Subject: Get sub-objects recursively. Miss sub-object if it is in 'selected' list. X-Git-Tag: V7_5_0a1~50^2~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4805532bcf967c2944dbe55c9198e6940d76bbc7;p=modules%2Fgeom.git Get sub-objects recursively. Miss sub-object if it is in 'selected' list. --- diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 7fa57d213..9742087c2 100755 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -3238,7 +3238,7 @@ void GEOM_Gen_i::GetEntriesToCleanStudy(SALOMEDS::Study_ptr theStudy, if ( aSelected.count( anEntry ) > 0 && aParents.count( anEntry ) == 0 ) { - getParentDependencies( geomObj, aSelected, aParents, aChildren, anOthers ); + includeParentDependencies( geomObj, aSelected, aParents, aChildren, anOthers ); } else if ( aParents.count( anEntry ) == 0 && aChildren.count( anEntry ) == 0 ) { anOthers.insert( geomObj->GetEntry() ); @@ -3252,32 +3252,7 @@ void GEOM_Gen_i::GetEntriesToCleanStudy(SALOMEDS::Study_ptr theStudy, // filling list of sub-objects for ( it = aSelected.begin(); it != aSelected.end(); ++it ) { - Handle(GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), (*it).c_str(), false); - if ( handle_object.IsNull() ) - continue; - - Handle(GEOM_Function) aShapeFun = handle_object->GetFunction(1); - if ( aShapeFun.IsNull() || !aShapeFun->HasSubShapeReferences() ) - continue; - - const TDataStd_ListOfExtendedString& aListEntries = aShapeFun->GetSubShapeReferences(); - if ( aListEntries.IsEmpty() ) - continue; - - TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries); - for ( ; anIt.More(); anIt.Next() ) { - TCollection_ExtendedString aSubEntry = anIt.Value(); - Standard_Integer aStrLen = aSubEntry.LengthOfCString(); - char* aSubEntryStr = new char[aStrLen+1]; - aSubEntry.ToUTF8CString( aSubEntryStr ); - foundIt = aParents.find( aSubEntryStr ); - if ( foundIt == aParents.end() ) { // add to sub-objects if it is not in parents list - aChildren.insert( aSubEntryStr ); - foundIt = anOthers.find( aSubEntryStr ); - if ( foundIt != anOthers.end() ) - anOthers.erase( foundIt ); - } - } + includeSubObjects( theStudy, *it, aSelected, aParents, aChildren, anOthers ); } // if some selected object is not a main shape, @@ -3332,11 +3307,15 @@ void GEOM_Gen_i::GetEntriesToCleanStudy(SALOMEDS::Study_ptr theStudy, } } -void GEOM_Gen_i::getParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj, - std::set& aSelected, - std::set& aParents, - std::set& aChildren, - std::set& anOthers) +//============================================================================== +// function : includeParentDependencies +// purpose : +//============================================================================== +void GEOM_Gen_i::includeParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj, + std::set& aSelected, + std::set& aParents, + std::set& aChildren, + std::set& anOthers) { std::string anEntry = geomObj->GetEntry(); if ( aSelected.count( anEntry ) == 0 ) { @@ -3363,10 +3342,53 @@ void GEOM_Gen_i::getParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj, aParents.count( aDepEntry ) > 0 // skip already processed objects ) continue; - getParentDependencies( depList[i], aSelected, aParents, aChildren, anOthers ); + includeParentDependencies( depList[i], aSelected, aParents, aChildren, anOthers ); } } +//============================================================================== +// function : includeSubObjects +// purpose : +//============================================================================== +void GEOM_Gen_i::includeSubObjects(SALOMEDS::Study_ptr theStudy, + const std::string& aSelectedEntry, + std::set& aSelected, + std::set& aParents, + std::set& aChildren, + std::set& anOthers) +{ + std::set::iterator foundIt; + Handle(GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), aSelectedEntry.c_str(), false); + if ( handle_object.IsNull() ) + return; + + Handle(GEOM_Function) aShapeFun = handle_object->GetFunction(1); + if ( aShapeFun.IsNull() || !aShapeFun->HasSubShapeReferences() ) + return; + + const TDataStd_ListOfExtendedString& aListEntries = aShapeFun->GetSubShapeReferences(); + if ( aListEntries.IsEmpty() ) + return; + + TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries); + for ( ; anIt.More(); anIt.Next() ) { + TCollection_ExtendedString aSubEntry = anIt.Value(); + Standard_Integer aStrLen = aSubEntry.LengthOfCString(); + char* aSubEntryStr = new char[aStrLen+1]; + aSubEntry.ToUTF8CString( aSubEntryStr ); + foundIt = aParents.find( aSubEntryStr ); + if ( foundIt == aParents.end() ) { // add to sub-objects if it is not in parents list + foundIt = aSelected.find( aSubEntryStr ); + if ( foundIt == aSelected.end() ) { // add to sub-objects if it is not in selected list + aChildren.insert( aSubEntryStr ); + foundIt = anOthers.find( aSubEntryStr ); + if ( foundIt != anOthers.end() ) + anOthers.erase( foundIt ); + } + } + includeSubObjects( theStudy, aSubEntryStr, aSelected, aParents, aChildren, anOthers ); + } +} //===================================================================================== // EXPORTED METHODS //===================================================================================== diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh index 27242fe5b..7d074fa81 100644 --- a/src/GEOM_I/GEOM_Gen_i.hh +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -391,11 +391,18 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi std::map< std::string, std::set > &passedEntries, int level = 0 ); - void getParentDependencies(GEOM::GEOM_BaseObject_ptr gbo, - std::set& aSelected, - std::set& aParents, - std::set& aChildren, - std::set& anOthers); + void includeParentDependencies(GEOM::GEOM_BaseObject_ptr gbo, + std::set& aSelected, + std::set& aParents, + std::set& aChildren, + std::set& anOthers); + + void includeSubObjects(SALOMEDS::Study_ptr theStudy, + const std::string& aSelectedEntry, + std::set& aSelected, + std::set& aParents, + std::set& aChildren, + std::set& anOthers); private: