X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestConstraintDistance.py;h=46ce2e4d1cba0c4bf6125b3f467242c37fda21dd;hb=82874628678a6b4eb234bf5663c7707e25dc1589;hp=b776b267b3ec22581c21622c3b4c5effdacb0c8b;hpb=5c59bf6725e7e4855b5ca956475d705e2d5b014c;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestConstraintDistance.py b/src/SketchPlugin/Test/TestConstraintDistance.py index b776b267b..46ce2e4d1 100644 --- a/src/SketchPlugin/Test/TestConstraintDistance.py +++ b/src/SketchPlugin/Test/TestConstraintDistance.py @@ -51,23 +51,6 @@ from salome.shaper import model __updated__ = "2014-10-28" -def distancePointLine(point, line): - """ - subroutine to calculate distance between point and line - result of calculated distance is has 10**-5 precision - """ - aStartPoint = geomDataAPI_Point2D(line.attribute("StartPoint")) - aEndPoint = geomDataAPI_Point2D(line.attribute("EndPoint")) - # orthogonal direction - aDirX = -(aEndPoint.y() - aStartPoint.y()) - aDirY = (aEndPoint.x() - aStartPoint.x()) - aLen = math.sqrt(aDirX**2 + aDirY**2) - aDirX = aDirX / aLen - aDirY = aDirY / aLen - aVecX = point.x() - aStartPoint.x() - aVecY = point.y() - aStartPoint.y() - return round(math.fabs(aVecX * aDirX + aVecY * aDirY), 5) - aSession = ModelAPI_Session.get() aDocument = aSession.moduleDocument() #========================================================================= @@ -163,7 +146,7 @@ assert (model.dof(aSketchFeature) == 6) # Add distance between point and line #========================================================================= PT_LINE_DIST = 50. -aDist = distancePointLine(aSketchPointCoords, aSketchLine) +aDist = model.distancePointLine(aSketchPointCoords, aSketchLine) aSession.startOperation() aConstraint = aSketchFeature.addFeature("SketchConstraintDistance") aDistance = aConstraint.real("ConstraintValue") @@ -194,7 +177,7 @@ assert (model.dof(aSketchFeature) == 5) aSession.startOperation() aDistance.setValue(PT_LINE_DIST) aSession.finishOperation() -assert (math.fabs(distancePointLine(aSketchPointCoords, aSketchLine) - PT_LINE_DIST) < 1.e-10) +assert (math.fabs(model.distancePointLine(aSketchPointCoords, aSketchLine) - PT_LINE_DIST) < 1.e-10) assert (model.dof(aSketchFeature) == 5) #========================================================================= # Set distance between line boundaries