From 353485be16b583b41b05a3944bf9182c7e1875bf Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 7 May 2020 10:26:30 +0300 Subject: [PATCH] Optimization of the neighbors selection in the issue #19071 : Selecting edges to create group takes too much time --- src/Model/Model_Update.cpp | 4 ++++ src/Selector/Selector_FilterByNeighbors.cpp | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 052468c78..d006d4374 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -911,6 +911,8 @@ void Model_Update::updateArguments(FeaturePtr theFeature) { for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) { std::shared_ptr aSel = std::dynamic_pointer_cast(*aRefsIter); + // #19071 : avoid sending of update event in cycle + bool aWasBlocked = theFeature->data()->blockSendAttributeUpdated(true); for(int a = aSel->size() - 1; a >= 0; a--) { std::shared_ptr aSelAttr = std::dynamic_pointer_cast(aSel->value(a)); @@ -935,6 +937,8 @@ void Model_Update::updateArguments(FeaturePtr theFeature) { } } } + if (!aWasBlocked) + theFeature->data()->blockSendAttributeUpdated(false); } if (aState != ModelAPI_StateDone) diff --git a/src/Selector/Selector_FilterByNeighbors.cpp b/src/Selector/Selector_FilterByNeighbors.cpp index c0db2d66d..e492ab8d3 100644 --- a/src/Selector/Selector_FilterByNeighbors.cpp +++ b/src/Selector/Selector_FilterByNeighbors.cpp @@ -194,7 +194,9 @@ bool Selector_FilterByNeighbors::select( myContext = theContextLab; // searching by neighbors std::list > aNBs; /// neighbor sub-shape -> level of neighborhood - for(int aLevel = 1; true; aLevel++) { + // # 19071 : moving through all levels may be too long, in practice there are no more than 2 or 3 + // levels real cases, so, make it "5" as maximum possible + for(int aLevel = 1; aLevel < 5; aLevel++) { TopTools_MapOfShape aNewNB; findNeighbors(theContext, theValue, aLevel, aNewNB); if (aNewNB.Extent() == 0) { // there are no neighbors of the given level, stop iteration -- 2.39.2