Get sub-objects recursively. Miss sub-object if it is in 'selected' list.

This commit is contained in:
akl 2014-06-23 18:12:26 +04:00
parent 420061dfc0
commit 4805532bcf
2 changed files with 67 additions and 38 deletions

View File

@ -3238,7 +3238,7 @@ void GEOM_Gen_i::GetEntriesToCleanStudy(SALOMEDS::Study_ptr theStudy,
if ( aSelected.count( anEntry ) > 0 && if ( aSelected.count( anEntry ) > 0 &&
aParents.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 && } else if ( aParents.count( anEntry ) == 0 &&
aChildren.count( anEntry ) == 0 ) { aChildren.count( anEntry ) == 0 ) {
anOthers.insert( geomObj->GetEntry() ); anOthers.insert( geomObj->GetEntry() );
@ -3252,32 +3252,7 @@ void GEOM_Gen_i::GetEntriesToCleanStudy(SALOMEDS::Study_ptr theStudy,
// filling list of sub-objects // filling list of sub-objects
for ( it = aSelected.begin(); it != aSelected.end(); ++it ) { for ( it = aSelected.begin(); it != aSelected.end(); ++it ) {
Handle(GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), (*it).c_str(), false); includeSubObjects( theStudy, *it, aSelected, aParents, aChildren, anOthers );
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 );
}
}
} }
// if some selected object is not a main shape, // if some selected object is not a main shape,
@ -3332,7 +3307,11 @@ void GEOM_Gen_i::GetEntriesToCleanStudy(SALOMEDS::Study_ptr theStudy,
} }
} }
void GEOM_Gen_i::getParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj, //==============================================================================
// function : includeParentDependencies
// purpose :
//==============================================================================
void GEOM_Gen_i::includeParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj,
std::set<std::string>& aSelected, std::set<std::string>& aSelected,
std::set<std::string>& aParents, std::set<std::string>& aParents,
std::set<std::string>& aChildren, std::set<std::string>& aChildren,
@ -3363,10 +3342,53 @@ void GEOM_Gen_i::getParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj,
aParents.count( aDepEntry ) > 0 // skip already processed objects aParents.count( aDepEntry ) > 0 // skip already processed objects
) )
continue; 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<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers)
{
std::set<std::string>::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 // EXPORTED METHODS
//===================================================================================== //=====================================================================================

View File

@ -391,7 +391,14 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
std::map< std::string, std::set<std::string> > &passedEntries, std::map< std::string, std::set<std::string> > &passedEntries,
int level = 0 ); int level = 0 );
void getParentDependencies(GEOM::GEOM_BaseObject_ptr gbo, void includeParentDependencies(GEOM::GEOM_BaseObject_ptr gbo,
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers);
void includeSubObjects(SALOMEDS::Study_ptr theStudy,
const std::string& aSelectedEntry,
std::set<std::string>& aSelected, std::set<std::string>& aSelected,
std::set<std::string>& aParents, std::set<std::string>& aParents,
std::set<std::string>& aChildren, std::set<std::string>& aChildren,