X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestFilletInteracting.py;h=5026f5385824b3271a90affc8d1562f26c428a74;hb=28038c772769f15a06376fa01d55529e7daa1aa9;hp=04160ace6312d62e5c7a2d6c9a121c93fa864b94;hpb=5a67842979db286af5bb5015fe413d8b06c6587e;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestFilletInteracting.py b/src/SketchPlugin/Test/TestFilletInteracting.py index 04160ace6..5026f5385 100644 --- a/src/SketchPlugin/Test/TestFilletInteracting.py +++ b/src/SketchPlugin/Test/TestFilletInteracting.py @@ -27,6 +27,7 @@ from GeomAPI import * from GeomDataAPI import * from ModelAPI import * +from SketchAPI import * import math import unittest from salome.shaper import model @@ -35,7 +36,7 @@ __updated__ = "2017-03-06" def isArcLineSmooth(theArc, theLine, theTolerance): aCenter = geomDataAPI_Point2D(theArc.attribute("center_point")) - aDistance = distancePointLine(aCenter, theLine) + aDistance = model.distancePointLine(aCenter, theLine) aRadius = arcRadius(theArc) return math.fabs(aRadius - aDistance) < theTolerance @@ -54,15 +55,6 @@ def arcRadius(theArc): aStart = geomDataAPI_Point2D(theArc.attribute("start_point")) return model.distancePointPoint(aCenter, aStart) -def distancePointLine(thePoint, theLine): - aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")) - aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")) - aLength = model.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 - class TestFilletInteracting(unittest.TestCase): @@ -181,9 +173,10 @@ class TestFilletInteracting(unittest.TestCase): self.checkNbFeatures("SketchConstraintTangent", 0) # no tangencies should not be created self.checkNbFeatures("SketchFillet", 1) # fillet feature should still exist. it should be wrong - model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0]) - model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [2]) - model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [4]) + # sketch is invalid, so, no results at all + model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, []) + model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, []) + model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, []) # remove fillet for correct python dump self.myDocument.removeFeature(aFillet.feature()) @@ -430,7 +423,7 @@ class TestFilletInteracting(unittest.TestCase): model.do() self.checkDOF() self.mySketch.setFillet(aSketchLineA.startPoint()) - self.myDOF += 2 + self.myDOF += 1 model.do() self.checkFillet() self.checkDOF() @@ -438,9 +431,10 @@ class TestFilletInteracting(unittest.TestCase): self.collectFeatures() self.checkNbFeatures("SketchLine", 2) self.checkNbFeatures("SketchArc", 1) - self.checkNbFeatures("SketchConstraintCoincidence", 2) + self.checkNbFeatures("SketchConstraintCoincidence", 4) # Additionally 2 coincidences for apex with fillet objects self.checkNbFeatures("SketchConstraintTangent", 2) self.checkNbFeatures("SketchConstraintLength", 0) # Length constraint expected to be removed + self.checkNbFeatures("SketchConstraintDistance", 1) # Distance constraint should appear instead of Length self.checkNbFeatures("SketchFillet", 0) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0]) @@ -483,24 +477,40 @@ class TestFilletInteracting(unittest.TestCase): def test_fillet_with_distance(self): """ Test 12. Fillet on two connected lines in case of Distance constraint applied """ - aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.) - aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.) - self.myDOF += 8 + aSketchLineA = self.mySketch.addLine(20, 20, 70, 20) + aSketchLineB = self.mySketch.addLine(70, 20, 70, 53.16624790355412) + aSketchLineC = self.mySketch.addLine(70, 53.16624790355412, 20, 20) + self.myDOF += 12 + model.do() self.checkDOF() - self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint()) - self.myDOF -= 2 + # coincidences + self.mySketch.setCoincident(aSketchLineA.endPoint(), aSketchLineB.startPoint()) + self.mySketch.setCoincident(aSketchLineB.endPoint(), aSketchLineC.startPoint()) + self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineC.endPoint()) + self.myDOF -= 6 model.do() self.checkDOF() - # third line to apply Distance constraints - aSketchLineC = self.mySketch.addLine(10., 0., 20., 5.) - self.myDOF += 4 - self.mySketch.setDistance(aSketchLineB.startPoint(), aSketchLineC.result(), 10.) - self.mySketch.setDistance(aSketchLineB.endPoint(), aSketchLineC.result(), 5.) + # other constraints + self.mySketch.setHorizontal(aSketchLineA.result()) + self.mySketch.setVertical(aSketchLineB.result()) self.myDOF -= 2 model.do() self.checkDOF() + # construction point + aProjection = self.mySketch.addProjection(model.selection("VERTEX", "Origin"), False) + aSketchPoint = SketchAPI_Point(aProjection.createdFeature()) + model.do() + # distances + self.mySketch.setLength(aSketchLineA.result(), 50) + self.mySketch.setDistance(aSketchLineA.startPoint(), aSketchLineC.startPoint(), 60, True) + self.mySketch.setHorizontalDistance(aSketchPoint.coordinates(), aSketchLineA.startPoint(), 20) + self.mySketch.setVerticalDistance(aSketchPoint.coordinates(), aSketchLineC.endPoint(), 20) + self.myDOF -= 4 + model.do() + self.checkDOF() + self.mySketch.setFillet(aSketchLineA.startPoint()) - self.myDOF += 2 # Distance has been removed + self.myDOF += 1 model.do() self.checkFillet() self.checkDOF() @@ -508,9 +518,14 @@ class TestFilletInteracting(unittest.TestCase): self.collectFeatures() self.checkNbFeatures("SketchLine", 3) self.checkNbFeatures("SketchArc", 1) - self.checkNbFeatures("SketchConstraintCoincidence", 2) + self.checkNbFeatures("SketchConstraintCoincidence", 6) # Additionally 2 coincidences for apex with fillet objects + self.checkNbFeatures("SketchConstraintHorizontal", 1) + self.checkNbFeatures("SketchConstraintVertical", 1) self.checkNbFeatures("SketchConstraintTangent", 2) - self.checkNbFeatures("SketchConstraintDistance", 1) # only one Distance should be left + self.checkNbFeatures("SketchConstraintLength", 0) # Length translated to Distance + self.checkNbFeatures("SketchConstraintDistance", 2) # Length translated to Distance + self.checkNbFeatures("SketchConstraintDistanceHorizontal", 1) + self.checkNbFeatures("SketchConstraintDistanceVertical", 1) self.checkNbFeatures("SketchFillet", 0) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])