Salome HOME
d28a79157a116f6e34607f3e23da39f88726a42d
[modules/shaper.git] / src / SketchPlugin / Test / Test2824.py
1 # Copyright (C) 2018-2023  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 """
21     Test2824.py
22     Test case for issue #2824 "Constraints at wrong positions when editing the sketch (BARCOM)"
23 """
24
25 from salome.shaper import model
26 from GeomAPI import *
27 from GeomDataAPI import *
28
29 import math
30
31 TOLERANCE = 1.e-6
32
33 model.begin()
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)
43 model.do()
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)
47 model.end()
48 model.undo()
49
50 # compare the arc arguments and the resulting shape
51 aStartAttrY = SketchArc_1.startPoint().y()
52 aEndAttrX = SketchArc_1.endPoint().x()
53
54 anArcShape = SketchArc_1.feature().lastResult().shape()
55 aShapeExplorer = GeomAPI_ShapeExplorer(anArcShape, GeomAPI_Shape.VERTEX)
56
57 aPoint = aShapeExplorer.current().vertex().point()
58 aEndShapeX = aPoint.x()
59 assert(math.fabs(aEndAttrX - aEndShapeX) < TOLERANCE)
60
61 aShapeExplorer.next()
62 aPoint = aShapeExplorer.current().vertex().point()
63 aStartShapeY = aPoint.z() # in 3D sketch y iz Z
64 assert(math.fabs(aStartAttrY - aStartShapeY) < TOLERANCE)