X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestFillet.py;h=e2535877587a4d0b1b0e3bde273957678be10011;hb=964cad2613a9a40164fcdac4fc62c73a65244465;hp=59f353cb8f1e6c792f0216a3aa6ce315a2980190;hpb=fe3678a85238df2b57ea18b341003ebef176e287;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestFillet.py b/src/SketchPlugin/Test/TestFillet.py index 59f353cb8..e25358775 100644 --- a/src/SketchPlugin/Test/TestFillet.py +++ b/src/SketchPlugin/Test/TestFillet.py @@ -1,3 +1,23 @@ +## 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 +## + """ TestFillet.py Unit test of SketchPlugin_Fillet class @@ -5,7 +25,6 @@ SketchPlugin_Fillet static const std::string MY_CONSTRAINT_FILLET_ID("SketchFillet"); data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId()); - data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttrList::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefAttrList::typeId()); @@ -75,9 +94,9 @@ def createSketch2(theSketch): allFeatures.append(aSketchLine) # Arc aSketchArc = theSketch.addFeature("SketchArc") - aStartPoint2 = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint")) - aEndPoint2 = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint")) - aCenterPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter")) + aStartPoint2 = geomDataAPI_Point2D(aSketchArc.attribute("start_point")) + aEndPoint2 = geomDataAPI_Point2D(aSketchArc.attribute("end_point")) + aCenterPoint = geomDataAPI_Point2D(aSketchArc.attribute("center_point")) aCenterPoint.setValue(20., 10.) aStartPoint2.setValue(10., 10.) aEndPoint2.setValue(20., 0.) @@ -104,15 +123,15 @@ def checkSmoothness(theSketch): checkArcLineSmoothness(aConnectedFeatures[1], aConnectedFeatures[0]) def checkArcLineSmoothness(theArc, theLine): - aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter")) - aDistance = distancePointLine(aCenter, theLine) + aCenter = geomDataAPI_Point2D(theArc.attribute("center_point")) + aDistance = model.distancePointLine(aCenter, theLine) aRadius = arcRadius(theArc) assert(math.fabs(aRadius - aDistance) < TOLERANCE) def checkArcArcSmoothness(theArc1, theArc2): - aCenter1 = geomDataAPI_Point2D(theArc1.attribute("ArcCenter")) - aCenter2 = geomDataAPI_Point2D(theArc2.attribute("ArcCenter")) - aDistance = distancePointPoint(aCenter1, aCenter2) + aCenter1 = geomDataAPI_Point2D(theArc1.attribute("center_point")) + aCenter2 = geomDataAPI_Point2D(theArc2.attribute("center_point")) + aDistance = model.distancePointPoint(aCenter1, aCenter2) aRadius1 = arcRadius(theArc1) aRadius2 = arcRadius(theArc2) aRadSum = aRadius1 + aRadius2 @@ -138,22 +157,9 @@ def connectedFeatures(theCoincidence): return [aFeatureA, aFeatureB] def arcRadius(theArc): - aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter")) - aStart = geomDataAPI_Point2D(theArc.attribute("ArcStartPoint")) - return distancePointPoint(aCenter, aStart) - -def distancePointPoint(thePoint1, thePoint2): - return math.hypot(thePoint1.x() - thePoint2.x(), thePoint1.y() - thePoint2.y()) - -def distancePointLine(thePoint, theLine): - aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")) - aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")) - aLength = distancePointPoint(aLineStart, aLineEnd) - - aDir1x, aDir1y = aLineEnd.x() - aLineStart.x(), aLineEnd.y() - aLineStart.y() - aDir2x, aDir2y = thePoint.x() - aLineStart.x(), thePoint.y() - aLineStart.y() - aCross = aDir1x * aDir2y - aDir1y * aDir2x - return math.fabs(aCross) / aLength + aCenter = geomDataAPI_Point2D(theArc.attribute("center_point")) + aStart = geomDataAPI_Point2D(theArc.attribute("start_point")) + return model.distancePointPoint(aCenter, aStart) #=========================================================================