From: mpv Date: Fri, 9 Oct 2015 07:32:32 +0000 (+0300) Subject: Optimize the process of stability flag changes (and concealment update): now only... X-Git-Tag: V_1.4.0_demo2~10^2~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7ad083ee0757f9933a873d5830e3f63e7c359ce7;p=modules%2Fshaper.git Optimize the process of stability flag changes (and concealment update): now only the modified feature modification used. --- diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 64574892c..e43e34e25 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -382,12 +382,11 @@ void Model_Data::removeBackReference(FeaturePtr theFeature, std::string theAttrI void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID, const bool theApplyConcealment) { - // do not add the same attribute twice + // it is possible to add the same attribute twice: may be last time the owner was not Stable... AttributePtr anAttribute = theFeature->data()->attribute(theAttrID); - if (myRefsToMe.find(anAttribute) != myRefsToMe.end()) - return; + if (myRefsToMe.find(anAttribute) == myRefsToMe.end()) + myRefsToMe.insert(theFeature->data()->attribute(theAttrID)); - myRefsToMe.insert(theFeature->data()->attribute(theAttrID)); if (theApplyConcealment && theFeature->isStable() && ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) { std::shared_ptr aRes = diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 21e38c5a4..0f8c3abdc 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -676,12 +676,37 @@ void Model_Update::executeFeature(FeaturePtr theFeature) void Model_Update::updateStability(void* theSender) { - ModelAPI_Object* aSender = static_cast(theSender); - if (aSender && aSender->document()) { - Model_Objects* aDocObjects = - std::dynamic_pointer_cast(aSender->document())->objects(); - if (aDocObjects) { - aDocObjects->synchronizeBackRefs(); + if (theSender) { + ModelAPI_Object* aSender = static_cast(theSender); + if (aSender && aSender->document()) { + FeaturePtr aFeatureSender = + std::dynamic_pointer_cast(aSender->data()->owner()); + if (aFeatureSender.get()) { + Model_Objects* aDocObjects = + std::dynamic_pointer_cast(aSender->document())->objects(); + if (aDocObjects) { + //aDocObjects->synchronizeBackRefs(); + // remove or add all concealment refs from this feature + std::list > > aRefs; + aSender->data()->referencesToObjects(aRefs); + std::list > >::iterator aRefIt = aRefs.begin(); + for(; aRefIt != aRefs.end(); aRefIt++) { + std::list& aRefFeaturesList = aRefIt->second; + std::list::iterator aReferenced = aRefFeaturesList.begin(); + for(; aReferenced != aRefFeaturesList.end(); aReferenced++) { + if (aReferenced->get() && (*aReferenced)->data()->isValid()) { + std::shared_ptr aData = + std::dynamic_pointer_cast((*aReferenced)->data()); + if (aFeatureSender->isStable()) { + aData->addBackReference(aFeatureSender, aRefIt->first); + } else { + aData->removeBackReference(aFeatureSender, aRefIt->first); + } + } + } + } + } + } } } }