From d7d6a11867c991926f6982c3c679874c8ebe2131 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 26 Apr 2016 16:43:47 +0300 Subject: [PATCH] Fix the problem with DoF (issue #1456). Incorrect calculation of DoF for several coincident points has been fixed. --- src/SketchSolver/SketchSolver_Manager.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index b957601b0..7b6bc263b 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -499,6 +499,7 @@ void SketchSolver_Manager::degreesOfFreedom() if (aSketchDoF.find(aSketch) != aSketchDoF.end() || aSketchDoF[aSketch] < 0) continue; + std::set aCoincidentPoints; int aDoF = 0; int aNbSubs = aSketch->numberOfSubs(); for (int i = 0; i < aNbSubs; ++i) { @@ -512,19 +513,32 @@ void SketchSolver_Manager::degreesOfFreedom() // DoF delta in specific cases if (aFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { + AttributePtr aCoincPoint[2] = {AttributePtr(), AttributePtr()}; for (int j = 0; j < 2; ++j) { AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast( aFeature->attribute(SketchPlugin_Constraint::ATTRIBUTE(j))); if (!aRefAttr) continue; bool isPoint = !aRefAttr->isObject(); - if (!isPoint) { + if (isPoint) + aCoincPoint[j] = aRefAttr->attr(); + else { FeaturePtr anAttr = ModelAPI_Feature::feature(aRefAttr->object()); isPoint = anAttr && anAttr->getKind() == SketchPlugin_Point::ID(); + if (isPoint) + aCoincPoint[j] = anAttr->attribute(SketchPlugin_Point::COORD_ID()); } - if (isPoint) - aDoF -= 1; } + if (aCoincPoint[0] && aCoincPoint[1]) { + // point-point coincidence + if (aCoincidentPoints.find(aCoincPoint[0]) == aCoincidentPoints.end() || + aCoincidentPoints.find(aCoincPoint[1]) == aCoincidentPoints.end()) + aDoF -= 2; + } else + aDoF -= 1; + for (int j = 0; j < 2; ++j) + if (aCoincPoint[j]) + aCoincidentPoints.insert(aCoincPoint[j]); } else if (aFeature->getKind() == SketchPlugin_ConstraintRigid::ID()) { AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast( -- 2.39.2