Salome HOME
Issues #2850, #2860: Change type of angle while Python Dump, because the configuratio...
[modules/shaper.git] / src / SketchPlugin / Test / Test2427.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     Test2427.py
23     Test case for issue #2427 "error in sketch solver"
24 """
25
26 from SketchAPI import *
27
28 from salome.shaper import model
29
30 model.begin()
31 partSet = model.moduleDocument()
32 Part_1 = model.addPart(partSet)
33 Part_1_doc = Part_1.document()
34 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
35 SketchLine_1 = Sketch_1.addLine(0, 0, 9.085455512028094, 9.085455512028094)
36 SketchLine_1.setAuxiliary(True)
37 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
38 SketchLine_2 = SketchProjection_1.createdFeature()
39 SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_2.result(), SketchLine_1.result(), 45)
40 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchAPI_Line(SketchLine_2).startPoint())
41 SketchArc_1 = Sketch_1.addArc(0, 0, 3.427521359192312, 2.062061427864143, 2.06206142786378, 3.427521359191917, True)
42 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.center())
43 SketchLine_3 = Sketch_1.addLine(6, 7.365459931328136, 6, 12)
44 SketchLine_4 = Sketch_1.addLine(6, 12, -6, 12)
45 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
46 SketchLine_5 = Sketch_1.addLine(-6, 12, -6, 7.365459931328136)
47 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
48 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 4)
49 SketchLine_6 = Sketch_1.addLine(-5.8309518948453, -7.5, -11, -7.5)
50 SketchLine_7 = Sketch_1.addLine(-11, -7.5, -11, -10)
51 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
52 SketchLine_8 = Sketch_1.addLine(-11, -10, 11, -10)
53 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
54 SketchLine_9 = Sketch_1.addLine(11, -10, 11, -7.5)
55 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
56 SketchLine_10 = Sketch_1.addLine(11, -7.5, 5.830951894845301, -7.5)
57 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
58 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_6.result())
59 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_10.result())
60 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_8.result())
61 SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_4.result())
62 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_7.result())
63 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_9.result())
64 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_3.result())
65 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_5.result())
66 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_8.result(), 22)
67 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), 12)
68 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_4.result(), SketchLine_7.endPoint(), 22, True)
69 SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_7.result(), 2.5)
70 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_8.endPoint(), SketchLine_2.result(), 10, True)
71 SketchPoint_1 = Sketch_1.addPoint(0, -10)
72 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_8.result())
73 SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchLine_8.result(), SketchPoint_1.coordinates())
74 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
75 SketchLine_11 = SketchProjection_2.createdFeature()
76 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_11.result(), SketchPoint_1.coordinates())
77 SketchLine_12 = Sketch_1.addLine(2.06206142786378, 3.427521359191917, 6, 7.365459931328136)
78 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_12.startPoint())
79 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_3.startPoint())
80 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_12.result(), SketchLine_1.result())
81 SketchLine_13 = Sketch_1.addLine(3.427521359192312, 2.062061427864143, 8.000256151511394, 5.123075395720331)
82 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_13.startPoint())
83 SketchArc_2 = Sketch_1.addArc(0, 0, 8.000256151511394, 5.123075395720331, 5.830951894845301, -7.5, True)
84 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_2.center())
85 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_13.endPoint())
86 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchArc_2.endPoint())
87 SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 9.5)
88 SketchLine_14 = Sketch_1.addLine(3.427521359192312, 2.062061427864143, 2.06206142786378, 3.427521359191917)
89 SketchLine_14.setAuxiliary(True)
90 SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_14.startPoint())
91 SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchArc_1.endPoint())
92 SketchPoint_2 = Sketch_1.addPoint(2.744791393527834, 2.744791393527835)
93 SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_14.result())
94 SketchConstraintMiddle_2 = Sketch_1.setMiddlePoint(SketchLine_14.result(), SketchPoint_2.coordinates())
95 SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchLine_14.result(), SketchPoint_2.coordinates())
96 SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_1.result())
97 SketchArc_3 = Sketch_1.addArc(0, 0, -6, 7.365459931328136, -5.8309518948453, -7.5, False)
98 SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchArc_3.startPoint())
99 SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchArc_3.endPoint())
100 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchArc_2.results()[1], SketchArc_3.results()[1])
101 SketchPoint_3 = Sketch_1.addPoint(0, 12)
102 SketchConstraintMiddle_3 = Sketch_1.setMiddlePoint(SketchLine_4.result(), SketchPoint_3.coordinates())
103 SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_11.result())
104 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_7.result(), SketchLine_9.result())
105 SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_6.result(), SketchLine_10.result())
106 SketchConstraintEqual_4 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_5.result())
107 SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_13.endPoint(), SketchLine_12.result(), 3, True)
108 SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchArc_3.center(), SketchLine_1.result())
109 model.do()
110 model.end()
111
112
113 # Test 1. Add constraint to make auxiliary line degenerated, then undo
114 model.begin()
115 aParallel = Sketch_1.setParallel(SketchLine_1.result(), SketchLine_13.result())
116 model.do()
117 model.end()
118 model.checkSketchErrorDegenerated(Sketch_1)
119 model.undo()
120 model.checkSketch(Sketch_1)
121
122 # Test 2. Add constraint to make auxiliary line degenerated, then remove such constraint
123 model.begin()
124 aParallel = Sketch_1.setParallel(SketchLine_1.result(), SketchLine_13.result())
125 model.do()
126 model.checkSketchErrorDegenerated(Sketch_1)
127 Part_1_doc.removeFeature(aParallel.feature())
128 model.do()
129 model.end()
130 model.checkSketch(Sketch_1)
131
132 assert(model.checkPythonDump())