Salome HOME
Copyright update 2022
[modules/shaper.git] / src / FeaturesPlugin / Test / Test2817.py
1 # Copyright (C) 2020-2022  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 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
30 SketchPoint_1 = SketchProjection_1.createdFeature()
31 SketchCircle_1 = Sketch_1.addCircle(0, 0, 30)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
33 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 30)
34 model.do()
35 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 100, 0)
36 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
37 SketchLine_1 = Sketch_2.addLine(50, 10, -50, 10)
38 SketchLine_2 = Sketch_2.addLine(-50, 10, -50, 90)
39 SketchLine_3 = Sketch_2.addLine(-50, 90, 50, 90)
40 SketchLine_4 = Sketch_2.addLine(50, 90, 50, 10)
41 SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
42 SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
43 SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
44 SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
45 SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_1.result())
46 SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_2.result())
47 SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_3.result())
48 SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_4.result())
49 SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchCircle_1"), False)
50 SketchPoint_2 = SketchProjection_2.createdFeature()
51 SketchConstraintDistance_1 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_1.result(), 10, True)
52 SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_4.result(), 50, True)
53 SketchConstraintLength_1 = Sketch_2.setLength(SketchLine_1.result(), 100)
54 SketchConstraintLength_2 = Sketch_2.setLength(SketchLine_2.result(), 80)
55 model.do()
56 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")])
57 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 12, keepSubResults = True)
58 Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("COMPOUND", "AngularCopy_1_1")], keepSubResults = True)
59 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Partition_1_1_3"))
60 SketchLine_5 = Sketch_3.addLine(50, 43.33333333333334, 35, 43.33333333333334)
61 SketchLine_6 = Sketch_3.addLine(35, 43.33333333333334, 35, 23.33333333333333)
62 SketchLine_7 = Sketch_3.addLine(35, 23.33333333333333, 50, 23.33333333333333)
63 SketchLine_8 = Sketch_3.addLine(50, 23.33333333333333, 50, 43.33333333333334)
64 SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint())
65 SketchConstraintCoincidence_7 = Sketch_3.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
66 SketchConstraintCoincidence_8 = Sketch_3.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
67 SketchConstraintCoincidence_9 = Sketch_3.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
68 SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_5.result())
69 SketchConstraintVertical_3 = Sketch_3.setVertical(SketchLine_6.result())
70 SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_7.result())
71 SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_8.result())
72 SketchLine_9 = Sketch_3.addLine(50, 76.66666666666667, 35, 76.66666666666667)
73 SketchLine_10 = Sketch_3.addLine(35, 76.66666666666667, 35, 56.66666666666666)
74 SketchLine_11 = Sketch_3.addLine(35, 56.66666666666666, 50, 56.66666666666666)
75 SketchLine_12 = Sketch_3.addLine(50, 56.66666666666666, 50, 76.66666666666667)
76 SketchConstraintCoincidence_10 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_9.startPoint())
77 SketchConstraintCoincidence_11 = Sketch_3.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
78 SketchConstraintCoincidence_12 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
79 SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
80 SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_9.result())
81 SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_10.result())
82 SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_11.result())
83 SketchConstraintVertical_6 = Sketch_3.setVertical(SketchLine_12.result())
84 SketchConstraintEqual_1 = Sketch_3.setEqual(SketchLine_8.result(), SketchLine_12.result())
85 SketchConstraintEqual_2 = Sketch_3.setEqual(SketchLine_11.result(), SketchLine_7.result())
86 SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "Partition_1_1_3/Modified_Edge&Sketch_2/SketchLine_2&Sketch_2/SketchLine_4"), False)
87 SketchLine_13 = SketchProjection_3.createdFeature()
88 SketchConstraintCoincidence_14 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_13.result())
89 SketchConstraintCoincidence_15 = Sketch_3.setCoincident(SketchLine_7.endPoint(), SketchLine_13.result())
90 SketchConstraintLength_3 = Sketch_3.setLength(SketchLine_7.result(), 15)
91 SketchConstraintLength_4 = Sketch_3.setLength(SketchLine_8.result(), 20)
92 SketchLine_14 = Sketch_3.addLine(50, 10, 50, 23.33333333333333)
93 SketchLine_14.setAuxiliary(True)
94 SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchAPI_Line(SketchLine_13).endPoint(), SketchLine_14.startPoint())
95 SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_7.endPoint(), SketchLine_14.endPoint())
96 SketchLine_15 = Sketch_3.addLine(50, 43.33333333333334, 50, 56.66666666666666)
97 SketchLine_15.setAuxiliary(True)
98 SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_5.startPoint(), SketchLine_15.startPoint())
99 SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_15.endPoint())
100 SketchLine_16 = Sketch_3.addLine(50, 76.66666666666667, 50, 90)
101 SketchLine_16.setAuxiliary(True)
102 SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_9.startPoint(), SketchLine_16.startPoint())
103 SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchAPI_Line(SketchLine_13).startPoint(), SketchLine_16.endPoint())
104 SketchConstraintEqual_3 = Sketch_3.setEqual(SketchLine_14.result(), SketchLine_15.result())
105 SketchConstraintEqual_4 = Sketch_3.setEqual(SketchLine_15.result(), SketchLine_16.result())
106 model.do()
107 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection(), 5, 5)
108 AngularCopy_2 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")], model.selection("EDGE", "PartSet/OZ"), 12, keepSubResults = True)
109 Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Partition_1_1")], [model.selection("COMPOUND", "AngularCopy_2_1"), model.selection("COMPOUND", "AngularCopy_2_2")], keepSubResults = True)
110 model.end()
111
112 from GeomAPI import *
113
114 model.testNbResults(Cut_1, 1)
115 model.testNbSubResults(Cut_1, [13])
116 model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [1])
117 model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [27])
118 model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [213])
119 model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [426])
120 model.testResultsVolumes(Cut_1, [282743.338823])
121
122 assert(model.checkPythonDump())