1 # Copyright (C) 2014-2021 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 #2273 "Error when reading HDF and Python dump"
23 (multi-rotation center refers to a feature produced by itself)
26 from salome.shaper import model
27 from SketchAPI import *
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()
37 # Test 1. Check MultiRotation error
39 SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_1.result()], SketchAPI_Point(SketchPoint_1).coordinates(), 90, 3)
40 [SketchLine_2, SketchLine_3] = SketchMultiRotation_1.rotated()
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())
47 assert(SketchMultiRotation_1.feature().error() != "")
48 # revert changes => no error
49 SketchMultiRotation_1.center().setAttr(SketchAPI_Point(SketchPoint_1).coordinates())
51 assert(SketchMultiRotation_1.feature().error() == "")
54 # Test 2. Check MultiRotation error
56 SketchMultiTranslation_1 = Sketch_1.addTranslation([SketchLine_1.result()], SketchLine_1.startPoint(), SketchAPI_Line(SketchLine_2).endPoint(), 2)
57 [SketchLine_4] = SketchMultiTranslation_1.translated()
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())
64 assert(SketchMultiTranslation_1.feature().error() != "")
65 # revert changes => no error
66 SketchMultiTranslation_1.startPoint().setAttr(SketchLine_1.startPoint())
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())
72 assert(SketchMultiTranslation_1.feature().error() != "")
73 # revert changes => no error
74 SketchMultiTranslation_1.endPoint().setAttr(SketchAPI_Line(SketchLine_2).endPoint())
76 assert(SketchMultiTranslation_1.feature().error() == "")
79 # Test 3. Check Mirror error
81 SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), [SketchLine_1.result(), SketchLine_3.result()])
82 [SketchLine_5, SketchLine_6] = SketchConstraintMirror_1.mirrored()
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())
89 assert(SketchConstraintMirror_1.feature().error() != "")
90 # revert changes => no error
91 SketchConstraintMirror_1.mirrorLine().setObject(SketchLine_2.feature().firstResult())
93 assert(SketchConstraintMirror_1.feature().error() == "")
98 assert(model.checkPythonDump())