Salome HOME
Merge remote-tracking branch 'origin/Toolbars_Management'
[modules/shaper.git] / test.API / SHAPER / Transformations / TestAPI_MultiRotation.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
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
34 # Points
35 pntOrigin = pnt(0.,0.,0.)
36 pnt1 = pnt(10.,0.,0.)
37
38 # Axis
39 xDir = direction(10., 0., 0.)
40 ax1 = axis(pntOrigin, xDir)
41
42 # Create MultiRotations
43 MultiRotation_1 = shaperpy.makeMultiRotation(Box_1, ax1, 45., 5)
44 MultiRotation_2 = shaperpy.makeMultiRotation(Box_2, ax1, 0., 5)
45
46 try:
47   MultiRotation_3 = shaperpy.makeMultiRotation(Box_3, ax1, 45., -5)
48 except myExcept as ec:
49   assert(ec.what() == "Multirotation builder :: the number of copies is null or negative.")
50
51 try:
52   MultiRotation_4 = shaperpy.makeMultiRotation(None, ax1, 45., 5)
53 except myExcept as ec:
54   assert(ec.what() == "Rotation builder :: source shape is not valid.")
55
56 try:
57   MultiRotation_5 = shaperpy.makeMultiRotation(Box_4, None, 45., 5)
58 except myExcept as ec:
59   assert(ec.what() == "Multirotation builder :: the axis is not valid")
60
61 MultiRotation_6 = shaperpy.makeMultiRotation(Box_5, ax1, 5)
62
63 try:
64   MultiRotation_7 = shaperpy.makeMultiRotation(Box_6, ax1, -5)
65 except myExcept as ec:
66   assert(ec.what() == "Multirotation builder :: the number of copies is null or negative.")
67
68 try:
69   MultiRotation_8 = shaperpy.makeMultiRotation(None, ax1, 5)
70 except myExcept as ec:
71   assert(ec.what() == "Rotation builder :: source shape is not valid.")
72
73 try:
74   MultiRotation_9 = shaperpy.makeMultiRotation(Box_7, None, 5)
75 except myExcept as ec:
76   assert(ec.what() == "Multirotation builder :: the axis is not valid")