Salome HOME
f93bc375b6357ee291e00775c531c9d00035f00f
[modules/shaper.git] / test.API / SHAPER / Transformations / TestAPI_MultiTranslation.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
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
34 # Points
35 pntOrigin = pnt(0.,0.,0.)
36 pnt1 = pnt(10.,0.,0.)
37 pnt2 = pnt(10.,10.,0.)
38
39 # Axis
40 xDir = direction(10., 0., 0.)
41 ax1 = axis(pntOrigin, xDir)
42
43 yDir = direction(0., 10., 0.)
44 ax2 = axis(pntOrigin, yDir)
45
46
47 # Create MultiTranslations
48 MultiTranslation_1 = shaperpy.makeMultiTranslation(Box_1, ax1, 15., 5)
49 MultiTranslation_2 = shaperpy.makeMultiTranslation(Box_2, ax1, -15., 5)
50
51 try:
52     MultiTranslation_3 = shaperpy.makeMultiTranslation(Box_3, ax1, 15., -2)
53 except myExcept as ec:
54     assert(ec.what() == "Multitranslation builder :: the number of copies for the first direction is null or negative.")
55
56 MultiTranslation_5 = shaperpy.makeMultiTranslation(Box_5, ax1, 10., 5, ax2, 10., 5)
57 MultiTranslation_6 = shaperpy.makeMultiTranslation(Box_6, ax1, 15., 5, ax2, -10., 5)
58
59 # Tests en erreur
60 try:
61     MultiTranslation_4 = shaperpy.makeMultiTranslation(Box_4, None, 15., 2)
62 except myExcept as ec:
63     assert(ec.what() == "Multitranslation builder :: the first axis is not valid")
64
65 # Pas d'exception levee alors qu'une devrait y en avoir une
66 try:
67     MultiTranslation_7 = shaperpy.makeMultiTranslation(Box_7, ax1, 15., 5, ax2, 10., -2)
68 except myExcept as ec:
69     assert(ec.what() == "Multitranslation builder :: the number of copies for the second direction is null or negative.")
70 try:
71     MultiTranslation_8 = shaperpy.makeMultiTranslation(Box_7, ax1, 15., -2, ax2, 10., 5)
72 except myExcept as ec:
73     assert(ec.what() == "Multitranslation builder :: the number of copies for the first direction is null or negative.")
74
75 try:
76     MultiTranslation_9 = shaperpy.makeMultiTranslation(Box_8, None, 15., 5, ax2, 10., 5)
77 except myExcept as ec:
78     assert(ec.what() == "Multitranslation builder :: the first axis is not valid")
79
80 try:
81     MultiTranslation_10 = shaperpy.makeMultiTranslation(Box_8, ax1, 15., 5, None, 10., 5)
82 except myExcept as ec:
83     assert(ec.what() == "Multitranslation builder :: the second axis is not valid")