From 79ad806c7ac0a19b9cc96b979e3cf14d6215f2e0 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 22 May 2014 14:18:41 +0400 Subject: [PATCH] Adding constraint to the appropriate group --- .../SketchSolver_ConstraintManager.cpp | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 4a47879fa..b2ebd3d24 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -12,6 +12,7 @@ #include #include #include + #include #include #include @@ -21,6 +22,8 @@ #include #include +#include + /// Tolerance for value of parameters const double tolerance = 1.e-10; @@ -237,10 +240,16 @@ void SketchSolver_ConstraintManager::findGroups( boost::shared_ptr SketchSolver_ConstraintManager::findWorkplaneForConstraint( boost::shared_ptr theConstraint) const { + // Already verified workplanes + std::set< boost::shared_ptr > aVerified; + std::vector::const_iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) { boost::shared_ptr aWP = (*aGroupIter)->getWorkplane(); + if (aVerified.find(aWP) != aVerified.end()) + continue; + boost::shared_ptr aWPFeatures = boost::dynamic_pointer_cast(aWP->data()->attribute(SKETCH_ATTR_FEATURES)); std::list< boost::shared_ptr > aFeaturesList = aWPFeatures->list(); @@ -248,6 +257,7 @@ boost::shared_ptr SketchSolver_ConstraintManager::findWork for (anIter = aFeaturesList.begin(); anIter != aFeaturesList.end(); anIter++) if (*anIter == theConstraint) return aWP; // workplane is found + aVerified.insert(aWP); } return boost::shared_ptr(); @@ -310,7 +320,19 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::isInteract( if (myWorkplane.h != SLVS_E_UNKNOWN && myConstraints.empty()) return true; - /// \todo Should be implemented + // Go through constraint entities and verify if some of them already in the group + for (int i = 0; i < CONSTRAINT_ATTR_SIZE; i++) + { + boost::shared_ptr aCAttrRef = + boost::dynamic_pointer_cast( + theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[i]) + ); + if (!aCAttrRef) continue; + if (myEntityMap.find(aCAttrRef->attr()) != myEntityMap.end()) + return true; + } + + // Entities did not found return false; } -- 2.30.2