Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / test.API / SHAPER / Transformations / TestAPI_Translation.py
1 # Copyright (C) 2014-2016 CEA/DEN, EDF R&D
2
3 # File:        TestAPI_Translation.py
4 # Created:     15 Nov 2016
5 # Author:      Clarisse Genrault (CEA)
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
10 from GeomAPI import GeomAPI_Pnt as pnt
11 from GeomAPI import GeomAPI_Dir as direction
12
13 # Points
14 pntOrigin = pnt(0.,0.,0.)
15 pnt1 = pnt(10.,0.,0.)
16 pnt2 = pnt(10.,10.,0.)
17
18 # Axis
19 xDir = direction(10., 0., 0.)
20 ax1 = axis(pntOrigin, xDir)
21
22 yDir = direction(0., 10., 0.)
23 ax2 = axis(pntOrigin, yDir)
24
25 zDir = direction(0., 0., 10.)
26 ax3 = axis(pntOrigin, zDir)
27
28 dir1 = direction(10., 10., 10.)
29 ax4 = axis(pntOrigin, dir1)
30
31 # Boxes
32 Box_1 = shaperpy.makeBox(10., 20., 10.)
33 Box_2 = shaperpy.makeBox(10., 20., 10.)
34 Box_3 = shaperpy.makeBox(10., 20., 10.)
35 Box_4 = shaperpy.makeBox(10., 20., 10.)
36 Box_5 = shaperpy.makeBox(10., 20., 10.)
37 Box_6 = shaperpy.makeBox(10., 20., 10.)
38 Box_7 = shaperpy.makeBox(10., 20., 10.)
39 Box_8 = shaperpy.makeBox(10., 20., 10.)
40 Box_9 = shaperpy.makeBox(10., 20., 10.)
41 Box_10 = shaperpy.makeBox(10., 20., 10.)
42 Box_11 = shaperpy.makeBox(10., 20., 10.)
43 Box_12 = shaperpy.makeBox(10., 20., 10.)
44 Box_13 = shaperpy.makeBox(10., 20., 10.)
45 Box_14 = shaperpy.makeBox(10., 20., 10.)
46 Box_15 = shaperpy.makeBox(10., 20., 10.)
47 Box_16 = shaperpy.makeBox(10., 20., 10.)
48 Box_17 = shaperpy.makeBox(10., 20., 10.)
49 Box_18 = shaperpy.makeBox(10., 20., 10.)
50
51 #Translations "By an axis and a distance"
52 Translation_1 = shaperpy.makeTranslation(Box_1, ax1, 15.)
53 Translation_2 = shaperpy.makeTranslation(Box_2, ax1, 0.)
54 Translation_3 = shaperpy.makeTranslation(Box_3, ax1, -15.)
55
56 try:
57     Translation_4 = shaperpy.makeTranslation(Box_4, None, 15.)
58 except myExcept,ec:
59     assert(ec.what() == "Translation builder :: axis is not valid.")
60
61 Translation_9 = shaperpy.makeTranslation(Box_5, ax4, 15.)
62
63 MultiTranslation_1 = shaperpy.makeMultiTranslation(Box_6, ax1, 15., 3, ax2, 15., 3)
64 Translation_10 = shaperpy.makeTranslation(MultiTranslation_1, ax3, 15.)
65
66 MultiTranslation_2 = shaperpy.makeMultiTranslation(Box_7, ax1, 15., 3, ax2, 15., 3)
67 Translation_11 = shaperpy.makeTranslation(MultiTranslation_2, ax3, 0.)
68
69 MultiTranslation_3 = shaperpy.makeMultiTranslation(Box_8, ax1, 15., 3, ax2, 15., 3)
70 Translation_12 = shaperpy.makeTranslation(MultiTranslation_3, ax3, -15.)
71
72 MultiTranslation_4 = shaperpy.makeMultiTranslation(Box_9, ax1, 15., 3, ax2, 15., 3)
73 try:
74     Translation_13 = shaperpy.makeTranslation(MultiTranslation_4, None, 15.)
75 except myExcept,ec:
76     assert(ec.what() == "Translation builder :: axis is not valid.")
77
78 MultiTranslation_5 = shaperpy.makeMultiTranslation(Box_10, ax1, 15., 3, ax2, 15., 3)
79 Translation_18 = shaperpy.makeTranslation(MultiTranslation_5, ax4, 15.)
80
81 # Translations "By dimensions in X, in Y and in Z"
82 Translation_91 = shaperpy.makeTranslation(Box_11, 10., 20., 15.)
83 Translation_92 = shaperpy.makeTranslation(Box_11, 0., 20., 15.)
84 Translation_93 = shaperpy.makeTranslation(Box_11, 10., 0., 15.)
85 Translation_94 = shaperpy.makeTranslation(Box_11, 10., 20., 0.)
86 Translation_95 = shaperpy.makeTranslation(Box_11, -10., 20., 15.)
87 Translation_96 = shaperpy.makeTranslation(Box_11, 10., -20., 15.)
88 Translation_97 = shaperpy.makeTranslation(Box_11, 10., 20., -15.)
89
90 # Translations "By two points"
91 Translation_99 = shaperpy.makeTranslation(Box_11, pnt1, pnt2)
92
93 try:
94     Translation_100 = shaperpy.makeTranslation(Box_11, pnt1, pnt1)
95 except myExcept,ec:
96     assert(ec.what() == "Translation builder :: start point and end point coincide.")
97
98 try:
99     Translation_101 = shaperpy.makeTranslation(Box_11, None, pnt1)
100 except myExcept,ec:
101     assert(ec.what() == "Translation builder :: start point is not valid.")
102
103 try:
104     Translation_102 = shaperpy.makeTranslation(Box_11, pnt1, None)
105 except myExcept,ec:
106     assert(ec.what() == "Translation builder :: end point is not valid.")