Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / Test / TestUnion_MultiLevelCompound_v0.py
1 # Copyright (C) 2014-2023  CEA, EDF
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 SketchLine_1 = Sketch_1.addLine(25, -25, -25, -25)
30 SketchLine_2 = Sketch_1.addLine(-25, -25, -25, 25)
31 SketchLine_3 = Sketch_1.addLine(-25, 25, 25, 25)
32 SketchLine_4 = Sketch_1.addLine(25, 25, 25, -25)
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
34 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
35 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
36 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
37 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
38 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
39 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
40 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
41 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_2.result())
42 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 50)
43 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
44 SketchPoint_1 = SketchProjection_1.createdFeature()
45 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.result(), 25, True)
46 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_2.result(), 25, True)
47 SketchMultiRotation_1_objects = [SketchLine_1.result(), SketchLine_2.result(), SketchLine_3.result(), SketchLine_4.result()]
48 SketchMultiRotation_1 = Sketch_1.addRotation(SketchMultiRotation_1_objects, SketchAPI_Point(SketchPoint_1).coordinates(), 45, 2, True)
49 [SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8] = SketchMultiRotation_1.rotated()
50 SketchLine_8.setName("SketchLine_14")
51 SketchLine_8.result().setName("SketchLine_14")
52 SketchLine_7.setName("SketchLine_11")
53 SketchLine_7.result().setName("SketchLine_11")
54 SketchLine_6.setName("SketchLine_8")
55 SketchLine_6.result().setName("SketchLine_8")
56 SketchCircle_1 = Sketch_1.addCircle(80, 0, 20)
57 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 20)
58 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
59 SketchLine_9 = SketchProjection_2.createdFeature()
60 SketchLine_9.setName("SketchLine_9")
61 SketchLine_9.result().setName("SketchLine_9")
62 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_9.result())
63 SketchConstraintDistance_3 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_9).startPoint(), SketchCircle_1.center(), 80, True)
64 SketchMultiRotation_2 = Sketch_1.addRotation([SketchCircle_1.results()[1]], SketchAPI_Line(SketchLine_9).startPoint(), 360, 8, True)
65 [SketchCircle_2, SketchCircle_3, SketchCircle_4, SketchCircle_5, SketchCircle_6, SketchCircle_7, SketchCircle_8] = SketchMultiRotation_2.rotated()
66 model.do()
67 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 50, 0)
68 Compound_1_objects = [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3"), model.selection("SOLID", "Extrusion_1_4"), model.selection("SOLID", "Extrusion_1_5"), model.selection("SOLID", "Extrusion_1_6"), model.selection("SOLID", "Extrusion_1_7"), model.selection("SOLID", "Extrusion_1_8"), model.selection("SOLID", "Extrusion_1_9")]
69 Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
70 Union_1_objects = [model.selection("SOLID", "Compound_1_1_1_1"), model.selection("SOLID", "Compound_1_1_1_2"), model.selection("SOLID", "Compound_1_1_1_3")]
71 Union_1 = model.addUnion(Part_1_doc, Union_1_objects)
72
73 model.testHaveNamingSubshapes(Union_1, model, Part_1_doc)
74
75 model.end()
76
77 from GeomAPI import GeomAPI_Shape
78
79 model.testNbResults(Union_1, 1)
80 model.testNbSubResults(Union_1, [7])
81 model.testNbSubShapes(Union_1, GeomAPI_Shape.SOLID, [7])
82 model.testNbSubShapes(Union_1, GeomAPI_Shape.FACE, [46])
83 model.testNbSubShapes(Union_1, GeomAPI_Shape.EDGE, [176])
84 model.testNbSubShapes(Union_1, GeomAPI_Shape.VERTEX, [352])
85 model.testResultsVolumes(Union_1, [146446.6094067262311])
86
87 assert(model.checkPythonDump())