Salome HOME
bd2c9aa50f5a3f95019137453e15796a3adc41c9
[modules/shaper.git] / src / SketchPlugin / Test / Test2273.py
1 # Copyright (C) 2014-2023  CEA, EDF
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     Test2273.py
22     Test case for issue #2273 "Error when reading HDF and Python dump"
23                               (multi-rotation center refers to a feature produced by itself)
24 """
25
26 from salome.shaper import model
27 from SketchAPI import *
28
29 model.begin()
30 partSet = model.moduleDocument()
31 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
32 SketchLine_1 = Sketch_1.addLine(-65.36884900412264, 10.74954405845571, -18.59380593895045, 62.75409504395774)
33 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "Origin"), False)
34 SketchPoint_1 = SketchProjection_1.createdFeature()
35
36
37 # Test 1. Check MultiRotation error
38
39 SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_1.result()], SketchAPI_Point(SketchPoint_1).coordinates(), 90, 3)
40 [SketchLine_2, SketchLine_3] = SketchMultiRotation_1.rotated()
41 model.do()
42 # check MultiRotation has NO error
43 assert(SketchMultiRotation_1.feature().error() == "")
44 # change center of MultiRotation to extremity of generated feature, check an error appears
45 SketchMultiRotation_1.center().setAttr(SketchAPI_Line(SketchLine_2).startPoint())
46 model.do()
47 assert(SketchMultiRotation_1.feature().error() != "")
48 # revert changes => no error
49 SketchMultiRotation_1.center().setAttr(SketchAPI_Point(SketchPoint_1).coordinates())
50 model.do()
51 assert(SketchMultiRotation_1.feature().error() == "")
52
53
54 # Test 2. Check MultiRotation error
55
56 SketchMultiTranslation_1 = Sketch_1.addTranslation([SketchLine_1.result()], SketchLine_1.startPoint(), SketchAPI_Line(SketchLine_2).endPoint(), 2)
57 [SketchLine_4] = SketchMultiTranslation_1.translated()
58 model.do()
59 # check MultiTranslation has NO error
60 assert(SketchMultiTranslation_1.feature().error() == "")
61 # change start point to extremity of generated feature, check an error appears
62 SketchMultiTranslation_1.startPoint().setAttr(SketchAPI_Line(SketchLine_4).endPoint())
63 model.do()
64 assert(SketchMultiTranslation_1.feature().error() != "")
65 # revert changes => no error
66 SketchMultiTranslation_1.startPoint().setAttr(SketchLine_1.startPoint())
67 model.do()
68 assert(SketchMultiTranslation_1.feature().error() == "")
69 # change end point to extremity of generated feature, check an error appears
70 SketchMultiTranslation_1.endPoint().setAttr(SketchAPI_Line(SketchLine_4).endPoint())
71 model.do()
72 assert(SketchMultiTranslation_1.feature().error() != "")
73 # revert changes => no error
74 SketchMultiTranslation_1.endPoint().setAttr(SketchAPI_Line(SketchLine_2).endPoint())
75 model.do()
76 assert(SketchMultiTranslation_1.feature().error() == "")
77
78
79 # Test 3. Check Mirror error
80
81 SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), [SketchLine_1.result(), SketchLine_3.result()])
82 [SketchLine_5, SketchLine_6] = SketchConstraintMirror_1.mirrored()
83 model.do()
84 # check Mirror has NO error
85 assert(SketchConstraintMirror_1.feature().error() == "")
86 # change mirror line to generated feature, check an error appears
87 SketchConstraintMirror_1.mirrorLine().setObject(SketchLine_5.feature().firstResult())
88 model.do()
89 assert(SketchConstraintMirror_1.feature().error() != "")
90 # revert changes => no error
91 SketchConstraintMirror_1.mirrorLine().setObject(SketchLine_2.feature().firstResult())
92 model.do()
93 assert(SketchConstraintMirror_1.feature().error() == "")
94
95 model.end()
96
97
98 assert(model.checkPythonDump())