From 074b1d850036614d4a08999c4bc4e8630db63d2b Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 20 Mar 2015 11:23:12 +0300 Subject: [PATCH] Issue #412: Crash on delete sketch line with constraints Avoid removing from the sketch all points used in coincidence constraint --- src/SketchSolver/SketchSolver_ConstraintGroup.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index f8470401a..237d2dc24 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -1911,19 +1911,26 @@ void SketchSolver_ConstraintGroup::removeConstraint( if (anEntToRemove.find(anEntIter->point[i]) != anEntToRemove.end()) { anEntToRemove.insert(anEntIter->h); for (int j = 0; j < 4; j++) - if (anEntIter->param[j] != 0) + if (anEntIter->point[j] != 0) anEntToRemove.insert(anEntIter->point[j]); break; } } + // Find entities used by remaining constraints and remove them from the list to delete std::vector::const_iterator aConstrIter = myConstraints.begin(); for (; aConstrIter != myConstraints.end(); aConstrIter++) { Slvs_hEntity aEnts[] = { aConstrIter->ptA, aConstrIter->ptB, aConstrIter->entityA, aConstrIter ->entityB }; for (int i = 0; i < 4; i++) - if (aEnts[i] != 0 && anEntToRemove.find(aEnts[i]) != anEntToRemove.end()) + if (aEnts[i] != 0 && anEntToRemove.find(aEnts[i]) != anEntToRemove.end()) { anEntToRemove.erase(aEnts[i]); + // remove from the list all points of current entity + int aEntPos = Search(aEnts[i], myEntities); + for (int j = 0; j < 4; j++) + if (myEntities[aEntPos].point[j] != 0) + anEntToRemove.erase(myEntities[aEntPos].point[j]); + } } if (anEntToRemove.empty()) -- 2.39.2