From: azv Date: Wed, 23 Mar 2016 11:05:59 +0000 (+0300) Subject: Update processing of the Angle constraint in the sketch solver connectors X-Git-Tag: V_2.3.0~374 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dd17943e3def56da06075b9fac49424ac58e1990;p=modules%2Fshaper.git Update processing of the Angle constraint in the sketch solver connectors --- diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp index 583c65401..9f92a1c4d 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp @@ -1183,15 +1183,12 @@ void adjustAngle(ConstraintWrapperPtr theConstraint) } } - double anAngle = aLine[0]->direction()->angle(aLine[1]->direction()) / PI * 180; - if (anAngle * aConstraint->value() < 0.0) - aConstraint->setValue(-aConstraint->value()); - if ((90.0 - fabs(anAngle)) * (fabs(aConstraint->value()) - 90.0) > 0.0) { - if (aConstraint->value() < 0.0) - aConstraint->setValue(-180.0 - aConstraint->value()); - else - aConstraint->setValue(180.0 - aConstraint->value()); - } + bool isReversed = false; + for (int i = 0; i < 2; i++) + if (aLine[i]->direction()->dot(aDir[i]) < 0.0) + isReversed = !isReversed; + if (isReversed) + aConstraint->setValue(aConstraint->value() - 180.0); } void makeMirrorPoints(EntityWrapperPtr theOriginal, diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 3fad1d4ad..c0edad021 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -207,7 +207,7 @@ static void updateMultiConstraints(ConstraintConstraintMap& theConstraints, Feat && aCIt->second->isUsed(theFeature)) std::dynamic_pointer_cast(aCIt->second)->update(true); else if ((aType == CONSTRAINT_TANGENT_CIRCLE_LINE || - aType == CONSTRAINT_SYMMETRIC) + aType == CONSTRAINT_SYMMETRIC || aType == CONSTRAINT_ANGLE) && aCIt->second->isUsed(theFeature)) aCIt->second->update(); } diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp index f080a9fca..b277cd707 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp @@ -731,8 +731,8 @@ void adjustAngle(ConstraintWrapperPtr theConstraint) // while changing angle value several times double cosA = cos(aConstraint->value() * PI / 180.0); double sinA = sin(aConstraint->value() * PI / 180.0); - if (aDir[0]->cross(aDir[1]) < 0.0) - sinA *= -1.0; + //if (aDir[0]->cross(aDir[1]) < 0.0) + // sinA *= -1.0; int aLineToUpd = 1; if (isFixed[1][0] && isFixed[1][1]) { sinA *= -1.0; @@ -766,11 +766,9 @@ void adjustAngle(ConstraintWrapperPtr theConstraint) const std::list& anUpdPoints = (*anUpdLine)->subEntities(); std::list::const_iterator aPIt = anUpdPoints.begin(); for (int i = 0; aPIt != anUpdPoints.end(); ++aPIt, ++i) { - double aCoord[2] = {aNewPoints[i]->x(), aNewPoints[i]->y()}; - const std::list& aParams = (*aPIt)->parameters(); - std::list::const_iterator aParIt = aParams.begin(); - for (int j = 0; aParIt != aParams.end(); ++j, ++aParIt) - (*aParIt)->setValue(aCoord[j]); + std::shared_ptr aPnt2D = + std::dynamic_pointer_cast((*aPIt)->baseAttribute()); + aPnt2D->setValue(aNewPoints[i]); } }