From 99171e51b501c3519c2379e4fe80cb56d881b040 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 8 Feb 2016 16:32:07 +0300 Subject: [PATCH] Fix the problem while moving arc with fixed point --- src/SketchPlugin/SketchPlugin_Arc.cpp | 17 +++++++++++------ src/SketchSolver/SketchSolver_Group.cpp | 8 ++++---- .../SolveSpaceSolver_Storage.cpp | 11 +++++++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index aacdeca1f..2725d8790 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -399,8 +399,6 @@ static inline void calculatePassedPoint( void SketchPlugin_Arc::updateDependentAttributes() { - data()->blockSendAttributeUpdated(true); - std::shared_ptr aCenterAttr = std::dynamic_pointer_cast< GeomDataAPI_Point2D>(data()->attribute(CENTER_ID())); std::shared_ptr aStartAttr = std::dynamic_pointer_cast< @@ -414,12 +412,19 @@ void SketchPlugin_Arc::updateDependentAttributes() AttributeDoublePtr anAngleAttr = std::dynamic_pointer_cast( data()->attribute(ANGLE_ID())); + if (!aPassedPoint) + return; + + data()->blockSendAttributeUpdated(true); + calculatePassedPoint(aCenterAttr->pnt(), aStartAttr->pnt(), anEndAttr->pnt(), isReversed(), aPassedPoint); - std::shared_ptr aCircle( - new GeomAPI_Circ2d(aStartAttr->pnt(), anEndAttr->pnt(), aPassedPoint->pnt())); - calculateArcAngleRadius(aCircle, aStartAttr->pnt(), anEndAttr->pnt(), aPassedPoint->pnt(), - anAngleAttr, aRadiusAttr); + if (aRadiusAttr && anAngleAttr) { + std::shared_ptr aCircle( + new GeomAPI_Circ2d(aStartAttr->pnt(), anEndAttr->pnt(), aPassedPoint->pnt())); + calculateArcAngleRadius(aCircle, aStartAttr->pnt(), anEndAttr->pnt(), aPassedPoint->pnt(), + anAngleAttr, aRadiusAttr); + } data()->blockSendAttributeUpdated(false); } diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 84d6a0bb2..1da845930 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -316,10 +316,10 @@ bool SketchSolver_Group::resolveConstraints() aResult = mySketchSolver->solve(); if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET || isLastChance) break; - // try to update parameters and resolve once again - ConstraintConstraintMap::iterator aConstrIt = myConstraints.begin(); - for (; aConstrIt != myConstraints.end(); ++aConstrIt) - aConstrIt->second->update(); +//// // try to update parameters and resolve once again +//// ConstraintConstraintMap::iterator aConstrIt = myConstraints.begin(); +//// for (; aConstrIt != myConstraints.end(); ++aConstrIt) +//// aConstrIt->second->update(); isLastChance = true; removeTemporaryConstraints(); diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index a060f20df..154334351 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -129,7 +129,7 @@ bool SolveSpaceSolver_Storage::update(EntityWrapperPtr theEntity) if (anEntity->baseAttribute()) { BuilderPtr aBuilder = SolveSpaceSolver_Builder::getInstance(); EntityWrapperPtr anUpdAttr = aBuilder->createAttribute(anEntity->baseAttribute(), GID_UNKNOWN); - if (anUpdAttr) { + if (anUpdAttr && !isFixed(theEntity)) { std::list anUpdParams = anUpdAttr->parameters(); std::list::iterator anUpdIt = anUpdParams.begin(); for (aPIt = aParams.begin(); aPIt != aParams.end() && anUpdIt != anUpdParams.end(); @@ -1129,10 +1129,17 @@ void SolveSpaceSolver_Storage::verifyFixed() for (; anAttrIt != myAttributeMap.end(); ++anAttrIt) { if (!anAttrIt->second) continue; + if (anAttrIt->second->group() == GID_OUTOFGROUP) { + Slvs_Entity anEnt = getEntity((Slvs_hEntity)anAttrIt->second->id()); + if (anEnt.group != (Slvs_hEntity)GID_OUTOFGROUP) + anEnt.group = (Slvs_hEntity)GID_OUTOFGROUP; + updateEntity(anEnt); + } + const std::list& aParameters = anAttrIt->second->parameters(); std::list::const_iterator aParIt = aParameters.begin(); for (; aParIt != aParameters.end(); ++aParIt) - if ((*aParIt)->group() == GID_OUTOFGROUP) { + if (anAttrIt->second->group() == GID_OUTOFGROUP || (*aParIt)->group() == GID_OUTOFGROUP) { Slvs_Param aParam = getParameter((Slvs_hParam)(*aParIt)->id()); if (aParam.group != (Slvs_hParam)GID_OUTOFGROUP) { aParam.group = (Slvs_hParam)GID_OUTOFGROUP; -- 2.39.2