X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestConstraintDistanceBehavior.py;h=720255968580df63b6e50d337e6968a0b8437dfd;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=269d4acfa7264d601f63941a182b894a80265c3c;hpb=dc7d4d86b58b81684abc9b5a2be8ec30f210c2da;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestConstraintDistanceBehavior.py b/src/SketchPlugin/Test/TestConstraintDistanceBehavior.py index 269d4acfa..720255968 100644 --- a/src/SketchPlugin/Test/TestConstraintDistanceBehavior.py +++ b/src/SketchPlugin/Test/TestConstraintDistanceBehavior.py @@ -1,22 +1,21 @@ -## Copyright (C) 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 -## +# Copyright (C) 2017-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 +# from salome.shaper import model from SketchAPI import * @@ -32,6 +31,7 @@ DistanceParam = model.addParameter(Part_1_doc, "distance", "10.") Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchRectangle_1 = Sketch_1.addRectangle(20., 20., 70., 50.) [SketchLine_1, SketchLine_2, SketchLine_3, SketchLine_4] = SketchRectangle_1.lines() +Sketch_1.setVertical(SketchLine_4.result()) firstPoint = SketchAPI_Line(SketchLine_2).startPoint() secondPoint = SketchAPI_Line(SketchLine_3).endPoint() model.do() @@ -45,7 +45,7 @@ SketchConstraintDistanceHorizontal_1.feature().real("ConstraintValue").setText(D model.do() # changing the parameter -for param in range(-30, 31, 2): +for param in range(11, 31, 2): if param == 0: continue DistanceParam.setValue(param) @@ -69,7 +69,7 @@ SketchConstraintDistanceVertical_1.feature().real("ConstraintValue").setText(Dis model.do() # changing the parameter -for param in range(-30, 31, 2): +for param in range(11, 31, 2): if param == 0: continue DistanceParam.setValue(param) @@ -92,11 +92,13 @@ SketchConstraintDistance_1 = Sketch_1.setDistance(firstPoint, secondPoint, "dist model.do() # changing the parameter -for param in range(-30, 31, 2): +for param in range(11, 31, 2): DistanceParam.setValue(param) model.do() - if param <= 0: + if param < 0: assert SketchConstraintDistance_1.feature().error() != '', "ERROR: Sketch should not be valid due to negative distance value" + elif param == 0: # constraint is valid, but lead to degenerated geometry + assert Sketch_1.feature().error() != '', "ERROR: Sketch should not be valid due to negative distance value" else: dist = model.distancePointPoint(firstPoint, secondPoint) assert math.fabs(dist - math.fabs(param)) < TOLERANCE, "Incorrect distance {}, expected {}".format(dist, math.fabs(param)) @@ -106,3 +108,4 @@ model.testNbSubFeatures(Sketch_1, "SketchConstraintDistance", 1) # leave distance constraint alive model.end() +