Salome HOME
2e9f9eb40c2071bf769f73547371e81aed27360e
[modules/shaper.git] / src / FeaturesPlugin / Test / Test20245_2.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 salome.shaper import model
21
22 model.begin()
23 partSet = model.moduleDocument()
24
25 ### Create Part
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28
29 ### Create Box
30 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
31
32 ### Create Sketch
33 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
34
35 ### Create SketchLine
36 SketchLine_1 = Sketch_1.addLine(7.071067811865538, 2.928932188134462, 2.928932188134676, 2.928932188134462)
37
38 ### Create SketchLine
39 SketchLine_2 = Sketch_1.addLine(2.928932188134676, 2.928932188134462, 2.928932188134676, 7.071067811865324)
40
41 ### Create SketchLine
42 SketchLine_3 = Sketch_1.addLine(2.928932188134676, 7.071067811865324, 7.071067811865538, 7.071067811865324)
43
44 ### Create SketchLine
45 SketchLine_4 = Sketch_1.addLine(7.071067811865538, 7.071067811865324, 7.071067811865538, 2.928932188134462)
46 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
47 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
48 Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
49 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
50 Sketch_1.setHorizontal(SketchLine_1.result())
51 Sketch_1.setVertical(SketchLine_2.result())
52 Sketch_1.setHorizontal(SketchLine_3.result())
53 Sketch_1.setVertical(SketchLine_4.result())
54
55 ### Create SketchLine
56 SketchLine_5 = Sketch_1.addLine(0, 0, 2.928932188134676, 2.928932188134462)
57
58 ### Create SketchProjection
59 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), False)
60 SketchPoint_1 = SketchProjection_1.createdFeature()
61 Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchPoint_1.result())
62 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.endPoint())
63
64 ### Create SketchLine
65 SketchLine_6 = Sketch_1.addLine(10, 0, 7.071067811865538, 2.928932188134462)
66
67 ### Create SketchProjection
68 SketchProjection_2 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]"), False)
69 SketchPoint_2 = SketchProjection_2.createdFeature()
70 Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchPoint_2.result())
71 Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint())
72
73 ### Create SketchLine
74 SketchLine_7 = Sketch_1.addLine(10, 10, 7.071067811865538, 7.071067811865324)
75
76 ### Create SketchProjection
77 SketchProjection_3 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]"), False)
78 SketchPoint_3 = SketchProjection_3.createdFeature()
79 Sketch_1.setCoincident(SketchLine_7.startPoint(), SketchPoint_3.result())
80 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_7.endPoint())
81
82 ### Create SketchLine
83 SketchLine_8 = Sketch_1.addLine(0, 10, 2.928932188134676, 7.071067811865324)
84
85 ### Create SketchProjection
86 SketchProjection_4 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]"), False)
87 SketchPoint_4 = SketchProjection_4.createdFeature()
88 Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchPoint_4.result())
89 Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_8.endPoint())
90 Sketch_1.setEqual(SketchLine_4.result(), SketchLine_3.result())
91 Sketch_1.setEqual(SketchLine_5.result(), SketchLine_6.result())
92 Sketch_1.setEqual(SketchLine_6.result(), SketchLine_7.result())
93 Sketch_1.setEqual(SketchLine_5.result(), SketchLine_2.result())
94 model.do()
95
96 ### Create Revolution
97 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), 0, 90, "Edges")
98
99 ### Create Split
100 Split_1 = model.addSplit(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "Revolution_1_1")], keepSubResults = True)
101
102 model.end()
103
104 from GeomAPI import *
105
106 model.testNbResults(Split_1, 1)
107 model.testNbSubResults(Split_1, [5])
108 model.testNbSubShapes(Split_1, GeomAPI_Shape.SOLID, [5])
109 model.testNbSubShapes(Split_1, GeomAPI_Shape.FACE, [32])
110 model.testNbSubShapes(Split_1, GeomAPI_Shape.EDGE, [124])
111 model.testNbSubShapes(Split_1, GeomAPI_Shape.VERTEX, [248])
112 model.testResultsVolumes(Split_1, [1000])
113
114 assert(model.checkPythonDump())