1 # Copyright (C) 2018-2019 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 Test case for issue #2824 "Constraints at wrong positions when editing the sketch (BARCOM)"
25 from salome.shaper import model
27 from GeomDataAPI import *
34 partSet = model.moduleDocument()
35 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOZ"))
36 SketchArc_1 = Sketch_1.addArc(7.554548355024374, 9.322927740745062, 20, 30.60489708262655, 31.5458454490763, 15, True)
37 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "OZ"), False)
38 SketchLine_1 = SketchProjection_1.createdFeature()
39 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.startPoint(), SketchLine_1.result(), 20, True)
40 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "OX"), False)
41 SketchLine_2 = SketchProjection_2.createdFeature()
42 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchArc_1.endPoint(), SketchLine_2.result(), 15, True)
44 # move the arc like the user does
45 for i in range(0, 10):
46 Sketch_1.move(SketchArc_1.startPoint(), SketchArc_1.startPoint().x(), SketchArc_1.startPoint().y() + 5)
50 # compare the arc arguments and the resulting shape
51 aStartAttrY = SketchArc_1.startPoint().y()
52 aEndAttrX = SketchArc_1.endPoint().x()
54 anArcShape = SketchArc_1.feature().lastResult().shape()
55 aShapeExplorer = GeomAPI_ShapeExplorer(anArcShape, GeomAPI_Shape.VERTEX)
57 aPoint = aShapeExplorer.current().vertex().point()
58 aEndShapeX = aPoint.x()
59 assert(math.fabs(aEndAttrX - aEndShapeX) < TOLERANCE)
62 aPoint = aShapeExplorer.current().vertex().point()
63 aStartShapeY = aPoint.z() # in 3D sketch y iz Z
64 assert(math.fabs(aStartAttrY - aStartShapeY) < TOLERANCE)