Salome HOME
Updated copyright comment
[modules/shaper.git] / src / SketchPlugin / Test / Test1577.py
1 # Copyright (C) 2018-2024  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     Test1577.py
22     Test case for issue #1577 "distance constraint change sign"
23 """
24
25 from salome.shaper import model
26 import math
27
28 model.begin()
29 partSet = model.moduleDocument()
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
32 model.addParameter(Part_1_doc, "Base_Off", "5.875")
33 model.addParameter(Part_1_doc, "Base_H", "3")
34 model.addParameter(Part_1_doc, "Base_B", "1.5")
35 model.addParameter(Part_1_doc, "Wall_R", "6.188")
36 model.addParameter(Part_1_doc, "Wall_T1", "0.089")
37 model.addParameter(Part_1_doc, "Wall_T2", "0.261")
38 model.addParameter(Part_1_doc, "Wall_H", "12.465")
39 model.addParameter(Part_1_doc, "StrGal_B", "0.75")
40 model.addParameter(Part_1_doc, "StrGal_H", "1.8")
41 model.addParameter(Part_1_doc, "StrGal_BU", "0.6")
42 model.addParameter(Part_1_doc, "StrGal_Inc", "0.2")
43 model.addParameter(Part_1_doc, "Bracket_H", "1.2")
44 model.addParameter(Part_1_doc, "Bracket_B", "0.15")
45 model.addParameter(Part_1_doc, "Bracket_B1", "0.256")
46 model.addParameter(Part_1_doc, "Bracket_B2", "0.094")
47 model.addParameter(Part_1_doc, "Bracket_H1", "1.226")
48 model.addParameter(Part_1_doc, "Cover_R", "9.794")
49 model.addParameter(Part_1_doc, "Cover_T", "0.082")
50 model.addParameter(Part_1_doc, "Cover_T1", "0.125")
51 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
52 SketchPoint_1 = Sketch_1.addPoint(0, 2.425)
53 SketchConstraintRigid_1 = Sketch_1.setFixed(SketchPoint_1.coordinates())
54 SketchLine_1 = Sketch_1.addLine(6.277, 12.18846022232796, 6.277, -8.121250994790044)
55 SketchLine_1.setAuxiliary(True)
56 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
57 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchPoint_1.coordinates(), SketchLine_1.result(), "Wall_R+Wall_T1", False)
58 SketchLine_2 = Sketch_1.addLine(6.538, -3.45, 7.777, -3.45)
59 SketchLine_3 = Sketch_1.addLine(7.777, -3.45, 7.777, -6.45)
60 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
61 SketchLine_4 = Sketch_1.addLine(7.777, -6.45, 0, -6.45)
62 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
63 SketchLine_5 = Sketch_1.addLine(0, -6.45, 0, -3.45)
64 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
65 SketchLine_6 = Sketch_1.addLine(0, -3.45, 6.188, -3.45)
66 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
67 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result())
68 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_5.result())
69 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_6.result())
70 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_2.result())
71 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_4.result())
72 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchPoint_1.coordinates(), SketchLine_6.result(), "Base_Off", False)
73 SketchConstraintDistance_3 = Sketch_1.setDistance(SketchPoint_1.coordinates(), SketchLine_2.result(), "Base_Off", False)
74 SketchConstraintDistance_4 = Sketch_1.setDistance(SketchLine_2.endPoint(), SketchLine_4.result(), "Base_H", False)
75 SketchConstraintDistance_5 = Sketch_1.setDistance(SketchLine_4.startPoint(), SketchLine_1.result(), "Base_B", False)
76 SketchConstraintDistance_6 = Sketch_1.setDistance(SketchLine_5.startPoint(), SketchLine_1.result(), "Wall_R+Wall_T1", False)
77 SketchConstraintDistance_7 = Sketch_1.setDistance(SketchLine_6.endPoint(), SketchLine_1.result(), "Wall_T1", False)
78 SketchConstraintDistance_8 = Sketch_1.setDistance(SketchLine_1.result(), SketchLine_2.startPoint(), "Wall_T2", False)
79 SketchLine_7 = Sketch_1.addLine(5.677, -4.05, 6.877, -4.05)
80 SketchLine_8 = Sketch_1.addLine(6.877, -4.05, 7.027, -4.25)
81 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
82 SketchLine_9 = Sketch_1.addLine(7.027, -4.25, 7.027, -5.85)
83 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
84 SketchLine_10 = Sketch_1.addLine(7.027, -5.85, 5.527, -5.85)
85 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
86 SketchLine_11 = Sketch_1.addLine(5.527, -5.85, 5.527, -4.25)
87 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
88 SketchLine_12 = Sketch_1.addLine(5.527, -4.25, 5.677, -4.05)
89 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
90 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_7.startPoint(), SketchLine_12.endPoint())
91 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_9.result())
92 SketchConstraintVertical_5 = Sketch_1.setVertical(SketchLine_11.result())
93 SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_7.result())
94 SketchConstraintHorizontal_5 = Sketch_1.setHorizontal(SketchLine_10.result())
95 SketchConstraintDistance_9 = Sketch_1.setDistance(SketchLine_10.endPoint(), SketchLine_1.result(), "StrGal_B", False)
96 SketchConstraintDistance_10 = Sketch_1.setDistance(SketchLine_10.startPoint(), SketchLine_1.result(), "StrGal_B", False)
97 SketchConstraintDistance_11 = Sketch_1.setDistance(SketchLine_12.endPoint(), SketchLine_1.result(), "StrGal_BU", False)
98 SketchConstraintDistance_12 = Sketch_1.setDistance(SketchLine_7.endPoint(), SketchLine_1.result(), "StrGal_BU", False)
99 SketchConstraintDistance_13 = Sketch_1.setDistance(SketchLine_7.endPoint(), SketchLine_10.result(), "StrGal_H", False)
100 SketchConstraintDistance_14 = Sketch_1.setDistance(SketchLine_7.endPoint(), SketchLine_2.result(), 0.6, True)
101 SketchConstraintDistance_15 = Sketch_1.setDistance(SketchLine_9.startPoint(), SketchLine_7.result(), "StrGal_Inc", False)
102 SketchConstraintDistance_16 = Sketch_1.setDistance(SketchLine_11.endPoint(), SketchLine_7.result(), "StrGal_Inc", False)
103 SketchLine_13 = Sketch_1.addLine(6.188, -3.45, 6.188, 0.287301537219)
104 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_13.startPoint())
105 SketchLine_14 = Sketch_1.addLine(6.538, -3.45, 6.538, -1.380737101082)
106 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_14.startPoint())
107 SketchLine_15 = Sketch_1.addLine(6.538, -1.380737101082, 6.366, -1.102730661365)
108 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
109 SketchLine_16 = Sketch_1.addLine(6.366, -1.102730661365, 6.366, 0.21779992729)
110 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
111 SketchConstraintVertical_6 = Sketch_1.setVertical(SketchLine_13.result())
112 SketchConstraintVertical_7 = Sketch_1.setVertical(SketchLine_14.result())
113 SketchConstraintVertical_8 = Sketch_1.setVertical(SketchLine_16.result())
114 SketchConstraintDistance_17 = Sketch_1.setDistance(SketchLine_16.endPoint(), SketchLine_1.result(), "Wall_T1", False)
115 model.do()
116
117 # store coordinates of the gallery
118 Lines = [SketchLine_7, SketchLine_8, SketchLine_9, SketchLine_10, SketchLine_11, SketchLine_12]
119 RefCoorindates = []
120 for line in Lines:
121     RefCoorindates.append(line.startPoint().x())
122     RefCoorindates.append(line.startPoint().y())
123     RefCoorindates.append(line.endPoint().x())
124     RefCoorindates.append(line.endPoint().y())
125
126 SketchConstraintDistance_18 = Sketch_1.setDistance(SketchLine_14.endPoint(), SketchLine_2.result(), "Wall_H", True)
127 model.do()
128
129 # check coordinates of lines are not changed
130 TOLERANCE = 1e-6
131 index = 0
132 for line in Lines:
133     assert(math.fabs(line.startPoint().x() - RefCoorindates[index]) < TOLERANCE)
134     assert(math.fabs(line.startPoint().y() - RefCoorindates[index + 1]) < TOLERANCE)
135     assert(math.fabs(line.endPoint().x() - RefCoorindates[index + 2]) < TOLERANCE)
136     assert(math.fabs(line.endPoint().y() - RefCoorindates[index + 3]) < TOLERANCE)
137     index += 4
138
139 model.end()