]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2053 fix: on open file create results taking into account dependencies in...
authormpv <mpv@opencascade.com>
Fri, 24 Mar 2017 08:15:52 +0000 (11:15 +0300)
committermpv <mpv@opencascade.com>
Fri, 24 Mar 2017 08:15:52 +0000 (11:15 +0300)
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h

index f0ebc884c6dae7d99123843e29196f0f92374249..dca740f6c558dc6d821677c2b574f460446b7c56 100644 (file)
@@ -723,23 +723,15 @@ void Model_Objects::synchronizeFeatures(
   // they may be connected, like sketch and sub elements)
   // After synchronisation of back references because sketch
   // must be set in sub-elements before "execute" by updateResults
-  std::list<FeaturePtr> aComposites; // composites must be updated after their subs (issue 360)
+  std::set<FeaturePtr> aProcessed; // composites must be updated after their subs (issue 360)
   TDF_ChildIDIterator aLabIter2(featuresLabel(), TDataStd_Comment::GetID());
   for (; aLabIter2.More(); aLabIter2.Next()) {
     TDF_Label aFeatureLabel = aLabIter2.Value()->Label();
     if (myFeatures.IsBound(aFeatureLabel)) {  // a new feature is inserted
       FeaturePtr aFeature = myFeatures.Find(aFeatureLabel);
-      if (std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature).get())
-        aComposites.push_back(aFeature);
-      else
-        updateResults(aFeature);
+      updateResults(aFeature, aProcessed);
     }
   }
-  std::list<FeaturePtr>::iterator aComposite = aComposites.begin();
-  for(; aComposite != aComposites.end(); aComposite++) {
-    updateResults(*aComposite);
-  }
-
   // the synchronize should be done after updateResults
   // in order to correct back references of updated results
   if (theUpdateReferences) {
@@ -1075,8 +1067,22 @@ std::string Model_Objects::featureResultGroup(FeaturePtr theFeature)
   return anEmpty; // not found
 }
 
-void Model_Objects::updateResults(FeaturePtr theFeature)
+void Model_Objects::updateResults(FeaturePtr theFeature, std::set<FeaturePtr>& theProcessed)
 {
+  if (theProcessed.find(theFeature) != theProcessed.end())
+    return;
+  theProcessed.insert(theFeature);
+  // for composites update subs recursively (sketch elements results are needed for the sketch)
+  CompositeFeaturePtr aComp = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
+  if (aComp.get()) {
+    // update subs of composites first
+    int aSubNum = aComp->numberOfSubs();
+    for(int a = 0; a < aSubNum; a++) {
+      FeaturePtr aSub = aComp->subFeature(a);
+      updateResults(aComp->subFeature(a), theProcessed);
+    }
+  }
+
   // for not persistent is will be done by parametric updater automatically
   //if (!theFeature->isPersistentResult()) return;
   // check the existing results and remove them if there is nothing on the label
index 9b7b6bda3026b45366e8c8d393826d30ccc26720..c4bc24476d0c6debef193b6edfa8bee62ccd55eb 100644 (file)
@@ -174,7 +174,8 @@ class Model_Objects
                         const int theResultIndex);
 
   //! Updates the results list of the feature basing on the current data tree
-  void updateResults(FeaturePtr theFeature);
+  //! theProcessed is used to avoid update twice (since the function is recursive)
+  void updateResults(FeaturePtr theFeature, std::set<FeaturePtr>& theProcessed);
 
   /// Internally makes document know that feature was removed or added in history after creation
   void updateHistory(const std::shared_ptr<ModelAPI_Object> theObject);