Salome HOME
040746700149f8d1c6a103810e80667ad8832f53
[modules/shaper.git] / test.API / SHAPER / Transformations / TestMultiRotation.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 Test case for MultiRotation feature.
22 Written on High API.
23 """
24
25 from salome.shaper import model
26
27 model.begin()
28 partSet = model.moduleDocument()
29 Part_1 = model.addPart(partSet)
30 Part_1_doc = Part_1.document()
31
32 #Init
33 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
34 Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
35 Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
36 Box_4 = model.addBox(Part_1_doc, 10, 10, 10)
37 Box_5 = model.addBox(Part_1_doc, 10, 10, 10)
38 Box_6 = model.addBox(Part_1_doc, 10, 10, 10)
39 Axis_1 = model.selection("EDGE", "edge")
40
41 # Tests
42 MultiRotation_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OZ"), 5)
43 MultiRotation_2 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("EDGE", "PartSet/OZ"), 0)
44 MultiRotation_3 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OZ"), -3)
45 MultiRotation_4 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("EDGE", "PartSet/OY"), 90, 4)
46 MultiRotation_5 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], model.selection("EDGE", "PartSet/OY"), -75, 4)
47 MultiRotation_6 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Box_6_1")], Axis_1, 4)
48
49 model.do()
50 model.end()
51
52 # Check
53 from GeomAPI import GeomAPI_Shape
54
55 model.testNbResults(MultiRotation_1, 1)
56 model.testNbSubResults(MultiRotation_1, [5])
57 model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.COMPOUND, [1])
58 model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.SOLID, [5])
59 model.testNbSubShapes(MultiRotation_1, GeomAPI_Shape.FACE, [30])
60 model.testHaveNamingFaces(MultiRotation_1, model, Part_1_doc)
61
62 model.testNbResults(MultiRotation_4, 1)
63 model.testNbSubResults(MultiRotation_4, [4])
64 model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.COMPOUND, [1])
65 model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.SOLID, [4])
66 model.testNbSubShapes(MultiRotation_4, GeomAPI_Shape.FACE, [24])
67 model.testHaveNamingFaces(MultiRotation_4, model, Part_1_doc)
68
69 model.testNbResults(MultiRotation_5, 1)
70 model.testNbSubResults(MultiRotation_5, [4])
71 model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.COMPOUND, [1])
72 model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.SOLID, [4])
73 model.testNbSubShapes(MultiRotation_5, GeomAPI_Shape.FACE, [24])
74 model.testHaveNamingFaces(MultiRotation_5, model, Part_1_doc)
75
76 model.testNbResults(MultiRotation_2, 0)
77 assert(MultiRotation_2.feature().error() == "Multirotation builder :: the number of copies for the angular direction is null or negative.")
78
79 model.testNbResults(MultiRotation_3, 0)
80 assert(MultiRotation_3.feature().error() == "Multirotation builder :: the number of copies for the angular direction is null or negative.")
81
82 model.testNbResults(MultiRotation_6, 0)
83 assert(MultiRotation_6.feature().error() == "Attribute \"axis_angular\" is not initialized.")