- for (int anIndex = 0; anIndex < aResultBody->numberOfSubs(); ++anIndex) {
- ResultBodyPtr aSubResult = aResultBody->subResult(anIndex);
- if(aSubResult->shape()->isEqual(aSubShape)) {
- aSubShapesToRemoveAttrList->append(aSubResult, aSubShape);
+ std::list<ResultPtr> anAllSubs;
+ ModelAPI_Tools::allSubs(aResultBody, anAllSubs);
+ std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
+ for(; aSubsIt != anAllSubs.end(); aSubsIt++) {
+ ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
+ if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
+ aSubShapesToRemoveAttrList->append(aSub, aSubShape);