1 # Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 # File: TestAPI_Translation.py
5 # Author: Clarisse Genrault (CEA)
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
14 pntOrigin = pnt(0.,0.,0.)
16 pnt2 = pnt(10.,10.,0.)
19 xDir = direction(10., 0., 0.)
20 ax1 = axis(pntOrigin, xDir)
22 yDir = direction(0., 10., 0.)
23 ax2 = axis(pntOrigin, yDir)
25 zDir = direction(0., 0., 10.)
26 ax3 = axis(pntOrigin, zDir)
28 dir1 = direction(10., 10., 10.)
29 ax4 = axis(pntOrigin, dir1)
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.)
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.)
57 Translation_4 = shaperpy.makeTranslation(Box_4, None, 15.)
59 assert(ec.what() == "Translation builder :: axis is not valid.")
61 Translation_9 = shaperpy.makeTranslation(Box_5, ax4, 15.)
63 MultiTranslation_1 = shaperpy.makeMultiTranslation(Box_6, ax1, 15., 3, ax2, 15., 3)
64 Translation_10 = shaperpy.makeTranslation(MultiTranslation_1, ax3, 15.)
66 MultiTranslation_2 = shaperpy.makeMultiTranslation(Box_7, ax1, 15., 3, ax2, 15., 3)
67 Translation_11 = shaperpy.makeTranslation(MultiTranslation_2, ax3, 0.)
69 MultiTranslation_3 = shaperpy.makeMultiTranslation(Box_8, ax1, 15., 3, ax2, 15., 3)
70 Translation_12 = shaperpy.makeTranslation(MultiTranslation_3, ax3, -15.)
72 MultiTranslation_4 = shaperpy.makeMultiTranslation(Box_9, ax1, 15., 3, ax2, 15., 3)
74 Translation_13 = shaperpy.makeTranslation(MultiTranslation_4, None, 15.)
76 assert(ec.what() == "Translation builder :: axis is not valid.")
78 MultiTranslation_5 = shaperpy.makeMultiTranslation(Box_10, ax1, 15., 3, ax2, 15., 3)
79 Translation_18 = shaperpy.makeTranslation(MultiTranslation_5, ax4, 15.)
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.)
90 # Translations "By two points"
91 Translation_99 = shaperpy.makeTranslation(Box_11, pnt1, pnt2)
94 Translation_100 = shaperpy.makeTranslation(Box_11, pnt1, pnt1)
96 assert(ec.what() == "Translation builder :: start point and end point coincide.")
99 Translation_101 = shaperpy.makeTranslation(Box_11, None, pnt1)
101 assert(ec.what() == "Translation builder :: start point is not valid.")
104 Translation_102 = shaperpy.makeTranslation(Box_11, pnt1, None)
106 assert(ec.what() == "Translation builder :: end point is not valid.")