Salome HOME
Add tests.
[modules/shaper.git] / test.API / SHAPER / Transformations / TestAPI_MultiTranslation.py
1 # Copyright (C) 2014-201x CEA/DEN, EDF R&D
2
3 # File:        TestAPI_MultiTranslation.py
4 # Created:     17 Mar 2017
5 # Author:      Sylvain Chouteau (Alyotech)
6
7 from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
8 from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
9 from GeomAPI import GeomAPI_Ax1 as axis, GeomAPI_Pnt as pnt, GeomAPI_Dir as direction
10
11 # Create Boxes
12 Box_1 = shaperpy.makeBox(10.,10.,10.)
13 Box_2 = shaperpy.makeBox(10.,10.,10.)
14 Box_3 = shaperpy.makeBox(10.,10.,10.)
15 Box_4 = shaperpy.makeBox(10.,10.,10.)
16 Box_5 = shaperpy.makeBox(10.,10.,10.)
17 Box_6 = shaperpy.makeBox(10.,10.,10.)
18 Box_7 = shaperpy.makeBox(10.,10.,10.)
19 Box_8 = shaperpy.makeBox(10.,10.,10.)
20
21 # Points
22 pntOrigin = pnt(0.,0.,0.)
23 pnt1 = pnt(10.,0.,0.)
24 pnt2 = pnt(10.,10.,0.)
25
26 # Axis
27 xDir = direction(10., 0., 0.)
28 ax1 = axis(pntOrigin, xDir)
29
30 yDir = direction(0., 10., 0.)
31 ax2 = axis(pntOrigin, yDir)
32
33
34 # Create MultiTranslations
35 MultiTranslation_1 = shaperpy.makeMultiTranslation(Box_1, ax1, 15., 5)
36 MultiTranslation_2 = shaperpy.makeMultiTranslation(Box_2, ax1, -15., 5)
37
38 try:
39     MultiTranslation_3 = shaperpy.makeMultiTranslation(Box_3, ax1, 15., -2)
40 except myExcept,ec:
41     assert(ec.what() == "Multitranslation builder :: the number of copies for the first direction is null or negative.")
42
43 MultiTranslation_5 = shaperpy.makeMultiTranslation(Box_5, ax1, 10., 5, ax2, 10., 5)
44 MultiTranslation_6 = shaperpy.makeMultiTranslation(Box_6, ax1, 15., 5, ax2, -10., 5)
45
46 # Tests en erreur
47 #try:
48 #    MultiTranslation_4 = shaperpy.makeMultiTranslation(Box_4, None, 15., 2)
49 #except myExcept,ec:
50 #    assert(ec.what() == "Multitranslation builder :: the first axis is not valid.")
51
52 # Pas d'exception levee alors qu'une devrait y en avoir une
53 try:
54     MultiTranslation_7 = shaperpy.makeMultiTranslation(Box_7, ax1, 15., 5, ax2, 10., -2)
55 except myExcept,ec:
56     assert(ec.what() == "Multitranslation builder :: the number of copies for the second direction is null or negative.")
57
58 #try:
59 #    MultiTranslation_8 = shaperpy.makeMultiTranslation(Box_8, ax1, 15., 5, None, 10., 5)
60 #except myExcept,ec:
61 #    assert(ec.what() == "Multitranslation builder :: the second axis is not valid.")