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