From: azv Date: Thu, 6 Apr 2017 11:58:02 +0000 (+0300) Subject: Update Arc unit test X-Git-Tag: V_2.7.0~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f483d3e94d5374e3ac8c845fec76d4e8770cc4d6;p=modules%2Fshaper.git Update Arc unit test --- diff --git a/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py b/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py index 4f01b367f..4f05ecf69 100644 --- a/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py +++ b/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py @@ -46,6 +46,31 @@ def verifyLastArc(theSketch, theCenter, theStart, theEnd): def verifyPointCoordinates(thePoint, theX, theY): assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.id(), thePoint.x(), thePoint.y(), theX, theY) +def verifyPointOnLine(thePoint, theLine): + aDistance = distancePointLine(thePoint, theLine) + assert aDistance < TOLERANCE, "Point is not on Line, distance: {0}".format(aDistance) + +def verifyPointOnCircle(thePoint, theCircular): + if theCircular.getKind() == "SketchArc": + aCenterPoint = geomDataAPI_Point2D(theCircular.attribute("center_point")) + aStartPoint = geomDataAPI_Point2D(theCircular.attribute("start_point")) + aRadius = model.distancePointPoint(aCenterPoint, aStartPoint) + elif theCircular.getKind() == "SketchCircle": + aCenterPoint = geomDataAPI_Point2D(theCircular.attribute("circle_center")) + aRadius = theCircular.real("circle_radius").value() + else: + return + assert math.fabs(model.distancePointPoint(aCenterPoint, thePoint) - aRadius) < TOLERANCE + + +def distancePointLine(thePoint, theLine): + aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")).pnt().xy() + aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")).pnt().xy() + aLineDir = aLineEnd.decreased(aLineStart) + aLineLen = aLineEnd.distance(aLineStart) + aPntDir = thePoint.pnt().xy().decreased(aLineStart) + return math.fabs(aPntDir.cross(aLineDir) / aLineLen) + aSession = ModelAPI_Session.get() aDocument = aSession.moduleDocument()