Salome HOME
84f0002bc8a1a83af45e58e718690f6a48a88439
[modules/shaper.git] / src / FeaturesPlugin / Test / Test20245_1.py
1 # Copyright (C) 2020-2021  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 SketchAPI import *
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26
27 ### Create Part
28 Part_1 = model.addPart(partSet)
29 Part_1_doc = Part_1.document()
30 model.addParameter(Part_1_doc, "r_ext", "80")
31 model.addParameter(Part_1_doc, "r_int", "60")
32 model.addParameter(Part_1_doc, "r_cut", "30")
33 model.addParameter(Part_1_doc, "h", "200")
34
35 ### Create Cylinder
36 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r_ext", "h")
37
38 ### Create Cylinder
39 Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r_int", "h")
40
41 ### Create Sphere
42 Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r_ext")
43
44 ### Create Sphere
45 Sphere_2 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r_int")
46
47 ### Create Rotation
48 Rotation_1 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-Sphere_1")], axis = model.selection("EDGE", "PartSet/OY"), angle = 90, keepSubResults = True)
49
50 ### Create Rotation
51 Rotation_2 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-Sphere_2")], axis = model.selection("EDGE", "PartSet/OY"), angle = 90, keepSubResults = True)
52
53 ### Create Translation
54 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Rotation_1_1"), model.selection("COMPOUND", "Rotation_2_1")], axis = model.selection("EDGE", "PartSet/OZ"), distance = "h", keepSubResults = True)
55
56 ### Create Fuse
57 Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Translation_1_1_1"), model.selection("SOLID", "Cylinder_1_1")], keepSubResults = True)
58
59 ### Create Fuse
60 Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cylinder_2_1"), model.selection("SOLID", "Translation_1_2_1")], keepSubResults = True)
61
62 ### Create Partition
63 Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Fuse_1_1"), model.selection("SOLID", "Fuse_2_1")], keepSubResults = True)
64
65 ### Create Sketch
66 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
67
68 ### Create SketchLine
69 SketchLine_1 = Sketch_1.addLine(0, 30, -30, 0)
70
71 ### Create SketchProjection
72 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
73 SketchLine_2 = SketchProjection_1.createdFeature()
74 Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result())
75
76 ### Create SketchLine
77 SketchLine_3 = Sketch_1.addLine(-30, 0, 0, -30)
78 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
79
80 ### Create SketchLine
81 SketchLine_4 = Sketch_1.addLine(0, -30, 30, 0)
82 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
83
84 ### Create SketchProjection
85 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
86 SketchLine_5 = SketchProjection_2.createdFeature()
87 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.result())
88
89 ### Create SketchLine
90 SketchLine_6 = Sketch_1.addLine(30, 0, 0, 30)
91 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_6.startPoint())
92 Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint())
93
94 ### Create SketchLine
95 SketchLine_7 = Sketch_1.addLine(-30, 0, -110, 0)
96 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_7.startPoint())
97 Sketch_1.setHorizontal(SketchLine_7.result())
98
99 ### Create SketchLine
100 SketchLine_8 = Sketch_1.addLine(0, -30, 0, -110)
101 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_8.startPoint())
102 Sketch_1.setVertical(SketchLine_8.result())
103
104 ### Create SketchLine
105 SketchLine_9 = Sketch_1.addLine(0, 30, 0, 110)
106 Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_9.startPoint())
107 Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_2.result())
108
109 ### Create SketchLine
110 SketchLine_10 = Sketch_1.addLine(30, 0, 110, 0)
111 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_10.startPoint())
112 Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_5.result())
113 Sketch_1.setEqual(SketchLine_10.result(), SketchLine_7.result())
114 Sketch_1.setEqual(SketchLine_9.result(), SketchLine_8.result())
115 Sketch_1.setParallel(SketchLine_1.result(), SketchLine_4.result())
116 Sketch_1.setParallel(SketchLine_6.result(), SketchLine_3.result())
117 Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchLine_2.result())
118 Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_3.result())
119 Sketch_1.setLength(SketchLine_7.result(), "r_ext")
120 Sketch_1.setDistance(SketchLine_7.startPoint(), SketchLine_2.result(), "r_int/2", True)
121 Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_5.result())
122 Sketch_1.setEqual(SketchLine_9.result(), SketchLine_10.result())
123 model.do()
124
125 ### Create Extrusion
126 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), "h", 0, "Edges")
127
128 ### Create Plane
129 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), "h", False)
130
131 ### Create Split
132 Split_1 = model.addSplit(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], [model.selection("FACE", "Plane_1"), model.selection("COMPOUND", "Extrusion_1_1")], keepSubResults = True)
133
134 ### Create Sketch
135 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
136
137 ### Create SketchProjection
138 SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_10/Modified_Edge&Extrusion_1_1_1/To_Edge"), True)
139 SketchLine_11 = SketchProjection_3.createdFeature()
140
141 ### Create SketchProjection
142 SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_9/Modified_Edge&Extrusion_1_1_4/To_Edge"), True)
143 SketchLine_12 = SketchProjection_4.createdFeature()
144
145 ### Create SketchProjection
146 SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_8/Modified_Edge&Extrusion_1_1_3/To_Edge"), True)
147 SketchLine_13 = SketchProjection_5.createdFeature()
148
149 ### Create SketchProjection
150 SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_7/Modified_Edge&Extrusion_1_1_2/To_Edge"), True)
151 SketchLine_14 = SketchProjection_6.createdFeature()
152 model.do()
153
154 ### Create Extrusion
155 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), "r_cut/sqrt(2)", 0, "Faces|Wires")
156
157 ### Create Sketch
158 Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
159
160 ### Create SketchProjection
161 SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_6][Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_5]"), True)
162 SketchLine_15 = SketchProjection_7.createdFeature()
163
164 ### Create SketchProjection
165 SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Split_1_1_7/Modified_Edge&Extrusion_1_1_6/To_Edge"), True)
166 SketchLine_16 = SketchProjection_8.createdFeature()
167
168 ### Create SketchProjection
169 SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Split_1_1_2/Modified_Edge&Extrusion_1_1_6/To_Edge"), True)
170 SketchLine_17 = SketchProjection_9.createdFeature()
171
172 ### Create SketchLine
173 SketchLine_18 = Sketch_3.addLine(-30, 221.2132034355964, -136.4686528504195, 327.681856286016)
174 Sketch_3.setCoincident(SketchAPI_Line(SketchLine_15).endPoint(), SketchLine_18.startPoint())
175
176 ### Create SketchLine
177 SketchLine_19 = Sketch_3.addLine(-136.4686528504195, 327.681856286016, -80, 200)
178 Sketch_3.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint())
179 Sketch_3.setCoincident(SketchAPI_Line(SketchLine_17).endPoint(), SketchLine_19.endPoint())
180
181 ### Create SketchConstraintAngle
182 Sketch_3.setAngle(SketchLine_15.result(), SketchLine_18.result(), 135, type = "Direct")
183 model.do()
184
185 ### Create Face
186 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchProjection_7r-SketchLine_18f-SketchLine_19f-SketchProjection_9r-SketchProjection_8r")])
187
188 ### Create AngularCopy
189 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 4, keepSubResults = True)
190
191 ### Create Plane
192 Plane_5 = model.addPlane(Part_1_doc, model.selection("VERTEX", "AngularCopy_1_1_3/MV:Rotated&Sketch_3/SketchLine_19_StartVertex&Sketch_3/SketchLine_18_EndVertex"), model.selection("VERTEX", "AngularCopy_1_1_4/MV:Rotated&Sketch_3/SketchLine_19_StartVertex&Sketch_3/SketchLine_18_EndVertex"), model.selection("VERTEX", "AngularCopy_1_1_4/MV:Rotated&Sketch_3/SketchLine_18_StartVertex&Sketch_3/SketchProjection_7_EndVertex"))
193
194 ### Create Sketch
195 Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2"))
196
197 ### Create SketchProjection
198 SketchProjection_10 = Sketch_4.addProjection(model.selection("EDGE", "AngularCopy_1_1_3/ME:Rotated&Sketch_3/SketchLine_18"), True)
199 SketchLine_20 = SketchProjection_10.createdFeature()
200
201 ### Create SketchProjection
202 SketchProjection_11 = Sketch_4.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_3][Extrusion_2_1/To_Face]"), True)
203 SketchLine_21 = SketchProjection_11.createdFeature()
204
205 ### Create SketchProjection
206 SketchProjection_12 = Sketch_4.addProjection(model.selection("EDGE", "AngularCopy_1_1_4/ME:Rotated&Sketch_3/SketchLine_18"), True)
207 SketchLine_22 = SketchProjection_12.createdFeature()
208
209 ### Create SketchLine
210 SketchLine_23 = Sketch_4.addLine(-245.2017461009716, 231.7060626516377, -78.06246341670106, 328.2039725015621)
211 Sketch_4.setCoincident(SketchAPI_Line(SketchLine_22).endPoint(), SketchLine_23.startPoint())
212 Sketch_4.setCoincident(SketchAPI_Line(SketchLine_20).endPoint(), SketchLine_23.endPoint())
213 model.do()
214
215 ### Create Face
216 Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchProjection_10r-SketchLine_23r-SketchProjection_12r-SketchProjection_11r")])
217
218 ### Create AngularCopy
219 AngularCopy_2 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), 4, keepSubResults = True)
220
221 ### Create Split
222 Split_2_objects_2 = [model.selection("COMPOUND", "AngularCopy_1_1"),
223                      model.selection("COMPOUND", "AngularCopy_2_1"),
224                      model.selection("SOLID", "Extrusion_2_1")]
225 Split_2 = model.addSplit(Part_1_doc, [model.selection("COMPSOLID", "Split_1_1")], Split_2_objects_2, keepSubResults = True)
226
227 ### Create Group
228 Group_1_objects = [model.selection("FACE", "Split_2_1_16/Modified_Face&Cylinder_2_1/Face_1"),
229                    model.selection("FACE", "Split_2_1_17/Modified_Face&Cylinder_2_1/Face_1"),
230                    model.selection("FACE", "Split_2_1_18/Modified_Face&Cylinder_2_1/Face_1"),
231                    model.selection("FACE", "Split_2_1_19/Modified_Face&Cylinder_2_1/Face_1")]
232 Group_1 = model.addGroup(Part_1_doc, "Faces", Group_1_objects)
233 Group_1.setName("shared_face_cyl")
234 Group_1.result().setName("shared_face_cyl")
235
236 model.end()
237
238 from GeomAPI import *
239
240 model.testNbResults(Split_2, 1)
241 model.testNbSubResults(Split_2, [20])
242 model.testNbSubShapes(Split_2, GeomAPI_Shape.SOLID, [20])
243 model.testNbSubShapes(Split_2, GeomAPI_Shape.FACE, [120])
244 model.testNbSubShapes(Split_2, GeomAPI_Shape.EDGE, [492])
245 model.testNbSubShapes(Split_2, GeomAPI_Shape.VERTEX, [984])
246 model.testResultsVolumes(Split_2, [5093568.889])
247
248 assert(model.checkPythonDump())