]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
To avoid cyclic recursion in solve space recomputation
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 6 Nov 2014 08:07:51 +0000 (11:07 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 6 Nov 2014 08:07:51 +0000 (11:07 +0300)
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/SketchSolver/SketchSolver_ConstraintManager.h

index ebc25b1fa35edf7dbbb20e78b976258937cd914c..1dec2867f7ee2b098386b0f51ffcf5a82c12353f 100644 (file)
@@ -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<Events_Message>& 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<ModelAPI_CompositeFeature> SketchSolver_ConstraintManager::fin
 // ============================================================================
 void SketchSolver_ConstraintManager::resolveConstraints()
 {
+  myIsComputed = true;
   bool needToUpdate = false;
   std::vector<SketchSolver_ConstraintGroup*>::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;
 }
 
index b13a67182460bb373c4da9300f00f250415e16b5..422ae03478af62197f2413d80c130b36e025e05b 100644 (file)
@@ -101,6 +101,9 @@ class SketchSolver_ConstraintManager : public Events_Listener
  private:
   static SketchSolver_ConstraintManager* _self;  ///< Self pointer to implement singleton functionality
   std::vector<SketchSolver_ConstraintGroup*> myGroups;  ///< Groups of constraints
+  /// true if computation is performed and all "updates" are generated by this algo
+  /// and needs no recomputation
+  bool myIsComputed;
 };
 
 #endif