-## 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<mailto: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
+#
"""
TestCreateArcByThreePoints.py
"""
aLastArc = model.lastSubFeature(theSketch, "SketchArc")
aCenter = geomDataAPI_Point2D(aLastArc.attribute("center_point"))
- verifyPointCoordinates(aCenter, theX, theY)
+ model.assertPoint(aCenter, [theX, theY])
aRadius = aLastArc.real("radius")
assert aRadius.value() == theR, "Wrong radius {0}, expected {1}".format(aRadius.value(), theR)
-def verifyPointCoordinates(thePoint, theX, theY):
- assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.attributeType(), thePoint.x(), thePoint.y(), theX, theY)
-
def verifyPointOnArc(thePoint, theArc):
aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
aDistCP = model.distancePointPoint(aCenter, thePoint)
def verifyTangentArcLine(theArc, theLine):
aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
aRadius = theArc.real("radius").value()
- aDistCL = distancePointLine(aCenter, theLine)
+ aDistCL = model.distancePointLine(aCenter, theLine)
assert math.fabs(aDistCL - aRadius) < TOLERANCE, "Circle and line are 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)
-
#=========================================================================
# Start of test
aSession.finishOperation()
assert (aSketchFeature.numberOfSubs() == 7)
# check the points do not change their positions
-verifyPointCoordinates(aPrevCenter, aPrevCenterXY[0], aPrevCenterXY[1])
-verifyPointCoordinates(aPointCoord, aPointCoodinates[0], aPointCoodinates[1])
-verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
+model.assertPoint(aPrevCenter, aPrevCenterXY)
+model.assertPoint(aPointCoord, aPointCoodinates)
+model.assertPoint(aStartPnt, aLineStart)
# check newly created arc passes through the points
anArc = model.lastSubFeature(aSketchFeature, "SketchArc")
verifyPointOnArc(aPrevCenter, anArc)
aSession.finishOperation()
assert (aSketchFeature.numberOfSubs() == 9)
# check the points do not change their positions
-verifyPointCoordinates(aPrevCenter, aPrevCenterXY[0], aPrevCenterXY[1])
-verifyPointCoordinates(aPointCoord, aPointCoodinates[0], aPointCoodinates[1])
-verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
+model.assertPoint(aPrevCenter, aPrevCenterXY)
+model.assertPoint(aPointCoord, aPointCoodinates)
+model.assertPoint(aStartPnt, aLineStart)
# check sub-features
model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 3)
model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 1)