]> SALOME platform Git repositories - modules/shaper.git/blob - test.models/bobine_film_reel.py
Salome HOME
Sort alphabetically unit tests for SketchPlugin module
[modules/shaper.git] / test.models / bobine_film_reel.py
1 ## Copyright (C) 2014-2017  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 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 Parameter_R = model.addParameter(Part_1_doc, "R", "40")
30 model.addParameter(Part_1_doc, "h", "3")
31 model.addParameter(Part_1_doc, "R2", "33.5")
32 model.addParameter(Part_1_doc, "h2", "4")
33 model.addParameter(Part_1_doc, "R3", "25.9")
34 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
35 SketchCircle_1 = Sketch_1.addCircle(0, 0, 40)
36 SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
37 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchPoint_1.result())
38 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], "R")
39 SketchLine_1 = Sketch_1.addLine(0, 0, -20.88093073029438, 34.1172497695333)
40 SketchLine_1.setAuxiliary(True)
41 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.startPoint())
42 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.startPoint())
43 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1])
44 model.do()
45 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "h", 0)
46 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1"))
47 SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"))
48 SketchLine_2 = SketchProjection_1.createdFeature()
49 SketchCircle_2 = Sketch_2.addCircle(0, 0, 33.5)
50 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_2.results()[1], "R2")
51 SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_2.center())
52 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_14")
53 model.do()
54 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")], model.selection(), "h2", 0)
55 Extrusion_3 = model.addExtrusion(Part_1_doc, [], model.selection(), "h2*3", 0)
56 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face_1"))
57 SketchCircle_3 = Sketch_3.addCircle(0, 0, 28.25)
58 SketchConstraintRadius_3 = Sketch_3.setRadius(SketchCircle_3.results()[1], 28.25)
59 SketchProjection_2 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"))
60 SketchLine_3 = SketchProjection_2.createdFeature()
61 SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchCircle_3.center(), SketchAPI_Line(SketchLine_3).startPoint())
62 Extrusion_3.setNestedSketch(Sketch_3)
63 Extrusion_4 = model.addExtrusion(Part_1_doc, [], model.selection(), "h2", 0)
64 Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_3_1/To_Face_1"))
65 SketchProjection_3 = Sketch_4.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"))
66 SketchLine_4 = SketchProjection_3.createdFeature()
67 SketchCircle_4 = Sketch_4.addCircle(0, 0, 25.9)
68 SketchConstraintRadius_4 = Sketch_4.setRadius(SketchCircle_4.results()[1], "R3")
69 SketchConstraintCoincidence_7 = Sketch_4.setCoincident(SketchAPI_Line(SketchLine_4).startPoint(), SketchCircle_4.center())
70 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_15")
71 Extrusion_4.setNestedSketch(Sketch_4)
72 Extrusion_5 = model.addExtrusion(Part_1_doc, [], model.selection(), "h2", 0)
73 Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_4_1/To_Face_1"))
74 SketchProjection_4 = Sketch_5.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"))
75 SketchLine_5 = SketchProjection_4.createdFeature()
76 SketchCircle_5 = Sketch_5.addCircle(0, 0, 8)
77 SketchConstraintRadius_5 = Sketch_5.setRadius(SketchCircle_5.results()[1], 8)
78 SketchConstraintCoincidence_8 = Sketch_5.setCoincident(SketchAPI_Line(SketchLine_5).startPoint(), SketchCircle_5.center())
79 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_16")
80 Extrusion_5.setNestedSketch(Sketch_5)
81 Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_4_1"), model.selection("SOLID", "Extrusion_5_1"), model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_3_1")], [])
82 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection("FACE", "Extrusion_5_1/To_Face_1"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")])
83 Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face_1"))
84 SketchCircle_6 = Sketch_6.addCircle(0, 0, 4.2)
85 SketchConstraintRadius_6 = Sketch_6.setRadius(SketchCircle_6.results()[1], 4.2)
86 SketchPoint_2 = Sketch_6.addPoint(model.selection("VERTEX", "PartSet/Origin"))
87 SketchConstraintCoincidence_9 = Sketch_6.setCoincident(SketchPoint_2.coordinates(), SketchCircle_6.center())
88 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_17")
89 ExtrusionCut_1.setNestedSketch(Sketch_6)
90 Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_2"))
91 SketchCircle_7 = Sketch_7.addCircle(0, -85, 66)
92 SketchLine_6 = Sketch_7.addLine(model.selection("EDGE", "PartSet/OY"))
93 SketchConstraintCoincidence_10 = Sketch_7.setCoincident(SketchCircle_7.center(), SketchLine_6.result())
94 SketchConstraintRadius_7 = Sketch_7.setRadius(SketchCircle_7.results()[1], 66)
95 SketchConstraintDistance_1 = Sketch_7.setDistance(SketchCircle_7.center(), SketchLine_6.startPoint(), 85)
96 SketchMultiRotation_1 = Sketch_7.addRotation([SketchCircle_7.results()[1]], SketchLine_6.startPoint(), 120, 3)
97 [SketchCircle_8, SketchCircle_9] = SketchMultiRotation_1.rotated()
98 model.do()
99 ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_7")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_1"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
100 Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/Modfied_1"))
101 SketchLine_7 = Sketch_8.addLine(-2.320957096353877e-016, 11.00000001704673, -7, 11.00000001704673)
102 SketchConstraintHorizontal_1 = Sketch_8.setHorizontal(SketchLine_7.result())
103 SketchLine_8 = Sketch_8.addLine(-7, 11.00000001704673, -6.329882773485103e-016, 30.00000001704673)
104 SketchConstraintCoincidence_11 = Sketch_8.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
105 SketchLine_9 = Sketch_8.addLine(model.selection("EDGE", "PartSet/OY"))
106 SketchConstraintCoincidence_12 = Sketch_8.setCoincident(SketchLine_7.startPoint(), SketchLine_9.result())
107 SketchConstraintCoincidence_13 = Sketch_8.setCoincident(SketchLine_8.endPoint(), SketchLine_9.result())
108 SketchConstraintMirror_1 = Sketch_8.addMirror(SketchLine_9.result(), [SketchLine_7.result(), SketchLine_8.result()])
109 [SketchLine_10, SketchLine_11] = SketchConstraintMirror_1.mirrored()
110 SketchConstraintLength_1 = Sketch_8.setLength(SketchLine_7.result(), 7)
111 SketchConstraintDistance_2 = Sketch_8.setDistance(SketchLine_9.startPoint(), SketchLine_7.result(), 11)
112 SketchConstraintDistance_3 = Sketch_8.setDistance(SketchLine_8.endPoint(), SketchLine_9.startPoint(), 30)
113 SketchMultiRotation_2_objects = [SketchLine_11.result(), SketchLine_10.result(), SketchLine_8.result(), SketchLine_7.result()]
114 SketchMultiRotation_2 = Sketch_8.addRotation(SketchMultiRotation_2_objects, SketchLine_9.startPoint(), 120, 3)
115 [SketchLine_11, SketchLine_12, SketchLine_13, SketchLine_10, SketchLine_14, SketchLine_15, SketchLine_16, SketchLine_17, SketchLine_18, SketchLine_19] = SketchMultiRotation_2.rotated()
116 SketchLine_18.setName("SketchLine_15")
117 SketchLine_18.result().setName("SketchLine_15")
118 SketchLine_17.setName("SketchLine_18")
119 SketchLine_17.result().setName("SketchLine_18")
120 SketchLine_16.setName("SketchLine_14")
121 SketchLine_16.result().setName("SketchLine_14")
122 SketchLine_15.setName("SketchLine_17")
123 SketchLine_15.result().setName("SketchLine_17")
124 SketchLine_14.setName("SketchLine_13")
125 SketchLine_14.result().setName("SketchLine_13")
126 SketchLine_13.setName("SketchLine_16")
127 SketchLine_13.result().setName("SketchLine_16")
128 model.do()
129 ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchLine_7r-SketchLine_8r-SketchLine_10f-SketchLine_11f"), model.selection("FACE", "Sketch_8/Face-SketchLine_16f-SketchLine_17f-SketchLine_18r-SketchLine_19r"), model.selection("FACE", "Sketch_8/Face-SketchLine_12f-SketchLine_13f-SketchLine_14r-SketchLine_15r")], model.selection(), model.selection("FACE", "ExtrusionCut_2_1/Modfied_3"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")])
130
131 # Test reexecution after parameter change
132 Parameter_R.setValue(50)
133 model.do()
134 model.testResultsVolumes(ExtrusionCut_3, [35832.402050074902945198118686676])
135 Parameter_R.setValue(40)
136 model.end()
137
138 from GeomAPI import GeomAPI_Shape
139
140 model.testNbResults(ExtrusionCut_3, 1)
141 model.testNbSubResults(ExtrusionCut_3, [0])
142 model.testNbSubShapes(ExtrusionCut_3, GeomAPI_Shape.SOLID, [1])
143 model.testNbSubShapes(ExtrusionCut_3, GeomAPI_Shape.FACE, [50])
144 model.testNbSubShapes(ExtrusionCut_3, GeomAPI_Shape.EDGE, [300])
145 model.testNbSubShapes(ExtrusionCut_3, GeomAPI_Shape.VERTEX, [600])
146 model.testResultsVolumes(ExtrusionCut_3, [34439.077343526856566313654184341])
147
148 assert(model.checkPythonDump())