From: azv Date: Fri, 11 Sep 2015 05:35:53 +0000 (+0300) Subject: Change sorting procedure to avoid "conflicting constraints" message on Linux (issue... X-Git-Tag: V_1.4.0_beta4~30 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=96c4ea302ca42050e2461ce940c13601c3ee6e43;p=modules%2Fshaper.git Change sorting procedure to avoid "conflicting constraints" message on Linux (issue #893) --- diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index ecd78c9cd..5bce44595 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -762,13 +762,21 @@ static double featureToVal(FeaturePtr theFeature) return 1.0; // features (arc, circle, line, point) const std::string& anID = aConstraint->getKind(); - if (anID == SketchPlugin_ConstraintCoincidence::ID()) - return 2.0; + if (anID == SketchPlugin_ConstraintCoincidence::ID()) { + AttributeRefAttrPtr anAttrA = std::dynamic_pointer_cast( + aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A())); + AttributeRefAttrPtr anAttrB = std::dynamic_pointer_cast( + aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B())); + if (anAttrA && anAttrB && (anAttrA->isObject() || anAttrB->isObject())) + return 2.0; // point-on-line and point-on-circle should go before points coincidence constraint + return 2.5; + } if (anID == SketchPlugin_ConstraintDistance::ID() || anID == SketchPlugin_ConstraintLength::ID() || - anID == SketchPlugin_ConstraintRadius::ID() || - anID == SketchPlugin_ConstraintAngle::ID()) + anID == SketchPlugin_ConstraintRadius::ID()) return 3.0; + if (anID == SketchPlugin_ConstraintAngle::ID()) + return 3.5; if (anID == SketchPlugin_ConstraintHorizontal::ID() || anID == SketchPlugin_ConstraintVertical::ID() || anID == SketchPlugin_ConstraintParallel::ID() || @@ -789,7 +797,7 @@ static double featureToVal(FeaturePtr theFeature) return 5.5; } -static bool operator< (FeaturePtr theFeature1, FeaturePtr theFeature2) +static bool isLess(FeaturePtr theFeature1, FeaturePtr theFeature2) { return featureToVal(theFeature1) < featureToVal(theFeature2); } @@ -814,7 +822,7 @@ std::list SketchSolver_Group::selectApplicableFeatures(const std::se // Find the place where to insert a feature for (aResIt = aResult.begin(); aResIt != aResult.end(); ++aResIt) - if (aFeature < *aResIt) + if (isLess(aFeature, *aResIt)) break; aResult.insert(aResIt, aFeature); }