continue;
}
+ ResultPtr aNewContext = *aNewCont;
+ if (aValueShape.get()) { // #2892 if context is higher level result, search this sub in lower
+ ResultBodyPtr aBodyContext = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aNewContext);
+ if (aBodyContext.get() && aBodyContext->numberOfSubs() != 0) {
+ std::list<ResultPtr> aLower;
+ ModelAPI_Tools::allSubs(aBodyContext, aLower, true);
+ for(std::list<ResultPtr>::iterator aL = aLower.begin(); aL != aLower.end(); aL++) {
+ GeomShapePtr aLShape = (*aL)->shape();
+ if (aLShape.get() && !aLShape->isNull()) {
+ if (aLShape->isSubShape(aValueShape, false)) {
+ aNewContext = *aL;
+ break;
+ }
+ }
+ }
+ }
+ }
+
if (aFirst) {
- if (!myParent || !myParent->isInList(*aNewCont, aValueShape)) { // avoid duplicates
- setValue(*aNewCont, aValueShape);
+ if (!myParent || !myParent->isInList(aNewContext, aValueShape)) { // avoid duplicates
+ setValue(aNewContext, aValueShape);
aFirst = false;
}
} else if (myParent) {
- if (!myParent->isInList(*aNewCont, aValueShape)) // avoid addition of duplicates
- myParent->append(*aNewCont, aValueShape);
+ if (!myParent->isInList(aNewContext, aValueShape)) // avoid addition of duplicates
+ myParent->append(aNewContext, aValueShape);
}
}
if (aFirst) { // nothing was added, all results were deleted
return aCompSolid.get() && aCompSolid->numberOfSubs() > 0;
}
-void allSubs(const ResultBodyPtr& theResult, std::list<ResultPtr>& theResults) {
+void allSubs(const ResultBodyPtr& theResult, std::list<ResultPtr>& theResults,
+ const bool theLowerOnly) {
// iterate sub-bodies of compsolid
ResultBodyPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
if (aComp.get()) {
int aNumSub = aComp->numberOfSubs();
for (int a = 0; a < aNumSub; a++) {
ResultBodyPtr aSub = aComp->subResult(a);
- theResults.push_back(aSub);
+ if (!theLowerOnly || aSub->numberOfSubs() == 0)
+ theResults.push_back(aSub);
allSubs(aSub, theResults);
}
}
* collects recursively all subs of the given result
*/
MODELAPI_EXPORT void allSubs(const std::shared_ptr<ModelAPI_ResultBody>& theResult,
- std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
+ std::list<std::shared_ptr<ModelAPI_Result> >& theResults,
+ const bool theLowerOnly = false);
/*!
* Adds the results of the given feature to theResults list: including disabled and sub-results