From 908f8bf97d07537a33c06349e86ea6a6aa4d7323 Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 29 Apr 2016 16:14:51 +0300 Subject: [PATCH] Avoid incorrect fixing of a point on line after the external point removed (issue #1389) --- src/SketchSolver/SketchSolver_Manager.cpp | 4 ++-- .../SolveSpaceSolver_Storage.cpp | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index aef46368a..dec3ead7e 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -547,8 +547,8 @@ void SketchSolver_Manager::degreesOfFreedom() aDoF -= 2; // attribute is a point else { FeaturePtr anAttr = ModelAPI_Feature::feature(aRefAttr->object()); - assert(anAttr); - aDoF -= aDoFDelta[anAttr->getKind()]; + if (anAttr) + aDoF -= aDoFDelta[anAttr->getKind()]; } } else if (aFeature->getKind() == SketchPlugin_ConstraintMirror::ID() || diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index e7b72775d..8226bebd5 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -928,13 +928,23 @@ bool SolveSpaceSolver_Storage::removeCoincidence(ConstraintWrapperPtr theConstra aConstrIt->first->attribute(SketchPlugin_Constraint::ENTITY_A())); AttributeRefAttrPtr aRefAttrB = std::dynamic_pointer_cast( aConstrIt->first->attribute(SketchPlugin_Constraint::ENTITY_B())); - if (!aRefAttrA || !aRefAttrB || aRefAttrA->isObject() || aRefAttrB->isObject()) - continue; + AttributePtr anAttrA, anAttrB; + if (aConstrIt->first->data()->isValid()) { + if (!aRefAttrA || !aRefAttrB || aRefAttrA->isObject() || aRefAttrB->isObject()) + continue; + anAttrA = aRefAttrA->attr(); + anAttrB = aRefAttrB->attr(); + } else { + // obtain attributes from the constraint wrapper + ConstraintWrapperPtr aWrapper = aConstrIt->second.front(); + anAttrA = aWrapper->entities().front()->baseAttribute(); + anAttrB = aWrapper->entities().back()->baseAttribute(); + } std::map::iterator - aFound = myAttributeMap.find(aRefAttrA->attr()); + aFound = myAttributeMap.find(anAttrA); if (aFound != myAttributeMap.end()) aNotCoinc.erase(aFound->second); - aFound = myAttributeMap.find(aRefAttrB->attr()); + aFound = myAttributeMap.find(anAttrB); if (aFound != myAttributeMap.end()) aNotCoinc.erase(aFound->second); } -- 2.39.2