1 # Copyright (C) 2020-2022 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from salome.shaper import model
23 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
30 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
33 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
36 SketchLine_1 = Sketch_1.addLine(7.071067811865538, 2.928932188134462, 2.928932188134676, 2.928932188134462)
39 SketchLine_2 = Sketch_1.addLine(2.928932188134676, 2.928932188134462, 2.928932188134676, 7.071067811865324)
42 SketchLine_3 = Sketch_1.addLine(2.928932188134676, 7.071067811865324, 7.071067811865538, 7.071067811865324)
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())
56 SketchLine_5 = Sketch_1.addLine(0, 0, 2.928932188134676, 2.928932188134462)
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())
65 SketchLine_6 = Sketch_1.addLine(10, 0, 7.071067811865538, 2.928932188134462)
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())
74 SketchLine_7 = Sketch_1.addLine(10, 10, 7.071067811865538, 7.071067811865324)
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())
83 SketchLine_8 = Sketch_1.addLine(0, 10, 2.928932188134676, 7.071067811865324)
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())
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")
100 Split_1 = model.addSplit(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "Revolution_1_1")], keepSubResults = True)
104 from GeomAPI import *
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])
114 assert(model.checkPythonDump())