X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestCreateArcByTangentEdge.py;h=2663540d5ecc77386a7688f6d0ac33e0bb4d47b8;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=6f296a03d91c5d046a78265137e49f62bbc9d452;hpb=5c59bf6725e7e4855b5ca956475d705e2d5b014c;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestCreateArcByTangentEdge.py b/src/SketchPlugin/Test/TestCreateArcByTangentEdge.py index 6f296a03d..2663540d5 100644 --- a/src/SketchPlugin/Test/TestCreateArcByTangentEdge.py +++ b/src/SketchPlugin/Test/TestCreateArcByTangentEdge.py @@ -1,22 +1,21 @@ -## Copyright (C) 2014-2017 CEA/DEN, EDF R&D -## -## This library is free software; you can redistribute it and/or -## modify it under the terms of the GNU Lesser General Public -## License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## -## This library is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## Lesser General Public License for more details. -## -## You should have received a copy of the GNU Lesser General Public -## License along with this library; if not, write to the Free Software -## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -## -## See http:##www.salome-platform.org/ or -## email : webmaster.salome@opencascade.com -## +# Copyright (C) 2014-2023 CEA, EDF +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# """ TestCreateArc.py @@ -52,19 +51,7 @@ def verifyLastArc(theSketch, theCenter, theStart, theEnd): subroutine to verify position of last arc in the sketch """ aLastArc = model.lastSubFeature(theSketch, "SketchArc") - aCenterPnt = geomDataAPI_Point2D(aLastArc.attribute("center_point")) - aStartPnt = geomDataAPI_Point2D(aLastArc.attribute("start_point")) - aEndPnt = geomDataAPI_Point2D(aLastArc.attribute("end_point")) - if len(theCenter): - verifyPointCoordinates(aCenterPnt, theCenter[0], theCenter[1]) - if len(theStart): - verifyPointCoordinates(aStartPnt, theStart[0], theStart[1]) - if len(theEnd): - verifyPointCoordinates(aEndPnt, theEnd[0], theEnd[1]) - model.assertSketchArc(aLastArc) - -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) + model.assertArc(aLastArc, theCenter, theStart, theEnd) def verifyTangent(theFeature1, theFeature2): anArcs = [] @@ -99,19 +86,11 @@ def verifyArcLineTangent(theArc, theLine): aStart = geomDataAPI_Point2D(theArc.attribute("start_point")) aRadius = model.distancePointPoint(aStart, aCenter) - aDistCL = distancePointLine(aCenter, theLine) + aDistCL = model.distancePointLine(aCenter, theLine) assert math.fabs(aDistCL - aRadius) < TOLERANCE, "Arc and line do not tangent" -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) - def verifyPointOnLine(thePoint, theLine): - aDistance = distancePointLine(thePoint, theLine) + aDistance = model.distancePointLine(thePoint, theLine) assert aDistance < TOLERANCE, "Point is not on Line, distance: {0}".format(aDistance)