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