X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestFilletInteracting.py;h=60783ed527bff4b6f0af2ba9c270341a679160df;hb=82874628678a6b4eb234bf5663c7707e25dc1589;hp=58a222b68d0678b63696b366458c774a15b3d37e;hpb=88ccd5939c210bd8e239d1cad8224a893e717b68;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestFilletInteracting.py b/src/SketchPlugin/Test/TestFilletInteracting.py index 58a222b68..60783ed52 100644 --- a/src/SketchPlugin/Test/TestFilletInteracting.py +++ b/src/SketchPlugin/Test/TestFilletInteracting.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 +## + """ TestFilletInteracting.py Unit test of SketchPlugin_Fillet feature. @@ -14,15 +34,15 @@ from salome.shaper import model __updated__ = "2017-03-06" def isArcLineSmooth(theArc, theLine, theTolerance): - 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) return math.fabs(aRadius - aDistance) < theTolerance def isArcArcSmooth(theArc1, theArc2, theTolerance): - 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 @@ -30,21 +50,9 @@ def isArcArcSmooth(theArc1, theArc2, theTolerance): return math.fabs(aDistance - aRadSum) < theTolerance or math.fabs(aDistance - aRadDiff) < theTolerance 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) @@ -58,8 +66,7 @@ class TestFilletInteracting(unittest.TestCase): def tearDown(self): model.end() - # TODO: Revert commented line to check Python dump - #self.assertTrue(model.checkPythonDump()) + self.assertTrue(model.checkPythonDump()) model.reset() @@ -115,7 +122,6 @@ class TestFilletInteracting(unittest.TestCase): return [aFeatureA, aFeatureB] - @unittest.expectedFailure def test_fillet_two_lines(self): """ Test 1. Fillet on two connected lines """ @@ -173,7 +179,6 @@ class TestFilletInteracting(unittest.TestCase): # remove fillet for correct python dump self.myDocument.removeFeature(aFillet.feature()) - @unittest.expectedFailure def test_fillet_arc_line(self): """ Test 3. Fillet on connected arc and line """ @@ -202,7 +207,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_two_arcs(self): """ Test 4. Fillet on two connected arcs """ @@ -231,7 +235,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_with_horizontal_vertical(self): """ Test 5. Fillet on two connected lines in case of Horizontal or Vertical constraints applied """ @@ -267,7 +270,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_with_orthogonal(self): """ Test 6. Fillet on two connected lines in case of Perpendicular constraint applied """ @@ -301,7 +303,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_with_parallel(self): """ Test 7. Fillet on two connected lines in case of Parallel constraint applied """ @@ -338,7 +339,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [4]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [8]) - @unittest.expectedFailure def test_fillet_with_equal_lines(self): """ Test 8. Fillet on two connected lines in case of Equal constraint applied """ @@ -355,7 +355,7 @@ class TestFilletInteracting(unittest.TestCase): model.do() self.checkDOF() self.mySketch.setFillet(aSketchLineA.startPoint()) - self.myDOF += 2 + self.myDOF += 2 # Equal has been removed model.do() self.checkFillet() self.checkDOF() @@ -372,7 +372,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_with_equal_arcs(self): """ Test 9. Fillet on two connected arcs in case of Equal constraint applied """ @@ -389,7 +388,7 @@ class TestFilletInteracting(unittest.TestCase): model.do() self.checkDOF() self.mySketch.setFillet(aSketchArc1.endPoint()) - self.myDOF += 1 + self.myDOF += 2 # Equal has been removed model.do() self.checkFillet() self.checkDOF() @@ -406,7 +405,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_with_length(self): """ Test 10. Fillet on two connected lines in case of Length constraint applied """ @@ -440,7 +438,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_with_radius(self): """ Test 11. Fillet on connected arc and line in case of Radius constraint is applied to arc """ @@ -474,7 +471,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_with_distance(self): """ Test 12. Fillet on two connected lines in case of Distance constraint applied """ @@ -495,7 +491,7 @@ class TestFilletInteracting(unittest.TestCase): model.do() self.checkDOF() self.mySketch.setFillet(aSketchLineA.startPoint()) - self.myDOF += 1 + self.myDOF += 2 # Distance has been removed model.do() self.checkFillet() self.checkDOF() @@ -512,7 +508,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [4]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [8]) - @unittest.expectedFailure def test_fillet_with_fixed_point(self): """ Test 13. Fillet on two connected lines in case of Fixed constraint applied to the fillet point """ @@ -529,7 +524,7 @@ class TestFilletInteracting(unittest.TestCase): model.do() self.checkDOF() self.mySketch.setFillet(aSketchLineA.startPoint()) - self.myDOF += 1 + self.myDOF += 3 # Fixed constraint has been removed model.do() self.checkFillet() self.checkDOF() @@ -546,7 +541,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_with_fixed_line(self): """ Test 14. Fillet on two connected lines in case of Fixed constraint applied to one of lines """ @@ -580,7 +574,6 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3]) model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) - @unittest.expectedFailure def test_fillet_with_angle(self): """ Test 15. Fillet on two connected lines in case of Perpendicular constraint applied """ @@ -615,6 +608,5 @@ class TestFilletInteracting(unittest.TestCase): model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6]) -# TODO: Remove unittest.expectedFailure if the Tangency in PlaneGCS will be updated if __name__ == '__main__': unittest.main()