From 1b169f78f27c437be2291249ab89788f36df7250 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 24 Mar 2017 11:15:52 +0300 Subject: [PATCH] Issue #2053 fix: on open file create results taking into account dependencies in composite features. --- src/Model/Model_Objects.cpp | 28 +++++++++++++++++----------- src/Model/Model_Objects.h | 3 ++- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index f0ebc884c..dca740f6c 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -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 aComposites; // composites must be updated after their subs (issue 360) + std::set 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(aFeature).get()) - aComposites.push_back(aFeature); - else - updateResults(aFeature); + updateResults(aFeature, aProcessed); } } - std::list::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& 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(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 diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index 9b7b6bda3..c4bc24476 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -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& theProcessed); /// Internally makes document know that feature was removed or added in history after creation void updateHistory(const std::shared_ptr theObject); -- 2.39.2