Salome HOME
d96c09f3a18923ea50f958f123d6e4314c1bb38f
[modules/shaper.git] / src / FeaturesPlugin / Test / Test19196.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 model.addParameter(Part_1_doc, "r_ext", "80")
30 model.addParameter(Part_1_doc, "r_int", "60")
31 model.addParameter(Part_1_doc, "r_cut", "30")
32 model.addParameter(Part_1_doc, "h", "200")
33 ParamSize = model.addParameter(Part_1_doc, "size", "r_int*3/4")
34 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r_int", "h")
35 Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r_ext", "h")
36 Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r_ext")
37 Sphere_2 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r_int")
38 Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Sphere_1_1")], axis = model.selection("EDGE", "PartSet/OY"), angle = 90, keepSubResults = True)
39 Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Sphere_2_1")], axis = model.selection("EDGE", "PartSet/OY"), angle = 90, keepSubResults = True)
40 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Rotation_1_1"), model.selection("SOLID", "Rotation_2_1")], axis = model.selection("EDGE", "PartSet/OZ"), distance = "h", keepSubResults = True)
41 Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1"), model.selection("SOLID", "Translation_1_2")], removeEdges = True, keepSubResults = True)
42 Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cylinder_2_1"), model.selection("SOLID", "Translation_1_1")], removeEdges = True, keepSubResults = True)
43 Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Fuse_1_1"), model.selection("SOLID", "Fuse_2_1")], keepSubResults = True)
44 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
45 SketchLine_1 = Sketch_1.addLine(0, 124.9999999998943, 0, 45.00000000000152)
46 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
47 SketchLine_2 = SketchProjection_1.createdFeature()
48 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.result())
49 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
50 SketchLine_3 = Sketch_1.addLine(0, 45.00000000000152, -45, 0)
51 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
52 SketchLine_4 = Sketch_1.addLine(-45, 0, 0, -45.00000000000152)
53 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
54 SketchLine_5 = Sketch_1.addLine(0, -45.00000000000152, 44.99999999998636, 0)
55 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
56 SketchLine_6 = Sketch_1.addLine(44.99999999998636, 0, 0, 45.00000000000152)
57 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
58 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_6.endPoint())
59 SketchLine_7 = Sketch_1.addLine(0, -45.00000000000152, 0, -124.9999999997331)
60 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_7.startPoint())
61 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_7.result())
62 SketchLine_8 = Sketch_1.addLine(-45, 0, -125, 0)
63 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_8.startPoint())
64 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_8.result())
65 SketchLine_9 = Sketch_1.addLine(44.99999999998636, 0, 124.9999999999994, 0)
66 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
67 SketchLine_10 = SketchProjection_2.createdFeature()
68 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.result())
69 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_9.startPoint())
70 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_10.result())
71 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchLine_10.result())
72 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_2.result())
73 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_3.result(), SketchLine_5.result())
74 SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_4.result(), SketchLine_6.result())
75 SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_3.result(), SketchLine_4.result())
76 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_8.result(), "r_ext")
77 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_8.startPoint(), SketchLine_7.result(), "size", True)
78 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_8.result(), SketchLine_1.result())
79 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_9.result())
80 SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_7.result(), SketchLine_9.result())
81 model.do()
82 Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_8"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_7"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_9"), model.selection("EDGE", "Sketch_1/SketchLine_6"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_1")]
83 Wire_1 = model.addWire(Part_1_doc, Wire_1_objects, False)
84 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), "h", 0)
85 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), "h", False)
86 Split_1 = model.addSplit(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], [model.selection("FACE", "Plane_1"), model.selection("SHELL", "Extrusion_1_1")], keepSubResults = True)
87 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Split_1_1_7/Modified_Face&Plane_1/Plane_1&new_weak_name_3"))
88 SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "Extrusion_1_1/To_Edge_2"), True)
89 SketchLine_11 = SketchProjection_3.createdFeature()
90 SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Extrusion_1_1/To_Edge_5"), True)
91 SketchLine_12 = SketchProjection_4.createdFeature()
92 SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "Extrusion_1_1/To_Edge_6"), True)
93 SketchLine_13 = SketchProjection_5.createdFeature()
94 SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "Extrusion_1_1/To_Edge_3"), True)
95 SketchLine_14 = SketchProjection_6.createdFeature()
96 model.do()
97 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), "r_cut/sqrt(2)", 0)
98 Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
99 SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "Split_1_1_3/Modified_Edge&Extrusion_1_1/To_Edge_4"), True)
100 SketchLine_15 = SketchProjection_7.createdFeature()
101 SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Split_1_1_9/Modified_Edge&Extrusion_1_1/To_Edge_4"), True)
102 SketchLine_16 = SketchProjection_8.createdFeature()
103 SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_3][Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_4]"), True)
104 SketchLine_17 = SketchProjection_9.createdFeature()
105 SketchLine_18 = Sketch_3.addLine(-45.00000000000152, 221.2132034355964, -99.71358592313776, 275.9267893638306)
106 SketchLine_19 = Sketch_3.addLine(-99.71358592313776, 275.9267893638306, -80, 200)
107 SketchConstraintCoincidence_14 = Sketch_3.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint())
108 SketchConstraintCoincidence_15 = Sketch_3.setCoincident(SketchAPI_Line(SketchLine_16).endPoint(), SketchLine_19.endPoint())
109 SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchLine_18.startPoint(), SketchAPI_Line(SketchLine_17).endPoint())
110 SketchConstraintAngle_1 = Sketch_3.setAngle(SketchLine_18.result(), SketchLine_16.result(), 45, type = "")
111 model.do()
112 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchProjection_9f-SketchLine_18f-SketchLine_19f-SketchProjection_8r-SketchProjection_7r")])
113 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 4, keepSubResults = True)
114 Plane_5 = model.addPlane(Part_1_doc, model.selection("VERTEX", "AngularCopy_1_1_1/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_9_EndVertex"))
115 Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2"))
116 SketchLine_20 = Sketch_4.addLine(-71.93873905691365, 265.6178566586798, -194.0624420262377, 195.1097038792864)
117 SketchProjection_10 = Sketch_4.addProjection(model.selection("VERTEX", "Sketch_3/SketchLine_18_EndVertex"), False)
118 SketchPoint_1 = SketchProjection_10.createdFeature()
119 SketchConstraintCoincidence_17 = Sketch_4.setCoincident(SketchLine_20.startPoint(), SketchPoint_1.result())
120 SketchProjection_11 = Sketch_4.addProjection(model.selection("VERTEX", "AngularCopy_1_1_4/MV:Rotated&Sketch_3/SketchLine_19_StartVertex&Sketch_3/SketchLine_18_EndVertex"), False)
121 SketchPoint_2 = SketchProjection_11.createdFeature()
122 SketchConstraintCoincidence_18 = Sketch_4.setCoincident(SketchLine_20.endPoint(), SketchPoint_2.result())
123 SketchProjection_12 = Sketch_4.addProjection(model.selection("EDGE", "Sketch_3/SketchLine_18"), True)
124 SketchLine_21 = SketchProjection_12.createdFeature()
125 SketchProjection_13 = Sketch_4.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_3][Extrusion_2_1/To_Face]"), True)
126 SketchLine_22 = SketchProjection_13.createdFeature()
127 SketchProjection_14 = Sketch_4.addProjection(model.selection("EDGE", "AngularCopy_1_1_4/ME:Rotated&Sketch_3/SketchLine_18"), True)
128 SketchLine_23 = SketchProjection_14.createdFeature()
129 model.do()
130 Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchLine_20r-SketchProjection_14r-SketchProjection_13f-SketchProjection_12f")])
131 AngularCopy_2 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), 4, keepSubResults = True)
132 Split_2_objects_2 = [model.selection("SOLID", "Extrusion_2_1"), model.selection("COMPOUND", "AngularCopy_1_1"), model.selection("COMPOUND", "AngularCopy_2_1")]
133 Split_2 = model.addSplit(Part_1_doc, [model.selection("COMPSOLID", "Split_1_1")], Split_2_objects_2, keepSubResults = True)
134 Group_1_objects = [model.selection("FACE", "Split_2_1_7/Modified_Face&Cylinder_1_1/Face_1"), model.selection("FACE", "Split_2_1_8/Modified_Face&Cylinder_1_1/Face_1"), model.selection("FACE", "Split_2_1_9/Modified_Face&Cylinder_1_1/Face_1"), model.selection("FACE", "Split_2_1_10/Modified_Face&Cylinder_1_1/Face_1")]
135 Group_1 = model.addGroup(Part_1_doc, "Faces", Group_1_objects)
136 Group_1.setName("shared_face_cyl")
137 Group_1.result().setName("shared_face_cyl")
138 model.end()
139
140 model.testNbResults(Split_2, 1)
141 model.testNbSubResults(Split_2, [20])
142 model.testNbSubShapes(Split_2, GeomAPI_Shape.SOLID, [20])
143 model.testNbSubShapes(Split_2, GeomAPI_Shape.FACE, [120])
144 model.testNbSubShapes(Split_2, GeomAPI_Shape.EDGE, [492])
145 model.testNbSubShapes(Split_2, GeomAPI_Shape.VERTEX, [984])
146 model.testResultsVolumes(Split_2, [5093568.888962713])
147
148 model.begin()
149 ParamSize.expression().setValue("r_int/2")
150 model.end()
151
152 model.testNbResults(Split_2, 1)
153 model.testNbSubResults(Split_2, [20])
154 model.testNbSubShapes(Split_2, GeomAPI_Shape.SOLID, [20])
155 model.testNbSubShapes(Split_2, GeomAPI_Shape.FACE, [120])
156 model.testNbSubShapes(Split_2, GeomAPI_Shape.EDGE, [492])
157 model.testNbSubShapes(Split_2, GeomAPI_Shape.VERTEX, [984])
158 model.testResultsVolumes(Split_2, [5093568.888962713])
159
160 assert(model.checkPythonDump())