Salome HOME
Merge remote-tracking branch 'origin/Toolbars_Management'
[modules/shaper.git] / test.API / SHAPER / Transformations / TestAPI_Rotation.py
1 ## Copyright (C) 2014-2017  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
22 from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
23 from GeomAPI import GeomAPI_Ax1 as axis, GeomAPI_Pnt as pnt, GeomAPI_Dir as direction
24 from GeomAPI import GeomAPI_Shape as shape
25
26 # Create Boxes
27 Box_1 = shaperpy.makeBox(10.,10.,10.)
28 Box_2 = shaperpy.makeBox(10.,10.,10.)
29 Box_3 = shaperpy.makeBox(10.,10.,10.)
30 Box_4 = shaperpy.makeBox(10.,10.,10.)
31 Box_5 = shaperpy.makeBox(10.,10.,10.)
32 Box_6 = shaperpy.makeBox(10.,10.,10.)
33 Box_7 = shaperpy.makeBox(10.,10.,10.)
34 Box_8 = shaperpy.makeBox(10.,10.,10.)
35 Box_9 = shaperpy.makeBox(10.,10.,10.)
36 Box_10 = shaperpy.makeBox(10.,10.,10.)
37 Box_11 = shaperpy.makeBox(10.,10.,10.)
38 Box_12 = shaperpy.makeBox(10.,10.,10.)
39 Box_13 = shaperpy.makeBox(10.,10.,10.)
40 Box_14 = shaperpy.makeBox(10.,10.,10.)
41 Box_15 = shaperpy.makeBox(10.,10.,10.)
42
43 # Points
44 pntOrigin = pnt(0.,0.,0.)
45 pnt1 = pnt(20.,0.,0.)
46 pnt2 = pnt(20.,20.,0.)
47 pnt3 = pnt(-10.,0.,0.)
48
49 # Axis
50 zDir = direction(0., 0., 10.)
51 ax1 = axis(pntOrigin, zDir)
52
53
54 # Create Rotations
55 Rotation_1 = shaperpy.makeRotation(Box_1, ax1, 45)
56 Rotation_2 = shaperpy.makeRotation(Box_2, ax1, 0)
57 Rotation_3 = shaperpy.makeRotation(Box_3, ax1, 360)
58 Rotation_4 = shaperpy.makeRotation(Box_4, ax1, -360)
59
60 try:
61     Rotation_5 = shaperpy.makeRotation(Box_5, ax1, 450)
62 except myExcept as ec:
63     assert(ec.what() == "Rotation builder :: angle greater than 360 degrees.")
64
65 try:
66     Rotation_6 = shaperpy.makeRotation(Box_6, ax1, -450)
67 except myExcept as ec:
68     assert(ec.what() == "Rotation builder :: angle smaller than -360 degrees.")
69
70 try:
71     Rotation_7 = shaperpy.makeRotation(Box_7, None, 180)
72 except myExcept as ec:
73     assert(ec.what() == "Rotation builder :: axis is not valid.")
74
75 try:
76     Rotation_8 = shaperpy.makeRotation(None, ax1, 180)
77 except myExcept as ec:
78     assert(ec.what() == "Rotation builder :: source shape is not valid.")
79
80 Rotation_9 = shaperpy.makeRotation(Box_8, pntOrigin, pnt1, pnt2)
81 Rotation_10 = shaperpy.makeRotation(Box_9, pnt3, pnt1, pnt2)
82
83 try:
84     Rotation_11 = shaperpy.makeRotation(Box_10, pnt3, pnt1, pnt1)
85 except myExcept as ec:
86     assert(ec.what() == "Rotation builder :: start point and end point coincide.")
87
88 try:
89     Rotation_12 = shaperpy.makeRotation(Box_11, pnt3, pnt3, pnt1)
90 except myExcept as ec:
91     assert(ec.what() == "Rotation builder :: center point and start point coincide.")
92
93 try:
94     Rotation_13 = shaperpy.makeRotation(Box_12, pnt3, pnt1, pnt3)
95 except myExcept as ec:
96     assert(ec.what() == "Rotation builder :: center point and end point coincide.")
97
98 try:
99     Rotation_14 = shaperpy.makeRotation(Box_13, pntOrigin, pnt1, None)
100 except myExcept as ec:
101     assert(ec.what() == "Rotation builder :: end point is not valid.")
102
103 try:
104     Rotation_15 = shaperpy.makeRotation(Box_14, None, pnt3, pnt2)
105 except myExcept as ec:
106     assert(ec.what() == "Rotation builder :: center point is not valid.")
107
108 try:
109     Rotation_16 = shaperpy.makeRotation(Box_15, pntOrigin, None, pnt1)
110 except myExcept as ec:
111     assert(ec.what() == "Rotation builder :: start point is not valid.")
112
113 try:
114     Rotation_17 = shaperpy.makeRotation(None, pntOrigin, pnt3, pnt2)
115 except myExcept as ec:
116     assert(ec.what() == "Rotation builder :: source shape is not valid.")
117
118 try:
119     Rotation_18 = shaperpy.makeRotation(shape(), ax1, 450)
120 except myExcept as ec:
121     assert(ec.what() == "Rotation builder :: source shape does not contain any actual shape.")