From: azv Date: Fri, 5 Feb 2016 14:37:40 +0000 (+0300) Subject: Fix failed unit tests X-Git-Tag: V_2.2.0~153 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=021bf7b6174b2a3eb8aaccc56f2c296cb124cfa2;p=modules%2Fshaper.git Fix failed unit tests --- diff --git a/src/GeomAPI/GeomAPI_Circ2d.cpp b/src/GeomAPI/GeomAPI_Circ2d.cpp index a58151409..4ac745864 100644 --- a/src/GeomAPI/GeomAPI_Circ2d.cpp +++ b/src/GeomAPI/GeomAPI_Circ2d.cpp @@ -55,15 +55,29 @@ static gp_Circ2d* newCirc2d(const std::shared_ptr& theFirstPoint, gp_XY aVec12 = aSecondPnt - aFirstPnt; gp_XY aVec23 = aThirdPnt - aSecondPnt; gp_XY aVec31 = aFirstPnt - aThirdPnt; + + // coefficients to calculate center + double aCoeff1, aCoeff2, aCoeff3; + // square of parallelogram double aSquare2 = aVec12.Crossed(aVec23); aSquare2 *= aSquare2 * 2.0; - if (aSquare2 < 1.e-20) - return NULL; - // coefficients to calculate center - double aCoeff1 = aVec23.Dot(aVec23) / aSquare2 * aVec12.Dot(aVec31.Reversed()); - double aCoeff2 = aVec31.Dot(aVec31) / aSquare2 * aVec23.Dot(aVec12.Reversed()); - double aCoeff3 = aVec12.Dot(aVec12) / aSquare2 * aVec31.Dot(aVec23.Reversed()); + if (aSquare2 < 1.e-20) { + // if two points are equal, build a circle on two different points as on diameter + double aSqLen12 = aVec12.SquareModulus(); + double aSqLen23 = aVec23.SquareModulus(); + double aSqLen31 = aVec31.SquareModulus(); + if (aSqLen12 < Precision::SquareConfusion() && + aSqLen23 < Precision::SquareConfusion() && + aSqLen31 < Precision::SquareConfusion()) + return NULL; + aCoeff1 = aCoeff2 = aCoeff3 = 1.0 / 3.0; + } + else { + aCoeff1 = aVec23.Dot(aVec23) / aSquare2 * aVec12.Dot(aVec31.Reversed()); + aCoeff2 = aVec31.Dot(aVec31) / aSquare2 * aVec23.Dot(aVec12.Reversed()); + aCoeff3 = aVec12.Dot(aVec12) / aSquare2 * aVec31.Dot(aVec23.Reversed()); + } // center gp_XY aCenter = aFirstPnt * aCoeff1 + aSecondPnt * aCoeff2 + aThirdPnt * aCoeff3; // radius diff --git a/src/PythonAPI/Test/TestSketcherSetFillet.py b/src/PythonAPI/Test/TestSketcherSetFillet.py index b6e90ea9c..fc5211b36 100644 --- a/src/PythonAPI/Test/TestSketcherSetFillet.py +++ b/src/PythonAPI/Test/TestSketcherSetFillet.py @@ -7,7 +7,7 @@ class SketcherSetFillet(SketcherTestCase): l1 = self.sketch.addLine(0, 0, 0, 1) l2 = self.sketch.addLine(0, 1, 1, 1) self.sketch.setCoincident(l1.endPoint(), l2.startPoint()) - self.sketch.setFillet(l1.result(), l2.result(), 10.0) + self.sketch.setFillet(l1.endPoint(), 10.0) model.do() if __name__ == "__main__": diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index d505350cb..aacdeca1f 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -518,6 +518,8 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) if (theID == CENTER_ID()) { if (!isFeatureValid()) return; + if (aCenterAttr->pnt()->distance(aStartAttr->pnt()) < tolerance) + return; data()->blockSendAttributeUpdated(true); // compute and change the arc end point std::shared_ptr aCircleForArc(