Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / Test / TestBooleanSplit_MultiLevelCompound_v0_2.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 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("EDGE", "PartSet/OX"), False)
30 SketchLine_1 = SketchProjection_1.createdFeature()
31 SketchCircle_1 = Sketch_1.addCircle(0, 0, 10)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_1).startPoint(), SketchCircle_1.center())
33 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 10)
34 SketchCircle_2 = Sketch_1.addCircle(10, 0, 10)
35 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_2.center())
36 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchCircle_1.results()[1], SketchCircle_2.results()[1])
37 SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchCircle_2.center(), 10)
38 model.do()
39 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 20, 0)
40 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
41 SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False)
42 SketchLine_2 = SketchProjection_2.createdFeature()
43 SketchCircle_3 = Sketch_2.addCircle(0, -7, 10)
44 SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_2.result(), SketchCircle_3.center())
45 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_3.results()[1], 10)
46 SketchConstraintDistanceVertical_1 = Sketch_2.setVerticalDistance(SketchCircle_3.center(), SketchAPI_Line(SketchLine_2).startPoint(), 7)
47 SketchCircle_4 = Sketch_2.addCircle(40, -27, 10)
48 SketchConstraintEqual_2 = Sketch_2.setEqual(SketchCircle_4.results()[1], SketchCircle_3.results()[1])
49 SketchConstraintDistanceHorizontal_2 = Sketch_2.setHorizontalDistance(SketchCircle_3.center(), SketchCircle_4.center(), 40)
50 SketchConstraintDistanceVertical_2 = Sketch_2.setVerticalDistance(SketchCircle_4.center(), SketchCircle_3.center(), 20)
51 model.do()
52 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), 20, 0)
53 Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")])
54 Compound_2 = model.addCompound(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPSOLID", "Extrusion_1_1")])
55 Compound_2.result().subResult(0).setColor(255, 170, 0)
56 Compound_2.result().subResult(0).subResult(0).setColor(255, 170, 0)
57 Compound_2.result().subResult(0).subResult(1).setColor(255, 170, 0)
58 Compound_2.result().subResult(1).setColor(0, 85, 255)
59 Compound_2.result().subResult(1).subResult(0).setColor(0, 85, 255)
60 Compound_2.result().subResult(1).subResult(1).setColor(0, 85, 255)
61 Compound_2.result().subResult(1).subResult(2).setColor(0, 85, 255)
62 Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
63 SketchLine_3 = Sketch_3.addLine(7, 0, -7, 0)
64 SketchLine_4 = Sketch_3.addLine(-7, 0, -7, 5)
65 SketchLine_5 = Sketch_3.addLine(-7, 5, 7, 5)
66 SketchLine_6 = Sketch_3.addLine(7, 5, 7, 0)
67 SketchConstraintCoincidence_4 = Sketch_3.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
68 SketchConstraintCoincidence_5 = Sketch_3.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
69 SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
70 SketchConstraintCoincidence_7 = Sketch_3.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
71 SketchConstraintHorizontal_1 = Sketch_3.setHorizontal(SketchLine_3.result())
72 SketchConstraintVertical_1 = Sketch_3.setVertical(SketchLine_4.result())
73 SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_5.result())
74 SketchConstraintVertical_2 = Sketch_3.setVertical(SketchLine_6.result())
75 SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
76 SketchLine_7 = SketchProjection_3.createdFeature()
77 SketchConstraintDistance_1 = Sketch_3.setDistance(SketchLine_5.endPoint(), SketchLine_7.result(), 7, True)
78 SketchConstraintMiddle_1 = Sketch_3.setMiddlePoint(SketchAPI_Line(SketchLine_7).startPoint(), SketchLine_3.result())
79 SketchConstraintLength_1 = Sketch_3.setLength(SketchLine_4.result(), 5)
80 SketchLine_8 = Sketch_3.addLine(7, 7, -7.000000000000001, 7)
81 SketchLine_9 = Sketch_3.addLine(-7.000000000000001, 7, -7.000000000000001, 10)
82 SketchLine_10 = Sketch_3.addLine(-7.000000000000001, 10, 7, 10)
83 SketchLine_11 = Sketch_3.addLine(7, 10, 7, 7)
84 SketchConstraintCoincidence_8 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_8.startPoint())
85 SketchConstraintCoincidence_9 = Sketch_3.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
86 SketchConstraintCoincidence_10 = Sketch_3.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
87 SketchConstraintCoincidence_11 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
88 SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_8.result())
89 SketchConstraintVertical_3 = Sketch_3.setVertical(SketchLine_9.result())
90 SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_10.result())
91 SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_11.result())
92 SketchConstraintCoincidence_12 = Sketch_3.setCoincident(SketchLine_9.startPoint(), SketchLine_4.result())
93 SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_8.startPoint(), SketchLine_6.result())
94 SketchConstraintLength_2 = Sketch_3.setLength(SketchLine_9.result(), 3)
95 SketchConstraintDistance_2 = Sketch_3.setDistance(SketchLine_9.startPoint(), SketchLine_5.result(), 2, True)
96 model.do()
97 Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")], model.selection(), 50, -10)
98 Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_11r-SketchLine_10r-SketchLine_9r-SketchLine_8r")], model.selection(), 60, 20)
99 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_4_1")], model.selection("EDGE", "PartSet/OZ"), 90, 2)
100 Compound_3 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_3_1"), model.selection("COMPOUND", "AngularCopy_1_1")])
101 Compound_3.result().subResult(0).setColor(0, 170, 0)
102 Compound_3.result().subResult(1).setColor(0, 255, 0)
103 Compound_3.result().subResult(1).subResult(0).setColor(0, 255, 0)
104 Compound_3.result().subResult(1).subResult(1).setColor(0, 255, 0)
105 Split_1 = model.addSplit(Part_1_doc, [model.selection("SOLID", "Compound_2_1_1_1"), model.selection("SOLID", "Compound_2_1_2_3")], [model.selection("COMPOUND", "Compound_3_1_2")])
106
107 model.testHaveNamingSubshapes(Split_1, model, Part_1_doc)
108
109 model.end()
110
111 from GeomAPI import GeomAPI_Shape
112
113 model.testNbResults(Split_1, 2)
114 model.testNbSubResults(Split_1, [5, 7])
115 model.testNbSubShapes(Split_1, GeomAPI_Shape.SOLID, [5, 7])
116 model.testNbSubShapes(Split_1, GeomAPI_Shape.FACE, [37, 56])
117 model.testNbSubShapes(Split_1, GeomAPI_Shape.EDGE, [148, 250])
118 model.testNbSubShapes(Split_1, GeomAPI_Shape.VERTEX, [296, 500])
119 model.testResultsVolumes(Split_1, [6283.185307174889203452, 10109.63121762967239192])
120
121 assert(model.checkPythonDump())