Salome HOME
Update copyrights
[modules/shaper.git] / test.API / SHAPER / Transformations / TestTranslation_5.py
1 # Copyright (C) 2014-2019  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 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
37 # Sketches
38 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
39 SketchLine_1 = Sketch_1.addLine(47.23370043826552, 82.68004022993115, -80.41547074975036, -6.189635913624215)
40 SketchLine_2 = Sketch_1.addLine(-80.41547074975036, -6.189635913624215, 57.33252727276048, -26.79124265599387)
41 SketchLine_3 = Sketch_1.addLine(57.33252727276048, -26.79124265599387, 47.23370043826552, 82.68004022993115)
42 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
43 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
44 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
45 model.do()
46
47 # Points
48 Point_1 = model.addPoint(Part_1_doc, 10, 0, 0)
49 Point_2 = model.addPoint(Part_1_doc, 10, 10, 0)
50
51 # Vertex
52 Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")])
53 Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex")])
54
55 # Translations
56 Translation_99 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2"))
57 Translation_100 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_1"))
58 Translation_101 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("VERTEX", "InvalidName"), model.selection("VERTEX", "Point_1"))
59 Translation_102 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "InvalidName"))
60 Translation_103 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"))
61 Translation_104 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1"))
62 Translation_105 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("VERTEX", "[Box_4_1/Back][Box_4_1/Left][Box_4_1/Bottom]"), model.selection("VERTEX", "[Box_4_1/Front][Box_4_1/Right][Box_4_1/Top]"))
63 model.do()
64 model.end()
65
66 # Checks
67 from GeomAPI import GeomAPI_Shape
68
69 model.testNbResults(Translation_99, 1)
70 model.testNbSubResults(Translation_99, [0])
71 model.testNbSubShapes(Translation_99, GeomAPI_Shape.SOLID, [1])
72 model.testNbSubShapes(Translation_99, GeomAPI_Shape.FACE, [6])
73 model.testHaveNamingFaces(Translation_99, model, Part_1_doc)
74
75 model.testNbResults(Translation_103, 1)
76 model.testNbSubResults(Translation_103, [0])
77 model.testNbSubShapes(Translation_103, GeomAPI_Shape.SOLID, [1])
78 model.testNbSubShapes(Translation_103, GeomAPI_Shape.FACE, [6])
79 model.testHaveNamingFaces(Translation_103, model, Part_1_doc)
80
81 model.testNbResults(Translation_104, 1)
82 model.testNbSubResults(Translation_104, [0])
83 model.testNbSubShapes(Translation_104, GeomAPI_Shape.SOLID, [1])
84 model.testNbSubShapes(Translation_104, GeomAPI_Shape.FACE, [6])
85 model.testHaveNamingFaces(Translation_104, model, Part_1_doc)
86
87 model.testNbResults(Translation_105, 1)
88 model.testNbSubResults(Translation_105, [0])
89 model.testNbSubShapes(Translation_105, GeomAPI_Shape.SOLID, [1])
90 model.testNbSubShapes(Translation_105, GeomAPI_Shape.FACE, [6])
91 model.testHaveNamingFaces(Translation_105, model, Part_1_doc)
92
93
94 model.testNbResults(Translation_100, 0)
95 assert(Translation_100.feature().error() == 'The feature uses equal shapes.')
96
97 model.testNbResults(Translation_101, 0)
98 assert(Translation_101.feature().error() == 'Attribute "start_point" is not initialized.')
99
100 model.testNbResults(Translation_102, 0)
101 assert(Translation_102.feature().error() == 'Attribute "end_point" is not initialized.')