Salome HOME
Issue #2824: Constraints at wrong positions when editing the sketch
[modules/shaper.git] / src / SketchPlugin / Test / Test2824.py
1 ## Copyright (C) 2018-20xx  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 """
22     Test2824.py
23     Test case for issue #2824 "Constraints at wrong positions when editing the sketch (BARCOM)"
24 """
25
26 from salome.shaper import model
27 from GeomAPI import *
28 from GeomDataAPI import *
29
30 import math
31
32 TOLERANCE = 1.e-6
33
34 model.begin()
35 partSet = model.moduleDocument()
36 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOZ"))
37 SketchArc_1 = Sketch_1.addArc(7.554548355024374, 9.322927740745062, 20, 30.60489708262655, 31.5458454490763, 15, True)
38 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "OZ"), False)
39 SketchLine_1 = SketchProjection_1.createdFeature()
40 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.startPoint(), SketchLine_1.result(), 20, True)
41 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "OX"), False)
42 SketchLine_2 = SketchProjection_2.createdFeature()
43 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchArc_1.endPoint(), SketchLine_2.result(), 15, True)
44 model.do()
45 # move the arc like the user does
46 for i in range(0, 10):
47     Sketch_1.move(SketchArc_1.startPoint(), SketchArc_1.startPoint().x(), SketchArc_1.startPoint().y() + 5)
48 model.end()
49 model.undo()
50
51 # compare the arc arguments and the resulting shape
52 aStartAttrY = SketchArc_1.startPoint().y()
53 aEndAttrX = SketchArc_1.endPoint().x()
54
55 anArcShape = SketchArc_1.feature().lastResult().shape()
56 aShapeExplorer = GeomAPI_ShapeExplorer(anArcShape, GeomAPI_Shape.VERTEX)
57
58 aPoint = aShapeExplorer.current().vertex().point()
59 aEndShapeX = aPoint.x()
60 assert(math.fabs(aEndAttrX - aEndShapeX) < TOLERANCE)
61
62 aShapeExplorer.next()
63 aPoint = aShapeExplorer.current().vertex().point()
64 aStartShapeY = aPoint.z() # in 3D sketch y iz Z
65 assert(math.fabs(aStartAttrY - aStartShapeY) < TOLERANCE)