Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / Test / Test2920.py
1 # Copyright (C) 2019-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 from salome.shaper import model
21
22 model.begin()
23 partSet = model.moduleDocument()
24 Part_1 = model.addPart(partSet)
25 Part_1_doc = Part_1.document()
26 Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 10, 0)
27 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
28 SketchLine_1 = Sketch_1.addLine(-28.02134146341463, 30.17682926829269, -40.03048780487805, 30.17682926829269)
29 SketchLine_2 = Sketch_1.addLine(-40.03048780487805, 30.17682926829269, -40.03048780487805, 21.24695121951219)
30 SketchLine_3 = Sketch_1.addLine(-40.03048780487805, 21.24695121951219, -28.02134146341463, 21.24695121951219)
31 SketchLine_4 = Sketch_1.addLine(-28.02134146341463, 21.24695121951219, -28.02134146341463, 30.17682926829269)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
33 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
34 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
35 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
36 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
37 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
38 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
39 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
40 SketchLine_5 = Sketch_1.addLine(-24.32621951219512, 13.39481707317073, -38.79878048780488, 13.39481707317073)
41 SketchLine_6 = Sketch_1.addLine(-38.79878048780488, 13.39481707317073, -38.79878048780488, 9.545731707317071)
42 SketchLine_7 = Sketch_1.addLine(-38.79878048780488, 9.545731707317071, -24.32621951219512, 9.545731707317071)
43 SketchLine_8 = Sketch_1.addLine(-24.32621951219512, 9.545731707317071, -24.32621951219512, 13.39481707317073)
44 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint())
45 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
46 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
47 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
48 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_5.result())
49 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_6.result())
50 SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_7.result())
51 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_8.result())
52 SketchCircle_1 = Sketch_1.addCircle(-15.39634146341463, 19.39939024390243, 5.234756097560973)
53 Extrusion_1.setNestedSketch(Sketch_1)
54 Extrusion_2 = model.addExtrusion(Part_1_doc, [], model.selection(), 10, 10)
55 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
56 SketchEllipse_1 = Sketch_2.addEllipse(9.45504630186378, 35.70277888541424, 12.45818659778603, 26.02599348744252, 6.842520574992792)
57 [SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_9, SketchLine_10] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
58 SketchLine_11 = Sketch_2.addLine(18.91725801191108, 15.97306085169858, 9.656369955269037, 15.97306085169858)
59 SketchLine_12 = Sketch_2.addLine(9.656369955269037, 15.97306085169858, 9.656369955269037, -4.360628142232864)
60 SketchLine_13 = Sketch_2.addLine(9.656369955269037, -4.360628142232864, 18.91725801191108, -4.360628142232864)
61 SketchLine_14 = Sketch_2.addLine(18.91725801191108, -4.360628142232864, 18.91725801191108, 15.97306085169858)
62 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_11.startPoint())
63 SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
64 SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
65 SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
66 SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_11.result())
67 SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_12.result())
68 SketchConstraintHorizontal_6 = Sketch_2.setHorizontal(SketchLine_13.result())
69 SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_14.result())
70 SketchCircle_2 = Sketch_2.addCircle(-32.8229209132412, -2.146067954774983, 6.582390686251648)
71 Extrusion_2.setNestedSketch(Sketch_2)
72 Compound_1_objects = [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")]
73 Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
74 Compound_1.result().setName("A")
75 Compound_1.result().setColor(0, 255, 0)
76 Compound_1.result().subResult(0).setColor(0, 255, 0)
77 Compound_1.result().subResult(1).setColor(0, 255, 0)
78 Compound_1.result().subResult(2).setColor(0, 255, 0)
79 Compound_2_objects = [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2"), model.selection("SOLID", "Extrusion_2_3")]
80 Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects)
81 Compound_2.result().setName("B")
82 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Compound_1_1_1/Modified_Face&Extrusion_1_1/To_Face"), 5, True)
83 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
84 SketchLine_15 = Sketch_3.addLine(-43.21451225862969, 24.76425132139253, -23.11145813617009, 27.98073998098607)
85 SketchLine_16 = Sketch_3.addLine(-23.11145813617009, 27.98073998098607, 25.13587175773296, 39.84154191323723)
86 SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
87 SketchLine_17 = Sketch_3.addLine(25.13587175773296, 39.84154191323723, 22.9245358042624, 1.746254351176285)
88 SketchConstraintCoincidence_14 = Sketch_3.setCoincident(SketchLine_16.endPoint(), SketchLine_17.startPoint())
89 SketchLine_18 = Sketch_3.addLine(22.9245358042624, 1.746254351176285, -48.84336741291839, 6.973048423015779)
90 SketchConstraintCoincidence_15 = Sketch_3.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint())
91 SketchLine_19 = Sketch_3.addLine(-48.84336741291839, 6.973048423015779, -43.21451225862969, 24.76425132139253)
92 SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint())
93 SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_15.startPoint(), SketchLine_19.endPoint())
94 SketchLine_20 = Sketch_3.addLine(-42.51090536434361, 23.45755280343266, -22.9104275949455, 26.1714651099647)
95 SketchLine_21 = Sketch_3.addLine(-22.9104275949455, 26.1714651099647, 23.32659688671159, 37.73072123037897)
96 SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint())
97 SketchLine_22 = Sketch_3.addLine(23.32659688671159, 37.73072123037897, 20.91423039201644, 3.957590304646839)
98 SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint())
99 SketchLine_23 = Sketch_3.addLine(20.91423039201644, 3.957590304646839, -46.02893983577404, 7.97820112913876)
100 SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint())
101 SketchLine_24 = Sketch_3.addLine(-46.02893983577404, 7.97820112913876, -42.51090536434361, 23.45755280343266)
102 SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_24.startPoint())
103 SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_20.startPoint(), SketchLine_24.endPoint())
104 model.do()
105 Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_19r-SketchLine_18r-SketchLine_17r-SketchLine_16r-SketchLine_15r-SketchLine_20f-SketchLine_21f-SketchLine_22f-SketchLine_23f-SketchLine_24f")], model.selection(), 10, 0)
106 Extrusion_3.result().setName("C")
107 Extrusion_3.result().setColor(0, 85, 255)
108 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Compound_1_1_1"), model.selection("SOLID", "Compound_2_1_2")], [model.selection("SOLID", "C")], keepSubResults = True)
109 model.end()
110
111 from GeomAPI import GeomAPI_Shape
112
113 model.testNbResults(Cut_1, 1)
114 model.testNbSubResults(Cut_1, [4])
115 model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [6])
116 model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [35])
117 model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [138])
118 model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [276])
119 model.testResultsVolumes(Cut_1, [14047.4641487433])
120
121 assert(model.checkPythonDump())