Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / Test / TestBooleanCut_Solid_Compound.py
1 # Copyright (C) 2014-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 ###
21 ### SHAPER component
22 ###
23
24 from salome.shaper import model
25
26 model.begin()
27 partSet = model.moduleDocument()
28
29 ### Create Part
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
32 model.addParameter(Part_1_doc, "nb", '6')
33
34 ### Create Cylinder
35 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
36
37 ### Create Sketch
38 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Cylinder_1_1/Face_3"))
39
40 ### Create SketchLine
41 SketchLine_1 = Sketch_1.addLine(-3.635759493440736, -2.855949413069177, 3.547995857301719, -2.855949413069177)
42
43 ### Create SketchProjection
44 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
45 SketchLine_2 = SketchProjection_1.createdFeature()
46
47 ### Create SketchLine
48 SketchLine_3 = Sketch_1.addLine(3.547995857301719, -2.855949413069177, 3.547995857301719, -5.405023892364889)
49
50 ### Create SketchLine
51 SketchLine_4 = Sketch_1.addLine(3.547995857301719, -5.405023892364889, -3.635759493440736, -5.405023892364889)
52
53 ### Create SketchLine
54 SketchLine_5 = Sketch_1.addLine(-3.635759493440736, -5.405023892364889, -3.635759493440736, -2.855949413069177)
55 Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_1.startPoint())
56 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
57 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
58 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
59
60 ### Create SketchLine
61 SketchLine_6 = Sketch_1.addLine(-3.635759493440736, -2.855949413069177, 3.547995857301719, -5.405023892364889)
62 SketchLine_6.setAuxiliary(True)
63
64 ### Create SketchLine
65 SketchLine_7 = Sketch_1.addLine(3.547995857301719, -2.855949413069177, -3.635759493440736, -5.405023892364889)
66 SketchLine_7.setAuxiliary(True)
67 Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.startPoint())
68 Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_7.startPoint())
69 Sketch_1.setCoincident(SketchLine_4.startPoint(), SketchLine_6.endPoint())
70 Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_7.endPoint())
71 Sketch_1.setHorizontal(SketchLine_1.result())
72 Sketch_1.setVertical(SketchLine_3.result())
73 Sketch_1.setHorizontal(SketchLine_4.result())
74 Sketch_1.setVertical(SketchLine_5.result())
75 model.do()
76
77 ### Create Extrusion
78 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_1r")], model.selection(), 1, 11, "Faces|Wires")
79
80 ### Create AngularCopy
81 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OZ"), "nb", keepSubResults = True)
82
83 ### Create Cut
84 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], [model.selection("COMPOUND", "AngularCopy_1_1")], keepSubResults = True)
85
86 model.do()
87 model.end()
88
89 model.testResults(Cut_1, 1, [0], [1], [8], [18], [12])
90 model.testResultsVolumes(Cut_1, [282.54761399726])