]> SALOME platform Git repositories - modules/shaper.git/blob - test.API/SHAPER/Primitives/TestBox.py
Salome HOME
Transfer of tests (Primitives, Transfotmation and GDML).
[modules/shaper.git] / test.API / SHAPER / Primitives / TestBox.py
1 """
2 Test case for Primitive Box feature. 
3 Written on High API.
4 """
5 from ModelAPI import *
6 from GeomAPI import *
7
8 from salome.shaper import model
9
10 # Get session
11 aSession = ModelAPI_Session.get()
12
13 # Create a part
14 aDocument = aSession.activeDocument()
15 aSession.startOperation()
16 model.addPart(aDocument)
17 aDocument = aSession.activeDocument()
18 aSession.finishOperation()
19
20 # Create a box with dimensions
21 aSession.startOperation()
22 aBox1 = model.addBox(aDocument, 10, 10, 10)
23 model.testNbResults(aBox1, 1)
24 model.testNbSubShapes(aBox1, GeomAPI_Shape.SOLID, [1])
25 model.testNbSubShapes(aBox1, GeomAPI_Shape.FACE, [6])
26 print "box1 : ok"
27 aSession.finishOperation()
28
29 aSession.startOperation()
30 aBox2 = model.addBox(aDocument, 0, 10, 10)
31 model.testNbResults(aBox2, 0)
32 print "box2 : ko (" + aBox2.feature().error() + ")"
33 aSession.finishOperation()
34
35 aSession.startOperation()
36 aBox3 = model.addBox(aDocument, 10, 0, 10)
37 model.testNbResults(aBox3, 0)
38 print "box3 : ko (" + aBox3.feature().error() + ")"
39 aSession.finishOperation()
40
41 aSession.startOperation()
42 aBox4 = model.addBox(aDocument, 10, 10, 0)
43 model.testNbResults(aBox4, 0)
44 print "box4 : ko (" + aBox4.feature().error() + ")"
45 aSession.finishOperation()
46
47 aSession.startOperation()
48 aBox5 = model.addBox(aDocument, -10, 10, 10)
49 model.testNbResults(aBox5, 0)
50 print "box5 : ko (" + aBox5.feature().error() + ")"
51 aSession.finishOperation()
52
53 aSession.startOperation()
54 aBox6 = model.addBox(aDocument, 10, -10, 10)
55 model.testNbResults(aBox6, 0)
56 print "box6 : ko (" + aBox6.feature().error() + ")"
57 aSession.finishOperation()
58
59 aSession.startOperation()
60 aBox7 = model.addBox(aDocument, 10, 10, -10)
61 model.testNbResults(aBox7, 0)
62 print "box7 : ko (" + aBox7.feature().error() + ")"
63 aSession.finishOperation()
64
65 # Create a box with 2 points
66 aSession.startOperation()
67 aPoint1 = model.addPoint(aDocument, 0, 0, 0).result()
68 aPoint2 = model.addPoint(aDocument, 50, 50, 50).result()
69 aBox8 = model.addBox(aDocument, aPoint1, aPoint2)
70 model.testNbResults(aBox8, 1)
71 model.testNbSubShapes(aBox8, GeomAPI_Shape.SOLID, [1])
72 model.testNbSubShapes(aBox8, GeomAPI_Shape.FACE, [6])
73 print "box8 : ok"
74 aSession.finishOperation()
75
76 aSession.startOperation()
77 aPoint1 = model.addPoint(aDocument, 0, 0, 0).result()
78 aBox9 = model.addBox(aDocument, aPoint1, aPoint1)
79 model.testNbResults(aBox9, 0)
80 print "box9 : ko (" + aBox9.feature().error() + ")"
81 aSession.finishOperation()
82
83 aSession.startOperation()
84 aPoint1 = model.addPoint(aDocument, 0, 0, 0).result()
85 aPoint2 = model.addPoint(aDocument, 0, 50, 50).result()
86 aBox10 = model.addBox(aDocument, aPoint1, aPoint2)
87 model.testNbResults(aBox10, 0)
88 print "box10 : ko (" + aBox10.feature().error() + ")"
89 aSession.finishOperation()
90
91 aSession.startOperation()
92 aPoint1 = model.addPoint(aDocument, 0, 0, 0).result()
93 aPoint2 = model.addPoint(aDocument, 50, 0, 50).result()
94 aBox11 = model.addBox(aDocument, aPoint1, aPoint2)
95 model.testNbResults(aBox11, 0)
96 print "box11 : ko (" + aBox11.feature().error() + ")"
97 aSession.finishOperation()
98
99 aSession.startOperation()
100 aPoint1 = model.addPoint(aDocument, 0, 0, 0).result()
101 aPoint2 = model.addPoint(aDocument, 50, 50, 0).result()
102 aBox12 = model.addBox(aDocument, aPoint1, aPoint2)
103 model.testNbResults(aBox12, 0)
104 print "box12 : ko (" + aBox12.feature().error() + ")"
105 aSession.finishOperation()
106
107 aSession.startOperation()
108 aPoint1 = model.selection("VERTEX", "point1")
109 aPoint2 = model.addPoint(aDocument, 50, 50, 0).result()
110 aBox13 = model.addBox(aDocument, aPoint1, aPoint2)
111 model.testNbResults(aBox13, 0)
112 print "box13 : ko (" + aBox13.feature().error() + ")"
113 aSession.finishOperation()
114
115 aSession.startOperation()
116 aPoint1 = model.addPoint(aDocument, 0, 0, 0).result()
117 aPoint2 = model.selection("VERTEX", "point2")
118 aBox14 = model.addBox(aDocument, aPoint1, aPoint2)
119 model.testNbResults(aBox14, 0)
120 print "box14 : ko (" + aBox14.feature().error() + ")"
121 aSession.finishOperation()
122
123 aSession.startOperation()
124 Sketch_1 = model.addSketch(aDocument, model.defaultPlane("XOY"))
125 Sketch_2 = model.addSketch(aDocument, model.defaultPlane("YOZ"))
126 SketchLine_1 = Sketch_1.addLine(20, 10, 40, 10)
127 SketchLine_2 = Sketch_1.addLine(40, 10, 40, 20)
128 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
129 SketchLine_3 = Sketch_1.addLine(40, 20, 20, 20)
130 SketchLine_4 = Sketch_1.addLine(20, 20, 20, 10)
131 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
132 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint())
133 SketchLine_5 = Sketch_2.addLine(20, 10, 40, 10)
134 SketchLine_6 = Sketch_2.addLine(40, 10, 40, 20)
135 SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
136 SketchLine_7 = Sketch_2.addLine(40, 20, 20, 20)
137 SketchLine_8 = Sketch_2.addLine(20, 20, 20, 10)
138 SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
139 SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_8.endPoint())
140 aSession.finishOperation()
141
142 aSession.startOperation()
143 aBox15 = model.addBox(aDocument, model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e"),
144                       model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e"))
145
146 model.testNbResults(aBox15, 1)
147 model.testNbSubShapes(aBox15, GeomAPI_Shape.SOLID, [1])
148 model.testNbSubShapes(aBox15, GeomAPI_Shape.FACE, [6])
149 print "box15 : ok"
150 aSession.finishOperation()
151
152 aSession.startOperation()
153 Extrusion_1 = model.addExtrusion(aDocument, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0)
154 Extrusion_2 = model.addExtrusion(aDocument, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "PartSet/OX"), 100, 0)
155 aBox16 = model.addBox(aDocument, model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"),
156                        model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_1&Extrusion_2_1/To_Face_1"))
157 model.testNbResults(aBox16, 1)
158 model.testNbSubShapes(aBox16, GeomAPI_Shape.SOLID, [1])
159 model.testNbSubShapes(aBox16, GeomAPI_Shape.FACE, [6])
160 print "box16 : ok"
161 aSession.finishOperation()
162
163 aSession.startOperation()
164 Vertex_1 = model.addVertex(aDocument, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e")])
165 Vertex_2 = model.addVertex(aDocument, [model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e")])
166 aBox17 = model.addBox(aDocument, model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1"))
167 model.testNbResults(aBox17, 1)
168 model.testNbSubShapes(aBox17, GeomAPI_Shape.SOLID, [1])
169 model.testNbSubShapes(aBox17, GeomAPI_Shape.FACE, [6])
170 print "box17 : ok"
171 aSession.finishOperation()