Salome HOME
Updated copyright comment
[modules/shaper.git] / test.API / SHAPER / Transformations / TestTranslation_4.py
1 # Copyright (C) 2014-2024  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 """
21 Test case for Translation feature.
22 Written on High API.
23 """
24 from salome.shaper import model
25
26 model.begin()
27 partSet = model.moduleDocument()
28 Part_1 = model.addPart(partSet)
29 Part_1_doc = Part_1.document()
30
31 # Boxes
32 Box_1 = model.addBox(Part_1_doc, 10, 20, 10)
33 Box_2 = model.addBox(Part_1_doc, 10, 20, 10)
34 Box_3 = model.addBox(Part_1_doc, 10, 20, 10)
35 Box_4 = model.addBox(Part_1_doc, 10, 20, 10)
36 Box_5 = model.addBox(Part_1_doc, 10, 20, 10)
37 Box_6 = model.addBox(Part_1_doc, 10, 20, 10)
38 Box_7 = model.addBox(Part_1_doc, 10, 20, 10)
39 Box_8 = model.addBox(Part_1_doc, 10, 20, 10)
40
41 # Parameters
42 model.addParameter(Part_1_doc, "dx", "10")
43 model.addParameter(Part_1_doc, "dy", "15")
44 model.addParameter(Part_1_doc, "dz", "-5")
45
46 # Translations
47 Translation_91 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], 10, 20, 15)
48 Translation_92 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], 0, 20, 15)
49 Translation_93 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], 10, 0, 15)
50 Translation_94 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], 10, 20, 0)
51 Translation_95 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], -10, 20, 15)
52 Translation_96 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_6_1")], 10, -20, 15)
53 Translation_97 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_7_1")], 10, 20, -15)
54 Translation_98 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_8_1")], "dx", "dy", "dz")
55 model.do()
56 model.end()
57
58 # Checks
59 from GeomAPI import GeomAPI_Shape
60
61 model.testNbResults(Translation_91, 1)
62 model.testNbSubResults(Translation_91, [0])
63 model.testNbSubShapes(Translation_91, GeomAPI_Shape.SOLID, [1])
64 model.testNbSubShapes(Translation_91, GeomAPI_Shape.FACE, [6])
65 model.testHaveNamingFaces(Translation_91, model, Part_1_doc)
66
67 model.testNbResults(Translation_92, 1)
68 model.testNbSubResults(Translation_92, [0])
69 model.testNbSubShapes(Translation_92, GeomAPI_Shape.SOLID, [1])
70 model.testNbSubShapes(Translation_92, GeomAPI_Shape.FACE, [6])
71 model.testHaveNamingFaces(Translation_92, model, Part_1_doc)
72
73 model.testNbResults(Translation_93, 1)
74 model.testNbSubResults(Translation_93, [0])
75 model.testNbSubShapes(Translation_93, GeomAPI_Shape.SOLID, [1])
76 model.testNbSubShapes(Translation_93, GeomAPI_Shape.FACE, [6])
77 model.testHaveNamingFaces(Translation_93, model, Part_1_doc)
78
79 model.testNbResults(Translation_94, 1)
80 model.testNbSubResults(Translation_94, [0])
81 model.testNbSubShapes(Translation_94, GeomAPI_Shape.SOLID, [1])
82 model.testNbSubShapes(Translation_94, GeomAPI_Shape.FACE, [6])
83 model.testHaveNamingFaces(Translation_94, model, Part_1_doc)
84
85 model.testNbResults(Translation_95, 1)
86 model.testNbSubResults(Translation_95, [0])
87 model.testNbSubShapes(Translation_95, GeomAPI_Shape.SOLID, [1])
88 model.testNbSubShapes(Translation_95, GeomAPI_Shape.FACE, [6])
89 model.testHaveNamingFaces(Translation_95, model, Part_1_doc)
90
91 model.testNbResults(Translation_96, 1)
92 model.testNbSubResults(Translation_96, [0])
93 model.testNbSubShapes(Translation_96, GeomAPI_Shape.SOLID, [1])
94 model.testNbSubShapes(Translation_96, GeomAPI_Shape.FACE, [6])
95 model.testHaveNamingFaces(Translation_96, model, Part_1_doc)
96
97 model.testNbResults(Translation_97, 1)
98 model.testNbSubResults(Translation_97, [0])
99 model.testNbSubShapes(Translation_97, GeomAPI_Shape.SOLID, [1])
100 model.testNbSubShapes(Translation_97, GeomAPI_Shape.FACE, [6])
101 model.testHaveNamingFaces(Translation_97, model, Part_1_doc)
102
103 model.testNbResults(Translation_98, 1)
104 model.testNbSubResults(Translation_98, [0])
105 model.testNbSubShapes(Translation_98, GeomAPI_Shape.SOLID, [1])
106 model.testNbSubShapes(Translation_98, GeomAPI_Shape.FACE, [6])
107 model.testHaveNamingFaces(Translation_98, model, Part_1_doc)