]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Avoid instability of test cases.
authorazv <azv@opencascade.com>
Mon, 7 Oct 2019 09:00:38 +0000 (12:00 +0300)
committerazv <azv@opencascade.com>
Mon, 7 Oct 2019 09:01:20 +0000 (12:01 +0300)
src/GeomAPI/GeomAPI_Ellipse2d.cpp
src/SketchPlugin/Test/TestTrimEllipse.py
src/SketchSolver/SketchSolver_ConstraintTangent.cpp

index 464d4b1c4fad884f1741691421a85490039287a8..e10765c7890877ea02ecafd7a9c1c96d80f86b9d 100644 (file)
@@ -136,13 +136,20 @@ static double extrema(IntAna2d_AnaIntersection* theIntersectionAlgo,
     gp_Pnt2d anArrangePoint(theArrangePoint->x(), theArrangePoint->y());
     gp_Pnt2d anInterPnt = theIntersectionAlgo->Point(1).Value();
     aDistance = anArrangePoint.SquareDistance(anInterPnt);
-    // get solution nearest to theArrangePoint
+    int aNbMergedPoints = 1;
+    // get solution nearest to theArrangePoint,
+    // if there are several point near each other, calculate average coordinates
     for (int i = 2; i <= theIntersectionAlgo->NbPoints(); ++i) {
       const IntAna2d_IntPoint& aPnt = theIntersectionAlgo->Point(i);
       double aSqDist = aPnt.Value().SquareDistance(anArrangePoint);
-      if (aSqDist < aDistance) {
+      if (aSqDist - aDistance < -Precision::Confusion() * aDistance) {
         aDistance = aSqDist;
         anInterPnt = aPnt.Value();
+        aNbMergedPoints = 1;
+      } else if (aSqDist - aDistance < Precision::Confusion() * aDistance) {
+        anInterPnt.ChangeCoord() =
+            (anInterPnt.XY() * aNbMergedPoints + aPnt.Value().XY()) / (aNbMergedPoints + 1);
+        ++aNbMergedPoints;
       }
     }
 
@@ -181,9 +188,7 @@ double GeomAPI_Ellipse2d::distance(const std::shared_ptr<GeomAPI_Circ2d>& theCir
 {
   IntAna2d_AnaIntersection anInter(theCircle->impl<gp_Circ2d>(), IntAna2d_Conic(*MY_ELLIPSE));
   Extrema_ExtElC2d anExtema(theCircle->impl<gp_Circ2d>(), *MY_ELLIPSE);
-  GeomPnt2dPtr aCircleStart;
-  theCircle->D0(0.0, aCircleStart);
-  return extrema(&anInter, &anExtema, aCircleStart, thePointOnCircle, thePointOnMe);
+  return extrema(&anInter, &anExtema, firstFocus(), thePointOnCircle, thePointOnMe);
 }
 
 double GeomAPI_Ellipse2d::distance(const std::shared_ptr<GeomAPI_Ellipse2d>& theEllipse,
index f621c2c8c7edc36dd1d955223638bfccba002336..ba3c59dcfe4b367ad1b77c58c6b1a0b115c28c95 100644 (file)
@@ -32,7 +32,7 @@ DOF = 11
 NB_LINES = 3
 NB_ELLIPSES = 1
 NB_ELLIPTIC_ARCS = 0
-NB_COINCIDENCES = 5
+NB_COINCIDENCES = 6
 NB_EQUALS = 0
 
 TOLERANCE = 1.e-6
@@ -72,9 +72,10 @@ SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint()
 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchEllipse_1.result())
 SketchLine_2 = Sketch_1.addLine(-16.85909682653373, 35.30399198463829, 20.9032928583277, -19.27802168426675)
 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
-SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchEllipse_1.result())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchEllipse_1.result())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchEllipse_1.result())
 SketchLine_3 = Sketch_1.addLine(34.69765676551338, 36.08465583643841, 35.0422024535432, -17.96612629290852)
-SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchEllipse_1.result())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchEllipse_1.result())
 model.do()
 
 checkFeaturesQuantity(Sketch_1)
index c54b01e91608855b7f2d3f855fa9e346ddec4c5e..18d95f8ec9d5c533dcaf88caf62f091719155b7b 100644 (file)
@@ -34,6 +34,7 @@
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_Circle.h>
 #include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_ConstraintCoincidenceInternal.h>
 #include <SketchPlugin_ConstraintMiddle.h>
 
 #include <cmath>
@@ -368,6 +369,7 @@ static std::set<AttributePtr> pointsOnFeature(FeaturePtr theFeature)
   for (std::set<AttributePtr>::const_iterator anIt = aRefs.begin(); anIt != aRefs.end(); ++anIt) {
     FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
     if (aRef && (aRef->getKind() == SketchPlugin_ConstraintCoincidence::ID() ||
+                 aRef->getKind() == SketchPlugin_ConstraintCoincidenceInternal::ID() ||
                  aRef->getKind() == SketchPlugin_ConstraintMiddle::ID())) {
       for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
         AttributeRefAttrPtr aRefAttr = aRef->refattr(SketchPlugin_Constraint::ATTRIBUTE(i));