X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestRectangle.py;h=56cf14ff46b3f3860a26af55b5e3a073d2574897;hb=241b1234365e3f65b9b84c7c8eccf072be54b68c;hp=cbb9b3cc7d02bad28ceddec7d1334d39f3a8f606;hpb=7074394f8f08413d885f63be01df6bd5007b868c;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestRectangle.py b/src/SketchPlugin/Test/TestRectangle.py index cbb9b3cc7..56cf14ff4 100644 --- a/src/SketchPlugin/Test/TestRectangle.py +++ b/src/SketchPlugin/Test/TestRectangle.py @@ -1,26 +1,25 @@ -## 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 -## +# Copyright (C) 2014-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 +# """ TestRectangle.py - Unit test of SketchPlugin_Ractangle class + Unit test of SketchPlugin_Rectangle class """ from GeomDataAPI import * @@ -71,6 +70,7 @@ aSession.finishOperation() #========================================================================= aSession.startOperation() aRectangle = aSketchFeature.addFeature("SketchRectangle") +aRectangle.string("RectangleType").setValue("RectangleTypeByCorners") aStartCorner = geomDataAPI_Point2D(aRectangle.attribute("RectStartPoint")) aEndCorner = geomDataAPI_Point2D(aRectangle.attribute("RectEndPoint")) aStartCorner.setValue(10., 10.) @@ -88,27 +88,32 @@ for i in range (0, aNbSubs): assert (isHorizontal(aLastLine) or isVertical(aLastLine)) aNbLines = aNbLines + 1 assert (aNbLines == 4) -assert (model.dof(aSketchFeature) == 4) +assert (model.dof(aSketchFeature) == 5) #========================================================================= # Move one of lines #========================================================================= aSession.startOperation() aLineEnd = geomDataAPI_Point2D(aLastLine.attribute("EndPoint")) -aLineEnd.setValue(50., 50.) +aLineEnd.setValue(41., 30.) aSession.finishOperation() #========================================================================= # Check the lines of rectangle are parallel to the axes #========================================================================= aNbSubs = aSketchFeature.numberOfSubs() aNbLines = 0 +tolerance = 1.e-5 +valref = [28.47721, 1.3352780] for i in range (0, aNbSubs): aFeature = objectToFeature(aSketchFeature.subFeature(i)) if aFeature.getKind() == "SketchLine": aLastLine = aFeature - assert (isHorizontal(aLastLine) or isVertical(aLastLine)) + #print (aLastLine.lastResult().shape().edge().length()) + #print (valref[i%2]) + #print (abs(aLastLine.lastResult().shape().edge().length()-valref[i%2])) + assert(abs(aLastLine.lastResult().shape().edge().length()-valref[i%2]) <= tolerance) aNbLines = aNbLines + 1 assert (aNbLines == 4) -assert (model.dof(aSketchFeature) == 4) +assert (model.dof(aSketchFeature) == 5) #========================================================================= # End of test #=========================================================================