From 4619c9af2c14a7309ccfd4d4cb81c5878a3389e5 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 14 Sep 2015 15:09:00 +0300 Subject: [PATCH] Avoid duplicating entities placed in temporary constraints. --- src/SketchSolver/SketchSolver_Group.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 0e4093ffa..8b4026ef2 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -147,11 +147,12 @@ Slvs_hEntity SketchSolver_Group::getFeatureId(FeaturePtr theFeature) const Slvs_hEntity aResult = SLVS_E_UNKNOWN; if (!myFeatureStorage) return aResult; + // Obtain regular constraints interacting with the feature and find its ID std::set aConstraints = myFeatureStorage->getConstraints(theFeature); if (aConstraints.empty()) return aResult; std::set::iterator aConstrIter = aConstraints.begin(); - for (; aConstrIter != aConstraints.end(); aConstrIter++) { + for (; aConstrIter != aConstraints.end(); ++aConstrIter) { ConstraintConstraintMap::const_iterator aCIter = myConstraints.find(*aConstrIter); if (aCIter == myConstraints.end()) continue; @@ -159,7 +160,11 @@ Slvs_hEntity SketchSolver_Group::getFeatureId(FeaturePtr theFeature) const if (aResult != SLVS_E_UNKNOWN) return aResult; } - return SLVS_E_UNKNOWN; + // The feature is not found, check it in the temporary constraints + std::set::iterator aTmpCIter = myTempConstraints.begin(); + for (; aTmpCIter != myTempConstraints.end() && aResult == SLVS_E_UNKNOWN; ++aTmpCIter) + aResult = (*aTmpCIter)->getId(theFeature); + return aResult; } // ============================================================================ @@ -172,6 +177,7 @@ Slvs_hEntity SketchSolver_Group::getAttributeId(AttributePtr theAttribute) const Slvs_hEntity aResult = SLVS_E_UNKNOWN; if (!myFeatureStorage) return aResult; + // Obtain regular constraints interacting with the attribute and find its ID std::set aConstraints = myFeatureStorage->getConstraints(theAttribute); if (aConstraints.empty()) return aResult; @@ -184,7 +190,11 @@ Slvs_hEntity SketchSolver_Group::getAttributeId(AttributePtr theAttribute) const if (aResult != SLVS_E_UNKNOWN) return aResult; } - return SLVS_E_UNKNOWN; + // The attribute is not found, check it in the temporary constraints + std::set::iterator aTmpCIter = myTempConstraints.begin(); + for (; aTmpCIter != myTempConstraints.end() && aResult == SLVS_E_UNKNOWN; ++aTmpCIter) + aResult = (*aTmpCIter)->getId(theAttribute); + return aResult; } // ============================================================================ -- 2.39.2