Salome HOME
588dc84af6879e2f95820e21ef8ea428f7ec3665
[modules/shaper.git] / src / SketchPlugin / Test / TestSketchCopy07.py
1 # Copyright (C) 2020-2023  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 email : webmaster.salome@opencascade.com
18 #
19
20 from GeomAPI import *
21 from SketchAPI import *
22
23 from salome.shaper import model
24
25 model.begin()
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
30 SketchLine_1 = Sketch_1.addLine(-40, -72, 0, -72)
31 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
32 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
33 SketchLine_2 = SketchProjection_1.createdFeature()
34 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.result())
35 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
36 SketchLine_3 = SketchProjection_2.createdFeature()
37 SketchArc_1 = Sketch_1.addArc(0, 0, 0, -72, 72, 0, False)
38 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchArc_1.center())
39 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.result(), SketchArc_1.endPoint())
40 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40)
41 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 72)
42 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint())
43 SketchEllipticArc_1 = Sketch_1.addEllipticArc(25, 0, 25, 74.98833242578475, 72, 0, 25, 88.5, False)
44 [SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_4, SketchLine_5] = SketchEllipticArc_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
45 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.result(), SketchEllipticArc_1.center())
46 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchEllipticArc_1.startPoint())
47 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchEllipticArc_1.endPoint(), SketchAPI_Line(SketchLine_4).endPoint())
48 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
49 SketchLine_6 = Sketch_1.addLine(7.834161075251729, 88.5, 25, 88.5)
50 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchEllipticArc_1.majorAxisPositive(), SketchLine_6.endPoint())
51 SketchArc_2 = Sketch_1.addArc(-40, -8.616197183098587, -40, -72, -94.21171510314713, 24.22579430808612, True)
52 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_2.startPoint())
53 SketchArc_3 = Sketch_1.addArc(-60, 3.5, -94.21171510314713, 24.22579430808612, -60, 43.5, True)
54 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchArc_3.startPoint())
55 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchArc_3.results()[1])
56 SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_3.results()[1], 40)
57 SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_4.result(), SketchLine_6.result())
58 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_2).startPoint(), SketchAPI_Point(SketchPoint_1).coordinates(), 25, True)
59 SketchLine_7 = Sketch_1.addLine(-40, -72, -40, -8.616197183098587)
60 SketchLine_7.setAuxiliary(True)
61 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_7.startPoint())
62 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_7.endPoint())
63 SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_1.result(), SketchLine_7.result(), 90, type = "Direct")
64 SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchArc_3.endPoint(), SketchAPI_Line(SketchLine_2).startPoint(), 60)
65 SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchArc_3.endPoint(), SketchLine_6.startPoint(), 45)
66 SketchLine_8 = Sketch_1.addLine(-60, 3.5, -60, 43.5)
67 SketchLine_8.setAuxiliary(True)
68 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_3.center(), SketchLine_8.startPoint())
69 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_8.endPoint())
70 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_7.result(), SketchLine_8.result())
71 SketchCircle_1 = Sketch_1.addCircle(-60, 66, 22.5)
72 SketchCircle_1.setAuxiliary(True)
73 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchCircle_1.results()[1])
74 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_8.result(), SketchCircle_1.center())
75 SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_6.result(), SketchCircle_1.results()[1])
76 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_3.result(), 66, True)
77 SketchBSpline_1 = Sketch_1.addSpline(poles = [(-60, 43.5), (-40, 43.5), (-11.56553854601814, 88.5), (8.434461453981855, 88.5)], weights = [1, 3, 3, 1])
78 [SketchPoint_8, SketchPoint_9, SketchPoint_10, SketchPoint_11] = SketchBSpline_1.controlPoles(auxiliary = [0, 1, 2, 3])
79 [SketchLine_9, SketchLine_10, SketchLine_11] = SketchBSpline_1.controlPolygon(auxiliary = [0, 1, 2])
80 SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_11).coordinates(), SketchLine_6.result())
81 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_9.result(), SketchLine_11.result())
82 SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_8).coordinates(), SketchArc_3.endPoint())
83 SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_10).endPoint(), SketchLine_6.result())
84 SketchLine_12 = Sketch_1.addLine(-19.07878402833891, -6, -23.3, -6)
85 SketchLine_13 = Sketch_1.addLine(-23.3, -6, -23.3, 6)
86 SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
87 SketchLine_14 = Sketch_1.addLine(-23.3, 6, -19.07878402833891, 6)
88 SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
89 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_14.result())
90 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_13.result())
91 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_12.result())
92 SketchArc_4 = Sketch_1.addArc(0, 0, -19.07878402833891, -6, -19.07878402833891, 6, False)
93 SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchArc_4.center())
94 SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchArc_4.endPoint())
95 SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchLine_12.startPoint(), SketchArc_4.startPoint())
96 SketchPoint_12 = Sketch_1.addPoint(-23.3, 0)
97 SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchPoint_12.coordinates(), SketchLine_3.result())
98 SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchPoint_12.coordinates(), SketchLine_13.result())
99 SketchConstraintRadius_3 = Sketch_1.setRadius(SketchArc_4.results()[1], 20)
100 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_13.result(), 12)
101 SketchConstraintDistance_3 = Sketch_1.setDistance(SketchPoint_12.coordinates(), SketchAPI_Line(SketchLine_2).startPoint(), 23.3, True)
102 SketchBSplinePeriodic_1 = Sketch_1.addSpline(poles = [(-80, -23), (-80, 0), (-50, 0), (-50, -23)], periodic = True)
103 [SketchPoint_13, SketchPoint_14, SketchPoint_15, SketchPoint_16] = SketchBSplinePeriodic_1.controlPoles(auxiliary = [0, 1, 2, 3])
104 [SketchLine_15, SketchLine_16, SketchLine_17, SketchLine_18] = SketchBSplinePeriodic_1.controlPolygon(auxiliary = [0, 1, 2, 3])
105 SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_16.result(), SketchLine_5.result())
106 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_18.result(), SketchLine_16.result())
107 SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_15.result(), SketchLine_17.result())
108 SketchConstraintPerpendicular_2 = Sketch_1.setPerpendicular(SketchLine_18.result(), SketchLine_15.result())
109 SketchEllipse_1 = Sketch_1.addEllipse(35, 45, 35, 67.91287847483518, 10)
110 [SketchPoint_17, SketchPoint_18, SketchPoint_19, SketchPoint_20, SketchPoint_21, SketchPoint_22, SketchPoint_23, SketchLine_19, SketchLine_20] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
111 SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_4.result(), SketchLine_19.result())
112 SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_16.result(), 30)
113 SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_15.result(), 23)
114 SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_19.result(), 50)
115 SketchConstraintLength_6 = Sketch_1.setLength(SketchLine_20.result(), 20)
116 SketchConstraintDistance_4 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_17).startPoint(), SketchArc_4.center(), 50, True)
117 SketchConstraintCoincidence_26 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_23).coordinates(), SketchLine_4.result())
118 SketchConstraintDistance_5 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_17).coordinates(), SketchLine_3.result(), 45, True)
119 SketchCircle_2 = Sketch_1.addCircle(0, 66, 12)
120 SketchConstraintCoincidence_27 = Sketch_1.setCoincident(SketchLine_2.result(), SketchCircle_2.center())
121 SketchConstraintRadius_4 = Sketch_1.setRadius(SketchCircle_2.results()[1], 12)
122 SketchLine_21 = Sketch_1.addLine(-60, 66, 0, 66)
123 SketchLine_21.setAuxiliary(True)
124 SketchConstraintCoincidence_28 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_21.startPoint())
125 SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_21.result())
126 SketchConstraintCoincidence_29 = Sketch_1.setCoincident(SketchLine_21.endPoint(), SketchCircle_2.center())
127 model.do()
128
129 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchArc_1_2f-SketchEllipticArc_1f-SketchLine_6r-SketchBSpline_1r-SketchArc_3_2f-SketchArc_2_2f-SketchLine_12f-SketchLine_13f-SketchLine_14f-SketchArc_4_2r-SketchBSplinePeriodic_1f-SketchEllipse_1r-SketchCircle_2_2r")], model.selection(), 10, 0)
130
131 Sketch_1_Copy = model.copySketch(partSet, Sketch_1)
132
133 model.end()
134
135 error = model.compareSketches(Sketch_1, Sketch_1_Copy)
136 assert(error == ""), error
137
138 model.testNbResults(Extrusion_1, 1)
139 model.testNbSubResults(Extrusion_1, [0])
140 model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [1])
141 model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [16])
142 model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [84])
143 model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [168])
144 model.testResultsVolumes(Extrusion_1, [183140.3921289446])
145
146 assert(partSet.size("Features") == 2)
147 assert(Part_1_doc.size("Features") == 2)
148
149 assert(model.checkPythonDump())