From c01dfe708e537d1f1ff857e40103dc843177f37b Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 31 Oct 2014 15:37:00 +0300 Subject: [PATCH] Issue #228: Behavior of "Fixed" constraint is changed --- .../SketchSolver_ConstraintGroup.cpp | 55 ++++--------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index da4af5825..7b1c9bf49 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -547,7 +547,6 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( aParamIter = myParams.begin() + aParamPos; } const bool isEntExists = (aEntIter != myEntityAttrMap.end()); // defines that the entity already exists - bool isFixed = false; // identify the entity is used in "Rigid" constraint const bool isNeedToSolve = myNeedToSolve; myNeedToSolve = false; @@ -559,45 +558,31 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( if (aCoincIter->find(aEntIter->second) != aCoincIter->end()) break; std::set aCoincident; - if (aCoincIter != myCoincidentPoints.end()) + if (aCoincIter != myCoincidentPoints.end()) { aCoincident = *aCoincIter; - else - aCoincident.insert(aEntIter->second); - - std::vector::const_iterator aConstrIter = myConstraints.begin(); - for (; aConstrIter != myConstraints.end(); aConstrIter++) - if (aConstrIter->type == SLVS_C_WHERE_DRAGGED && - aCoincident.find(aConstrIter->ptA) != aCoincident.end()) { - isFixed = true; - break; - } + aCoincident.erase(aEntIter->second); + + std::vector::const_iterator aConstrIter = myConstraints.begin(); + for (; aConstrIter != myConstraints.end(); aConstrIter++) + if (aConstrIter->type == SLVS_C_WHERE_DRAGGED && + aCoincident.find(aConstrIter->ptA) != aCoincident.end()) { + myNeedToSolve = true; + return aEntIter->second; + } + } } // Look over supported types of entities Slvs_Entity aNewEntity; aNewEntity.h = SLVS_E_UNKNOWN; - double anOldValues[3]; // Point in 3D boost::shared_ptr aPoint = boost::dynamic_pointer_cast( theEntity); if (aPoint) { - if (isFixed) - { - anOldValues[0] = aParamIter->val; - anOldValues[1] = (aParamIter+1)->val; - anOldValues[2] = (aParamIter+2)->val; - } Slvs_hParam aX = changeParameter(aPoint->x(), aParamIter); Slvs_hParam aY = changeParameter(aPoint->y(), aParamIter); Slvs_hParam aZ = changeParameter(aPoint->z(), aParamIter); - if (isFixed && myNeedToSolve) - { // the entity is fixed, but its parameters are changed, we need to revert them and recalculate current sketch - aParamIter -= 3; - changeParameter(anOldValues[0], aParamIter); - changeParameter(anOldValues[1], aParamIter); - changeParameter(anOldValues[2], aParamIter); - } if (!isEntExists) // New entity aNewEntity = Slvs_MakePoint3d(++myEntityMaxID, myID, aX, aY, aZ); } else { @@ -609,33 +594,15 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( boost::shared_ptr aPoint2D = boost::dynamic_pointer_cast(theEntity); if (aPoint2D) { - if (isFixed) - { - anOldValues[0] = aParamIter->val; - anOldValues[1] = (aParamIter+1)->val; - } Slvs_hParam aU = changeParameter(aPoint2D->x(), aParamIter); Slvs_hParam aV = changeParameter(aPoint2D->y(), aParamIter); - if (isFixed && myNeedToSolve) - { // the entity is fixed, but its parameters are changed, we need to revert them and recalculate current sketch - aParamIter -= 2; - changeParameter(anOldValues[0], aParamIter); - changeParameter(anOldValues[1], aParamIter); - } if (!isEntExists) // New entity aNewEntity = Slvs_MakePoint2d(++myEntityMaxID, myID, myWorkplane.h, aU, aV); } else { // Scalar value (used for the distance entities) AttributeDoublePtr aScalar = boost::dynamic_pointer_cast(theEntity); if (aScalar) { - if (isFixed) - anOldValues[0] = aParamIter->val; Slvs_hParam aValue = changeParameter(aScalar->value(), aParamIter); - if (isFixed && myNeedToSolve) - { // the entity is fixed, but its parameters are changed, we need to revert them and recalculate current sketch - aParamIter--; - changeParameter(anOldValues[0], aParamIter); - } if (!isEntExists) // New entity aNewEntity = Slvs_MakeDistance(++myEntityMaxID, myID, myWorkplane.h, aValue); } -- 2.39.2