From: mpv Date: Thu, 6 Nov 2014 08:07:51 +0000 (+0300) Subject: To avoid cyclic recursion in solve space recomputation X-Git-Tag: V_0.5~32^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b7b6dfeb6d8d31f738f75ec4889582dc021fda06;p=modules%2Fshaper.git To avoid cyclic recursion in solve space recomputation --- diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index ebc25b1fa..1dec2867f 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -41,6 +41,7 @@ SketchSolver_ConstraintManager* SketchSolver_ConstraintManager::Instance() SketchSolver_ConstraintManager::SketchSolver_ConstraintManager() { myGroups.clear(); + myIsComputed = false; // Register in event loop Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); @@ -62,6 +63,8 @@ SketchSolver_ConstraintManager::~SketchSolver_ConstraintManager() void SketchSolver_ConstraintManager::processEvent( const boost::shared_ptr& theMessage) { + if (myIsComputed) + return; if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED) || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED) || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) { @@ -363,6 +366,7 @@ boost::shared_ptr SketchSolver_ConstraintManager::fin // ============================================================================ void SketchSolver_ConstraintManager::resolveConstraints() { + myIsComputed = true; bool needToUpdate = false; std::vector::iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) @@ -372,5 +376,6 @@ void SketchSolver_ConstraintManager::resolveConstraints() // Features may be updated => send events if (needToUpdate) Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + myIsComputed = false; } diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.h b/src/SketchSolver/SketchSolver_ConstraintManager.h index b13a67182..422ae0347 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.h +++ b/src/SketchSolver/SketchSolver_ConstraintManager.h @@ -101,6 +101,9 @@ class SketchSolver_ConstraintManager : public Events_Listener private: static SketchSolver_ConstraintManager* _self; ///< Self pointer to implement singleton functionality std::vector myGroups; ///< Groups of constraints + /// true if computation is performed and all "updates" are generated by this algo + /// and needs no recomputation + bool myIsComputed; }; #endif