Salome HOME
Add tests.
[modules/shaper.git] / test.API / SHAPER / Transformations / TestAPI_Rotation.py
1 # Copyright (C) 2014-201x CEA/DEN, EDF R&D
2
3 # File:        TestAPI_Rotation.py
4 # Created:     17 Mar 2017
5 # Author:      Sylvain Chouteau (Alyotech)
6
7 from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
8 from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
9 from GeomAPI import GeomAPI_Ax1 as axis, GeomAPI_Pnt as pnt, GeomAPI_Dir as direction
10
11 # Create Boxes
12 Box_1 = shaperpy.makeBox(10.,10.,10.)
13 Box_2 = shaperpy.makeBox(10.,10.,10.)
14 Box_3 = shaperpy.makeBox(10.,10.,10.)
15 Box_4 = shaperpy.makeBox(10.,10.,10.)
16 Box_5 = shaperpy.makeBox(10.,10.,10.)
17 Box_6 = shaperpy.makeBox(10.,10.,10.)
18 Box_7 = shaperpy.makeBox(10.,10.,10.)
19 Box_8 = shaperpy.makeBox(10.,10.,10.)
20 Box_9 = shaperpy.makeBox(10.,10.,10.)
21 Box_10 = shaperpy.makeBox(10.,10.,10.)
22 Box_11 = shaperpy.makeBox(10.,10.,10.)
23 Box_12 = shaperpy.makeBox(10.,10.,10.)
24 Box_13 = shaperpy.makeBox(10.,10.,10.)
25 Box_14 = shaperpy.makeBox(10.,10.,10.)
26 Box_15 = shaperpy.makeBox(10.,10.,10.)
27
28 # Points
29 pntOrigin = pnt(0.,0.,0.)
30 pnt1 = pnt(20.,0.,0.)
31 pnt2 = pnt(20.,20.,0.)
32 pnt3 = pnt(-10.,0.,0.)
33
34 # Axis
35 zDir = direction(0., 0., 10.)
36 ax1 = axis(pntOrigin, zDir)
37
38
39 # Create Rotations
40 Rotation_1 = shaperpy.makeRotation(Box_1, ax1, 45)
41 Rotation_2 = shaperpy.makeRotation(Box_2, ax1, 0)
42 Rotation_3 = shaperpy.makeRotation(Box_3, ax1, 360)
43 Rotation_4 = shaperpy.makeRotation(Box_4, ax1, -360)
44
45 try:
46     Rotation_5 = shaperpy.makeRotation(Box_5, ax1, 450)
47 except myExcept,ec:
48     assert(ec.what() == "Rotation builder :: angle greater than 360 degrees.")
49
50 try:
51     Rotation_6 = shaperpy.makeRotation(Box_6, ax1, -450)
52 except myExcept,ec:
53     assert(ec.what() == "Rotation builder :: angle smaller than -360 degrees.")
54
55 try:
56     Rotation_7 = shaperpy.makeRotation(Box_7, None, 180)
57 except myExcept,ec:
58     assert(ec.what() == "Rotation builder :: axis is not valid.")
59
60 try:
61     Rotation_8 = shaperpy.makeRotation(None, ax1, 180)
62 except myExcept,ec:
63     assert(ec.what() == "Rotation builder :: source shape is not valid.")
64
65 Rotation_9 = shaperpy.makeRotation(Box_8, pntOrigin, pnt1, pnt2)
66 Rotation_10 = shaperpy.makeRotation(Box_9, pnt3, pnt1, pnt2)
67
68 try:
69     Rotation_11 = shaperpy.makeRotation(Box_10, pnt3, pnt1, pnt1)
70 except myExcept,ec:
71     assert(ec.what() == "Rotation builder :: start point and end point coincide.")
72
73 try:
74     Rotation_12 = shaperpy.makeRotation(Box_11, pnt3, pnt3, pnt1)
75 except myExcept,ec:
76     assert(ec.what() == "Rotation builder :: center point and start point coincide.")
77
78 try:
79     Rotation_13 = shaperpy.makeRotation(Box_12, pnt3, pnt1, pnt3)
80 except myExcept,ec:
81     assert(ec.what() == "Rotation builder :: center point and end point coincide.")
82
83 try:
84     Rotation_14 = shaperpy.makeRotation(Box_13, pntOrigin, pnt1, None)
85 except myExcept,ec:
86     assert(ec.what() == "Rotation builder :: end point is not valid.")
87
88 try:
89     Rotation_15 = shaperpy.makeRotation(Box_14, None, pnt3, pnt2)
90 except myExcept,ec:
91     assert(ec.what() == "Rotation builder :: center point is not valid.")
92
93 try:
94     Rotation_16 = shaperpy.makeRotation(Box_15, pntOrigin, None, pnt1)
95 except myExcept,ec:
96     assert(ec.what() == "Rotation builder :: start point is not valid.")
97
98 try:
99     Rotation_17 = shaperpy.makeRotation(None, pntOrigin, pnt3, pnt2)
100 except myExcept,ec:
101     assert(ec.what() == "Rotation builder :: source shape is not valid.")