From 8014d0ac5139d9289e7dabb514ecaba8f263db0c Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 2 Sep 2015 17:05:33 +0300 Subject: [PATCH] Application crashes during sketching (issue #872) Multi-coincidence with external point was implemented --- .../SketchSolver_ConstraintCoincidence.cpp | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp index 0e6ee7490..205c744e9 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp @@ -2,6 +2,8 @@ #include #include +#include + #include void SketchSolver_ConstraintCoincidence::getAttributes( @@ -169,9 +171,12 @@ void SketchSolver_ConstraintCoincidence::addConstraint(ConstraintPtr theConstrai Slvs_hEntity anEntity = SLVS_E_UNKNOWN; int anEntType; for (; anIter != anAttrList.end(); anIter++) { + Slvs_hEntity aPointID = SLVS_E_UNKNOWN; AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*anIter); if (!aRefAttr) continue; + + AttributePtr aPointAttr; if (aRefAttr->isObject()) { FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object()); std::map::const_iterator aFeatFound = @@ -185,21 +190,29 @@ void SketchSolver_ConstraintCoincidence::addConstraint(ConstraintPtr theConstrai else myFeatureMap[aFeature] = anEntity; } + // If the feature is a point, add it to the list of coincident points + if (aFeature->getKind() == SketchPlugin_Point::ID()) { + aPointID = anEntity; + anEntity = SLVS_E_UNKNOWN; + aPointAttr = aFeature->attribute(SketchPlugin_Point::COORD_ID()); + } } else { - Slvs_hEntity anEntID = SLVS_E_UNKNOWN; + aPointAttr = aRefAttr->attr(); std::map::const_iterator anAttrFound = - myAttributeMap.find(aRefAttr->attr()); + myAttributeMap.find(aPointAttr); if (anAttrFound != myAttributeMap.end()) - anEntID = anAttrFound->second; + aPointID = anAttrFound->second; else { - anEntID = myGroup->getAttributeId(aRefAttr->attr()); - if (anEntID == SLVS_E_UNKNOWN) - anEntID = changeEntity(aRefAttr->attr(), anEntType); - else - myAttributeMap[aRefAttr->attr()] = anEntID; + aPointID = myGroup->getAttributeId(aPointAttr); + if (aPointID == SLVS_E_UNKNOWN) + aPointID = changeEntity(aPointAttr, anEntType); } - aPoints.push_back(anEntID); - myCoincidentPoints.insert(aRefAttr->attr()); + } + + if (aPointAttr) { // the point is found + aPoints.push_back(aPointID); + myCoincidentPoints.insert(aPointAttr); + myAttributeMap[aPointAttr] = aPointID; } } -- 2.39.2