Salome HOME
Update copyrights
[modules/shaper.git] / test.API / SHAPER / Transformations / TestAPI_Symmetry.py
1 # Copyright (C) 2014-2019  CEA/DEN, EDF R&D
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
23 from GeomAPI import GeomAPI_Dir as direction
24 from GeomAPI import GeomAPI_Ax1 as axis
25 from GeomAPI import GeomAPI_Ax2 as plane
26 from GeomAPI import GeomAPI_Shape as shape
27
28 # Create boxes
29 Box_1 = shaperpy.makeBox(10., 10., 10.)
30 Box_2 = shaperpy.makeBox(10., 10., 10.)
31 Box_3 = shaperpy.makeBox(10., 10., 10.)
32 Box_4 = shaperpy.makeBox(10., 10., 10.)
33 Box_5 = shaperpy.makeBox(10., 10., 10.)
34 Box_6 = shaperpy.makeBox(10., 10., 10.)
35 Box_7 = shaperpy.makeBox(10., 10., 10.)
36 Box_8 = shaperpy.makeBox(10., 10., 10.)
37 Box_9 = shaperpy.makeBox(10., 10., 10.)
38 Box_10 = shaperpy.makeBox(10., 10., 10.)
39 Box_11 = shaperpy.makeBox(10., 10., 10.)
40 Box_12 = shaperpy.makeBox(10., 10., 10.)
41 Box_13 = shaperpy.makeBox(10., 10., 10.)
42 Box_14 = shaperpy.makeBox(10., 10., 10.)
43 Box_15 = shaperpy.makeBox(10., 10., 10.)
44 Box_16 = shaperpy.makeBox(10., 10., 10.)
45 Box_17 = shaperpy.makeBox(10., 10., 10.)
46 Box_18 = shaperpy.makeBox(10., 10., 10.)
47
48 # Create points
49 origin = pnt(0., 0., 0.)
50 pnt1 = pnt(-10., -10., -10)
51
52 # Create Axis
53 dirZ = direction(0., 0., 10.)
54 axZ = axis(origin, dirZ)
55
56 dir1 = direction(10., 10., 10.)
57 ax1 = axis(origin, dir1)
58
59 # Create Planes
60 planeXOY = plane(origin, dirZ)
61
62 Symmetry_1 = shaperpy.makeSymmetry(Box_1, origin)
63 Symmetry_2 = shaperpy.makeSymmetry(Box_2, pnt1)
64
65 try :
66     Symmetry_3 = shaperpy.makeSymmetry(Box_3, None)
67 except myExcept as ec :
68     assert(ec.what() == "Symmetry builder :: point is not valid.")
69
70 Symmetry_4 = shaperpy.makeSymmetry(Box_4, axZ)
71 Symmetry_5 = shaperpy.makeSymmetry(Box_5, ax1)
72 Symmetry_6 = shaperpy.makeSymmetry(Box_6, planeXOY)
73
74 try :
75     Symmetry_7 = shaperpy.makeSymmetry(None, pnt1)
76 except myExcept as ec :
77     assert(ec.what() == "Symmetry builder :: source shape is not valid.")
78
79 try :
80     Symmetry_8 = shaperpy.makeSymmetry(None, axZ)
81 except myExcept as ec :
82     assert(ec.what() == "Symmetry builder :: source shape is not valid.")
83
84 try :
85     Symmetry_9 = shaperpy.makeSymmetry(None, planeXOY)
86 except myExcept as ec :
87     assert(ec.what() == "Symmetry builder :: source shape is not valid.")
88
89 try :
90     Symmetry_10 = shaperpy.makeSymmetry(shape(), pnt1)
91 except myExcept as ec :
92     assert(ec.what() == "Symmetry builder :: source shape does not contain any actual shape.")