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