Salome HOME
8ea9d29dc2ac578474ef6a5b76d1f3b048398bc8
[modules/shaper.git] / test.API / SHAPER / Primitives / TestAPI_Box.py
1 ## Copyright (C) 2014-2017  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
22 from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
23 from GeomAPI import GeomAPI_Pnt as pnt
24
25 # Create a box with dimensions
26 Box_1 = shaperpy.makeBox(10.,10.,10.)
27
28 try :
29   Box_2 = shaperpy.makeBox(0.,10.,10.)
30 except myExcept as ec:
31   assert(ec.what() == "Box builder with dimensions :: Dx is null or negative.")
32
33 try :
34   Box_3 = shaperpy.makeBox(10.,0.,10.)
35 except myExcept as ec:
36   assert(ec.what() == "Box builder with dimensions :: Dy is null or negative.")
37
38 try :
39   Box_4 = shaperpy.makeBox(10.,10.,0.)
40 except myExcept as ec:
41   assert(ec.what() == "Box builder with dimensions :: Dz is null or negative.")
42
43 try :
44   Box_5 = shaperpy.makeBox(-10.,10.,10.)
45 except myExcept as ec:
46   assert(ec.what() == "Box builder with dimensions :: Dx is null or negative.")
47
48 try :
49   Box_6 = shaperpy.makeBox(10.,-10.,10.)
50 except myExcept as ec:
51   assert(ec.what() == "Box builder with dimensions :: Dy is null or negative.")
52
53 try :
54   Box_7 = shaperpy.makeBox(10.,10.,-10.)
55 except myExcept as ec:
56   assert(ec.what() == "Box builder with dimensions :: Dz is null or negative.")
57
58 # Create a box with two points defining the diagonal
59 pnt1 = pnt(0.,0.,0.)
60 pnt2 = pnt(50.,50.,50.)
61 Box_8 = shaperpy.makeBox(pnt1,pnt2)
62
63 try :
64   Box_9 = shaperpy.makeBox(pnt1,pnt1)
65 except myExcept as ec:
66   assert(ec.what() == "Box builder with points :: the distance between the two points is null.")
67
68 try :
69   pnt3 = pnt(0.,50.,50.)
70   Box_10 = shaperpy.makeBox(pnt1,pnt3)
71 except myExcept as ec:
72   assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
73
74 try :
75   pnt4 = pnt(50.,0.,50.)
76   Box_11 = shaperpy.makeBox(pnt1,pnt4)
77 except myExcept as ec:
78   assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
79
80 try :
81   pnt5 = pnt(50.,50.,0.)
82   Box_12 = shaperpy.makeBox(pnt1,pnt5)
83 except myExcept as ec:
84   assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
85
86 try :
87   Box_13 = shaperpy.makeBox(None, pnt2)
88 except myExcept as ec:
89   assert(ec.what() == "Box builder with points :: the first point is not valid.")
90
91 try :
92   Box_14 = shaperpy.makeBox(pnt2, None)
93 except myExcept as ec:
94   assert(ec.what() == "Box builder with points :: the second point is not valid.")