Salome HOME
updated copyright message
[modules/shaper.git] / test.API / SHAPER / Transformations / TestAPI_Scale.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_Pnt as pnt, GeomAPI_Shape as shape
23
24 # Create Boxes
25 Box_1 = shaperpy.makeBox(10.,10.,10.)
26 Box_2 = shaperpy.makeBox(10.,10.,10.)
27 Box_3 = shaperpy.makeBox(10.,10.,10.)
28 Box_4 = shaperpy.makeBox(10.,10.,10.)
29 Box_5 = shaperpy.makeBox(10.,10.,10.)
30 Box_6 = shaperpy.makeBox(10.,10.,10.)
31 Box_7 = shaperpy.makeBox(10.,10.,10.)
32 Box_8 = shaperpy.makeBox(10.,10.,10.)
33 Box_9 = shaperpy.makeBox(10.,10.,10.)
34 Box_10 = shaperpy.makeBox(10.,10.,10.)
35 Box_11 = shaperpy.makeBox(10.,10.,10.)
36 Box_12 = shaperpy.makeBox(10.,10.,10.)
37
38 # Create Points
39 pntOrigin = pnt(0., 0., 0.)
40 pnt1 = pnt(-10., -10., -10.)
41
42
43 # Create Scales
44 Scale_1 = shaperpy.makeScale(Box_1, pntOrigin, 2.)
45 Scale_2 = shaperpy.makeScale(Box_2, pnt1, 2.)
46 try :
47     Scale_6 = shaperpy.makeScale(Box_3, pntOrigin, 0)
48 except myExcept as ec :
49     assert(ec.what() == "Scale builder :: the scale factor is null.")
50
51 Scale_7 = shaperpy.makeScale(Box_4, pntOrigin, -3.)
52
53 try :
54     Scale_8 = shaperpy.makeScale(Box_5, None, 2.)
55 except myExcept as ec :
56     assert(ec.what() == "Scale builder :: center point is not valid.")
57
58 Scale_9 = shaperpy.makeScale(Box_6, pntOrigin, 2., 3., 1.)
59 Scale_10 = shaperpy.makeScale(Box_7, pnt1, 2., 3., 1.)
60
61 try :
62     Scale_14 = shaperpy.makeScale(Box_8, pntOrigin, 0., 3., 1.)
63 except myExcept as ec :
64     assert(ec.what() == "Scale builder :: the scale factor in X is null.")
65 try :
66     Scale_15 = shaperpy.makeScale(Box_9, pntOrigin, 2., 0., 1.)
67 except myExcept as ec :
68     assert(ec.what() == "Scale builder :: the scale factor in Y is null.")
69 try :
70     Scale_16 = shaperpy.makeScale(Box_10, pntOrigin, 2., 3., 0.)
71 except myExcept as ec :
72     assert(ec.what() == "Scale builder :: the scale factor in Z is null.")
73
74 Scale_17 = shaperpy.makeScale(Box_11, pntOrigin, -2., -3., 0.5)
75
76 try :
77     Scale_18 = shaperpy.makeScale(Box_12, None, 2., 3., 1.)
78 except myExcept as ec :
79     assert(ec.what() == "Scale builder :: center point is not valid.")
80
81 try :
82     Scale_19 = shaperpy.makeScale(None, pntOrigin, 2., 3., 1.)
83 except myExcept as ec :
84     assert(ec.what() == "Scale builder :: source shape is not valid.")
85
86 try :
87     Scale_20 = shaperpy.makeScale(shape(), pntOrigin, 2.)
88 except myExcept as ec :
89     assert(ec.what() == "Transformation :: source shape does not contain any actual shape.")
90
91 try :
92     Scale_21 = shaperpy.makeScale(shape(), pntOrigin, 2., 3., 1.)
93 except myExcept as ec :
94     assert(ec.what() == "Scale builder :: source shape does not contain any actual shape.")