From: azv Date: Wed, 5 Apr 2017 10:50:10 +0000 (+0300) Subject: Issue #2095: Fillet with mirror produces a problem in solver X-Git-Tag: V_2.7.0~68 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cfe4bcc5b3ebf08f0f4f36a0df4067728f1a080a;p=modules%2Fshaper.git Issue #2095: Fillet with mirror produces a problem in solver - Improve update of mirrored entities - Adjust stack depth - Unit test for the issue --- diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 75fe9e993..d9aa0c5da 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -164,6 +164,7 @@ ADD_UNIT_TESTS(TestSketchPointLine.py Test1924.py Test1966.py Test1967.py + Test2095.py TestTrimArc01.py TestTrimArc02.py TestTrimArc03.py diff --git a/src/SketchPlugin/Test/Test2095.py b/src/SketchPlugin/Test/Test2095.py new file mode 100644 index 000000000..bed556cbc --- /dev/null +++ b/src/SketchPlugin/Test/Test2095.py @@ -0,0 +1,29 @@ +from SketchAPI import * +from salome.shaper import model + +lineStart = [26, 53] +lineEnd = [71, 30] + +model.begin() +partSet = model.moduleDocument() +Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(lineStart[0], lineStart[1], lineEnd[0], lineEnd[1]) +SketchLine_2 = Sketch_1.addLine(model.selection("EDGE", "OX")) +SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), [SketchLine_1.result()]) +[SketchLine_3] = SketchConstraintMirror_1.mirrored() + +SketchLine_4 = Sketch_1.addLine(lineEnd[0], lineEnd[1], lineEnd[0], -lineEnd[1]) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_3).endPoint(), SketchLine_4.endPoint()) + +Sketch_1.setFillet(SketchLine_1.endPoint()) +model.do() + +assert(SketchLine_1.startPoint().x() == SketchAPI_Line(SketchLine_3).startPoint().x()) +assert(SketchLine_1.startPoint().y() == -SketchAPI_Line(SketchLine_3).startPoint().y()) +assert(SketchLine_1.endPoint().x() == SketchAPI_Line(SketchLine_3).endPoint().x()) +assert(SketchLine_1.endPoint().y() == -SketchAPI_Line(SketchLine_3).endPoint().y()) +assert(SketchLine_1.endPoint().x() != lineEnd[0]) +assert(SketchLine_1.endPoint().y() != lineEnd[1]) + +model.end() diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 96235587d..b68c6aae5 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -244,20 +244,19 @@ bool PlaneGCSSolver_Storage::update(AttributePtr theAttribute, bool theForce) } EntityWrapperPtr aRelated = entity(anAttribute); + FeaturePtr aFeature = ModelAPI_Feature::feature(anAttribute->owner()); if (!aRelated) { // Attribute does not exist, create it. // First of all check if the parent feature exists. If not, add it. - FeaturePtr aFeature = ModelAPI_Feature::feature(anAttribute->owner()); if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end()) return update(aFeature, theForce); // theAttribute has been processed while adding feature - -//// PlaneGCSSolver_AttributeBuilder aBuilder(this); -//// aRelated = createAttribute(anAttribute, &aBuilder); return aRelated.get() != 0; } bool isUpdated = updateValues(anAttribute, aRelated); - if (isUpdated) + if (isUpdated) { setNeedToResolve(true); + notify(aFeature); + } return isUpdated; } diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 4782f9705..0664550a2 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -141,12 +141,14 @@ bool SketchSolver_Group::moveFeature(FeaturePtr theFeature) // Function: resolveConstraints // Class: SketchSolver_Group // Purpose: solve the set of constraints for the current group +#include // ============================================================================ bool SketchSolver_Group::resolveConstraints() { - static const int MAX_STACK_SIZE = 3; + static const int MAX_STACK_SIZE = 5; // check the "Multi" constraints do not drop sketch into infinite loop if (myMultiConstraintUpdateStack > MAX_STACK_SIZE) { + myMultiConstraintUpdateStack = 0; myPrevResult = PlaneGCSSolver_Solver::STATUS_FAILED; // generate error message due to loop update of the sketch getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR()) @@ -163,7 +165,7 @@ bool SketchSolver_Group::resolveConstraints() PlaneGCSSolver_Solver::SolveStatus aResult = PlaneGCSSolver_Solver::STATUS_OK; try { - if (!isGroupEmpty && myMultiConstraintUpdateStack <= 1) + if (!isGroupEmpty) aResult = mySketchSolver->solve(); } catch (...) { getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())