]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Optimize the process of stability flag changes (and concealment update): now only...
authormpv <mpv@opencascade.com>
Fri, 9 Oct 2015 07:32:32 +0000 (10:32 +0300)
committermpv <mpv@opencascade.com>
Fri, 9 Oct 2015 07:32:32 +0000 (10:32 +0300)
src/Model/Model_Data.cpp
src/Model/Model_Update.cpp

index 64574892c2f6cc47dd140f191b25da6fd520ebd4..e43e34e2509d53704740588712c8aa0482af053a 100644 (file)
@@ -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<ModelAPI_Result> aRes = 
index 21e38c5a49de0145a6f0cfa2f98f6c3e934e5f11..0f8c3abdc25693e4d361358eb8ca9b32075da5a2 100644 (file)
@@ -676,12 +676,37 @@ void Model_Update::executeFeature(FeaturePtr theFeature)
 
 void Model_Update::updateStability(void* theSender)
 {
-  ModelAPI_Object* aSender = static_cast<ModelAPI_Object*>(theSender);
-  if (aSender && aSender->document()) {
-    Model_Objects* aDocObjects = 
-      std::dynamic_pointer_cast<Model_Document>(aSender->document())->objects();
-    if (aDocObjects) {
-      aDocObjects->synchronizeBackRefs();
+  if (theSender) {
+    ModelAPI_Object* aSender = static_cast<ModelAPI_Object*>(theSender);
+    if (aSender && aSender->document()) {
+      FeaturePtr aFeatureSender = 
+        std::dynamic_pointer_cast<ModelAPI_Feature>(aSender->data()->owner());
+      if (aFeatureSender.get()) {
+        Model_Objects* aDocObjects = 
+          std::dynamic_pointer_cast<Model_Document>(aSender->document())->objects();
+        if (aDocObjects) {
+          //aDocObjects->synchronizeBackRefs();
+          // remove or add all concealment refs from this feature
+          std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefs;
+          aSender->data()->referencesToObjects(aRefs);
+          std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRefIt = aRefs.begin();
+          for(; aRefIt != aRefs.end(); aRefIt++) {
+            std::list<ObjectPtr>& aRefFeaturesList = aRefIt->second;
+            std::list<ObjectPtr>::iterator aReferenced = aRefFeaturesList.begin();
+            for(; aReferenced != aRefFeaturesList.end(); aReferenced++) {
+              if (aReferenced->get() && (*aReferenced)->data()->isValid()) {
+                std::shared_ptr<Model_Data> aData = 
+                  std::dynamic_pointer_cast<Model_Data>((*aReferenced)->data());
+                if (aFeatureSender->isStable()) {
+                  aData->addBackReference(aFeatureSender, aRefIt->first);
+                } else {
+                  aData->removeBackReference(aFeatureSender, aRefIt->first);
+                }
+              }
+            }
+          }
+        }
+      }
     }
   }
 }