1 # Copyright (C) 2014-2021 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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
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.)
43 pntOrigin = pnt(0.,0.,0.)
45 pnt2 = pnt(20.,20.,0.)
46 pnt3 = pnt(-10.,0.,0.)
49 zDir = direction(0., 0., 10.)
50 ax1 = axis(pntOrigin, zDir)
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)
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.")
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.")
70 Rotation_7 = shaperpy.makeRotation(Box_7, None, 180)
71 except myExcept as ec:
72 assert(ec.what() == "Rotation builder :: axis is not valid.")
75 Rotation_8 = shaperpy.makeRotation(None, ax1, 180)
76 except myExcept as ec:
77 assert(ec.what() == "Transformation :: incorrect input data.")
79 Rotation_9 = shaperpy.makeRotation(Box_8, pntOrigin, pnt1, pnt2)
80 Rotation_10 = shaperpy.makeRotation(Box_9, pnt3, pnt1, pnt2)
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.")
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.")
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.")
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.")
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.")
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.")
113 Rotation_17 = shaperpy.makeRotation(None, pntOrigin, pnt3, pnt2)
114 except myExcept as ec:
115 assert(ec.what() == "Transformation :: incorrect input data.")
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.")