From: azv Date: Tue, 26 Apr 2016 13:43:47 +0000 (+0300) Subject: Fix the problem with DoF (issue #1456). X-Git-Tag: V_2.3.0~102 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d7d6a11867c991926f6982c3c679874c8ebe2131;p=modules%2Fshaper.git Fix the problem with DoF (issue #1456). Incorrect calculation of DoF for several coincident points has been fixed. --- 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(