From 8a62402d4f55c542df46f57562996171e4b29ea7 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 19 Dec 2016 19:18:37 +0300 Subject: [PATCH] PlaneGCS: update all arc parameters when moving start/end point --- src/SketchPlugin/Test/TestArcBehavior.py | 39 +++++++++++++++++++ .../PlaneGCSSolver/PlaneGCSSolver_Storage.cpp | 14 +++++-- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/SketchPlugin/Test/TestArcBehavior.py b/src/SketchPlugin/Test/TestArcBehavior.py index 7498a37d5..24014cae2 100644 --- a/src/SketchPlugin/Test/TestArcBehavior.py +++ b/src/SketchPlugin/Test/TestArcBehavior.py @@ -131,3 +131,42 @@ for aCenterCoords in range(-20, 20): anArcCentr.setValue(aCenterCoords, aCenterCoords/2) # move center aSession.finishOperation() assert aSketchArc.boolean("InversedArc").value() == anInversed +#========================================================================= +# Test that movement of start point of arc does not change central point +#========================================================================= +TOL = 1.e-5 +x = anArcCentr.x() +y = anArcCentr.y() +sx = anArcStartPoint.x() +sy = anArcStartPoint.y() +for aDelta in range(0, 20): + aSession.startOperation() + anArcStartPoint.setValue(sx, sy+aDelta) # move start point + aSession.finishOperation() + assert math.fabs(anArcCentr.x() - x) < TOL + assert math.fabs(anArcCentr.y() - y) < TOL +for aDelta in range(20, -1, -1): + aSession.startOperation() + anArcStartPoint.setValue(sx, sy+aDelta) # move start point + aSession.finishOperation() + assert math.fabs(anArcCentr.x() - x) < TOL + assert math.fabs(anArcCentr.y() - y) < TOL +#========================================================================= +# Test that movement of end point of arc does not change central point +#========================================================================= +x = anArcCentr.x() +y = anArcCentr.y() +sx = anArcEndPoint.x() +sy = anArcEndPoint.y() +for aDelta in range(0, 20): + aSession.startOperation() + anArcEndPoint.setValue(sx+aDelta, sy) # move end point + aSession.finishOperation() + assert math.fabs(anArcCentr.x() - x) < TOL + assert math.fabs(anArcCentr.y() - y) < TOL +for aDelta in range(20, -1, -1): + aSession.startOperation() + anArcEndPoint.setValue(sx+aDelta, sy) # move end point + aSession.finishOperation() + assert math.fabs(anArcCentr.x() - x) < TOL + assert math.fabs(anArcCentr.y() - y) < TOL diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 6c8527ada..37086e22f 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -389,8 +389,11 @@ void PlaneGCSSolver_Storage::processArc(const EntityWrapperPtr& theArc) // Calculate additional parameters necessary for PlaneGCS const std::list& aSubs = theArc->subEntities(); std::list::const_iterator aSubIt = aSubs.begin(); - while ((*aSubIt)->type() == ENTITY_POINT) // search scalar entities + bool isFixed[3] = {false, false, false}; + for (int i = 0; (*aSubIt)->type() == ENTITY_POINT; ++i) { // search scalar entities + isFixed[i] = (*aSubIt)->group() == GID_OUTOFGROUP; ++aSubIt; + } double* aStartAngle = std::dynamic_pointer_cast(*aSubIt++)->scalar(); double* aEndAngle = @@ -411,7 +414,10 @@ void PlaneGCSSolver_Storage::processArc(const EntityWrapperPtr& theArc) std::shared_ptr aStartPnt = aStartAttr->pnt(); std::shared_ptr aEndPnt = aEndAttr->pnt(); - *aRadius = aCenterPnt->distance(aStartPnt); + if (isFixed[2] && !isFixed[1]) + *aRadius = aCenterPnt->distance(aEndPnt); + else + *aRadius = aCenterPnt->distance(aStartPnt); if (!anArcFeature->lastResult()) return; static std::shared_ptr OX(new GeomAPI_Dir2d(1.0, 0.0)); @@ -428,8 +434,8 @@ void PlaneGCSSolver_Storage::processArc(const EntityWrapperPtr& theArc) // No need to add constraints if they are already exist std::map >::const_iterator aFound = myArcConstraintMap.find(theArc); - if (aFound != myArcConstraintMap.end()) - return; +// if (aFound != myArcConstraintMap.end()) +// return; // Prepare additional constraints to produce the arc std::vector anArcConstraints; -- 2.39.2