From 4d16f67f43a8a805f8d1e5ef0f8f309ccefd2b5d Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 29 May 2015 14:26:47 +0300 Subject: [PATCH] Issue #542: Wrong arc created on existing points --- src/SketchSolver/SketchSolver_Constraint.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index 6a7ecdb09..27f7b76d1 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -569,11 +569,16 @@ void SketchSolver_Constraint::refresh() { cleanErrorMsg(); std::map::iterator anAttrIter = myAttributeMap.begin(); - for (; anAttrIter != myAttributeMap.end(); anAttrIter++) { + while (anAttrIter != myAttributeMap.end()) { std::shared_ptr aPoint = std::dynamic_pointer_cast(anAttrIter->first); + Slvs_Entity anEntity = myStorage->getEntity(anAttrIter->second); + if (anEntity.h == SLVS_E_UNKNOWN) { + std::map::iterator aTmpIter = anAttrIter++; + myAttributeMap.erase(aTmpIter); + continue; + } if (aPoint) { - Slvs_Entity anEntity = myStorage->getEntity(anAttrIter->second); double aXYZ[3]; for (int i = 0; i < 3; i++) { Slvs_Param aPar = myStorage->getParameter(anEntity.param[i]); @@ -588,7 +593,6 @@ void SketchSolver_Constraint::refresh() std::shared_ptr aPoint2D = std::dynamic_pointer_cast(anAttrIter->first); if (aPoint2D) { - Slvs_Entity anEntity = myStorage->getEntity(anAttrIter->second); double aXY[2]; for (int i = 0; i < 2; i++) { Slvs_Param aPar = myStorage->getParameter(anEntity.param[i]); @@ -602,13 +606,13 @@ void SketchSolver_Constraint::refresh() AttributeDoublePtr aScalar = std::dynamic_pointer_cast(anAttrIter->first); if (aScalar) { - Slvs_Entity anEntity = myStorage->getEntity(anAttrIter->second); Slvs_Param aPar = myStorage->getParameter(anEntity.param[0]); if (fabs(aScalar->value() - aPar.val) > tolerance) aScalar->setValue(aPar.val); } } } + anAttrIter++; } std::map::iterator aValIter = myValueMap.begin(); -- 2.39.2