]> SALOME platform Git repositories - modules/shaper.git/blob - test.API/SHAPER/Primitives/TestAPI_Box.py
Salome HOME
Add tests.
[modules/shaper.git] / test.API / SHAPER / Primitives / TestAPI_Box.py
1 # Copyright (C) 2014-2016 CEA/DEN, EDF R&D
2
3 # File:        TestAPI_Box.py
4 # Created:     16 Sept 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_Pnt as pnt
10
11 # Create a box with dimensions   
12 Box_1 = shaperpy.makeBox(10.,10.,10.)
13   
14 try :    
15   Box_2 = shaperpy.makeBox(0.,10.,10.)
16 except myExcept,ec:
17   assert(ec.what() == "Box builder with dimensions :: Dx is null or negative.")
18
19 try :    
20   Box_3 = shaperpy.makeBox(10.,0.,10.)
21 except myExcept,ec:
22   assert(ec.what() == "Box builder with dimensions :: Dy is null or negative.")
23   
24 try :    
25   Box_4 = shaperpy.makeBox(10.,10.,0.)
26 except myExcept,ec:
27   assert(ec.what() == "Box builder with dimensions :: Dz is null or negative.")
28   
29 try :    
30   Box_5 = shaperpy.makeBox(-10.,10.,10.)
31 except myExcept,ec:
32   assert(ec.what() == "Box builder with dimensions :: Dx is null or negative.")
33   
34 try :    
35   Box_6 = shaperpy.makeBox(10.,-10.,10.)
36 except myExcept,ec:
37   assert(ec.what() == "Box builder with dimensions :: Dy is null or negative.")
38   
39 try :    
40   Box_7 = shaperpy.makeBox(10.,10.,-10.)
41 except myExcept,ec:
42   assert(ec.what() == "Box builder with dimensions :: Dz is null or negative.")
43
44 # Create a box with two points defining the diagonal
45 pnt1 = pnt(0.,0.,0.)
46 pnt2 = pnt(50.,50.,50.)
47 Box_8 = shaperpy.makeBox(pnt1,pnt2)
48
49 try :  
50   Box_9 = shaperpy.makeBox(pnt1,pnt1)
51 except myExcept,ec:
52   assert(ec.what() == "Box builder with points :: the distance between the two points is null.")
53   
54 try :    
55   pnt3 = pnt(0.,50.,50.)
56   Box_10 = shaperpy.makeBox(pnt1,pnt3)
57 except myExcept,ec:
58   assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
59   
60 try :    
61   pnt4 = pnt(50.,0.,50.)
62   Box_11 = shaperpy.makeBox(pnt1,pnt4)
63 except myExcept,ec:
64   assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
65   
66 try :    
67   pnt5 = pnt(50.,50.,0.)
68   Box_12 = shaperpy.makeBox(pnt1,pnt5)
69 except myExcept,ec:
70   assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
71   
72 try :    
73   Box_13 = shaperpy.makeBox(None, pnt2)
74 except myExcept,ec:
75   assert(ec.what() == "Box builder with points :: the first point is not valid.")
76   
77 try :    
78   Box_14 = shaperpy.makeBox(pnt2, None)
79 except myExcept,ec:
80   assert(ec.what() == "Box builder with points :: the second point is not valid.")