Salome HOME
Issue #2095: Fillet with mirror produces a problem in solver
authorazv <azv@opencascade.com>
Wed, 5 Apr 2017 10:50:10 +0000 (13:50 +0300)
committerazv <azv@opencascade.com>
Wed, 5 Apr 2017 10:50:38 +0000 (13:50 +0300)
- Improve update of mirrored entities
- Adjust stack depth
- Unit test for the issue

src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/Test/Test2095.py [new file with mode: 0644]
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/SketchSolver_Group.cpp

index 75fe9e99392841d1f5cad66aefb88dcaacc5b1c8..d9aa0c5dadc288890e78120859c019649ed80c3c 100644 (file)
@@ -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 (file)
index 0000000..bed556c
--- /dev/null
@@ -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()
index 96235587d0bd0f2b4bd96d4c01f8bcba4131ce79..b68c6aae5197049fdbc626f9a3e7ee1ab37b7a75 100644 (file)
@@ -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;
 }
 
index 4782f97050af090cb6a7f2f535f8200901e2f53b..0664550a29441c7802a3981dc0b998dc190369b6 100644 (file)
@@ -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 <iostream>
 // ============================================================================
 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())