- if (theDoc->isLaterByDep(aThisFeature, aRefFeat)) {
- // for extrusion cut in python script the nested sketch reference may be concealed before
- // it is nested, so, check this composite feature is valid
- static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
- // need to be validated to update the "Apply" state if not previewed
- if (aFactory->validate(aRefFeat)) {
- // there could be a reference to unmodified object, check result contain same shape
- std::list<ResultPtr> aRefResults;
- ModelAPI_Tools::allResults(aRefFeat, aRefResults);
- std::list<ResultPtr>::iterator aRefIter = aRefResults.begin();
- for(; aRefIter != aRefResults.end(); aRefIter++) {
- ResultBodyPtr aRefBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRefIter);
- if (!aRefBody.get() || aRefBody->numberOfSubs() != 0) // iterate only leafs
- continue;
- GeomShapePtr aRefShape = aRefBody->shape();
- if (!aRefShape.get() || aRefShape->isNull())
- continue;
- if (aRefShape->impl<TopoDS_Shape>().IsSame(theContShape)) {
- // add the new context result with the same shape
- aResults.insert(aRefBody);
- }
- }
- if (aResults.empty())
- return true; // feature conceals result, return true, so the context will be removed
- }
+ if (aRefShape->impl<TopoDS_Shape>().IsSame(theContShape)) {
+ // add the new context result with the same shape
+ aResults.push_back(aRefBody);
+ }
+ }
+ if (aResults.empty())
+ return true; // feature conceals result, return true, so the context will be removed
+ }
+ aStaySame = aResults.empty();
+ }
+ if (myParent && myParent->isMakeCopy()) {
+ // check there are copies before the new results, so, make a copy
+ std::list<ObjectPtr> aCopyContext;
+ std::list<GeomShapePtr> aCopyVals;
+ // features between the new and the old: check the "Move" interface to get a copy
+ FeaturePtr aRootOwner = theDoc->feature(theContext);
+ FeaturePtr anOwner = ModelAPI_Tools::compositeOwner(aRootOwner);
+ for(; anOwner.get(); anOwner = ModelAPI_Tools::compositeOwner(anOwner))
+ aRootOwner = anOwner;
+ FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ // iterate all results to find a "Copy" features between the new and one and to add the
+ // copy-results also to results if this attribute refers to the copied shape
+ int anIndex = kUNDEFINED_FEATURE_INDEX;
+ for(FeaturePtr aFeat = theDoc->objects()->nextFeature(aRootOwner, anIndex); aFeat.get() &&
+ aFeat != aThisFeature; aFeat = theDoc->objects()->nextFeature(aFeat, anIndex)) {
+ std::shared_ptr<ModelAPI_FeatureCopyInterface> aCopier =
+ std::dynamic_pointer_cast<ModelAPI_FeatureCopyInterface>(aFeat);
+ if (aCopier.get()) {
+ GeomShapePtr aValShape(new GeomAPI_Shape);
+ aValShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(
+ theValShape.IsNull() ? theContShape : theValShape));
+ aCopier->getCopies(theContext, aValShape, aCopyContext, aCopyVals);
+ }
+ }
+ // check for the further modifications of the copy contexts and values
+ std::list<ObjectPtr>::iterator aCopyContIter = aCopyContext.begin();
+ std::list<GeomShapePtr>::iterator aCopyValIter = aCopyVals.begin();
+ for(; aCopyContIter != aCopyContext.end(); aCopyContIter++, aCopyValIter++) {
+ ResultPtr aNewCont = std::dynamic_pointer_cast<ModelAPI_Result>(*aCopyContIter);
+ TopoDS_Shape aNewContShape = aNewCont->shape()->impl<TopoDS_Shape>();
+ GeomShapePtr aNewVal = *aCopyValIter;
+ TopoDS_Shape aNewValShape;
+ if (aNewVal.get() && !aNewVal->isNull())
+ aNewValShape = aNewVal->impl<TopoDS_Shape>();
+ std::list<ResultPtr> aNewRes;
+ TopTools_ListOfShape aNewUpdatedVal;
+ if (searchNewContext(theDoc, aNewContShape, aNewCont, aNewValShape,
+ theAccessLabel, aNewRes, aNewUpdatedVal)) {
+ // append new results instead of the current ones
+ std::list<ResultPtr>::iterator aNewIter = aNewRes.begin();
+ TopTools_ListIteratorOfListOfShape aNewUpdVal(aNewUpdatedVal);
+ for(; aNewIter != aNewRes.end(); aNewIter++, aNewUpdVal.Next()) {
+ theResults.push_back(*aNewIter);
+ theValShapes.Append(aNewUpdVal.Value());