Salome HOME
Add tests.
[modules/shaper.git] / test.API / SHAPER / GDML / TestConeSegment.py
1 """
2 Test case for GDML Primitive Cone Segment feature. 
3 Written on High API.
4 """
5 from salome.shaper import model
6
7 model.begin()
8 partSet = model.moduleDocument()
9 Part_1 = model.addPart(partSet)
10 Part_1_doc = Part_1.document()
11
12 # Parameters
13 model.addParameter(Part_1_doc, "rmin1", "7")
14 model.addParameter(Part_1_doc, "rmax1", "11")
15 model.addParameter(Part_1_doc, "rmin2", "5")
16 model.addParameter(Part_1_doc, "rmax2", "8")
17 model.addParameter(Part_1_doc, "z", "12")
18 model.addParameter(Part_1_doc, "startphi", "0")
19 model.addParameter(Part_1_doc, "deltaphi", "270")
20
21 CS1 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 0 , 270)
22 CS2 = model.addConeSegment(Part_1_doc, 5, 10, 7, 15, 15, 45 , 180)
23 CS3 = model.addConeSegment(Part_1_doc, 5, 10, 7, 15, 15, -45 , 180)
24 CS4 = model.addConeSegment(Part_1_doc, 0, 10, 2, 7, 3, 0 , 270)
25 CS5 = model.addConeSegment(Part_1_doc, 5, 8, 0, 6, 10, 45 , 270)
26 CS6 = model.addConeSegment(Part_1_doc, 0, 6, 0, 4, 17, 0 , 270)
27 CS7 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 0 , 360)
28 CS8 = model.addConeSegment(Part_1_doc, -5, 11, 5, 8, 12, 0 , 270)
29 CS9 = model.addConeSegment(Part_1_doc, 11, 7, 5, 8, 12, 0 , 270)
30 CS10 = model.addConeSegment(Part_1_doc, 7, 11, 8, 5, 12, 0 , 270)
31 CS11 = model.addConeSegment(Part_1_doc, 7, 11, -3, 5, 12, 0 , 270)
32 CS12 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 0, 0 , 270)
33 CS13 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, -10, 0 , 270)
34 CS14 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, -45 , -45)
35 CS15 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 45 , 450)
36 CS16 = model.addConeSegment(Part_1_doc, "rmin1", "rmax1", "rmin2", "rmax2", "z", "startphi" , "deltaphi")
37 model.do()
38 model.end()
39
40 # Checks
41 from GeomAPI import GeomAPI_Shape
42
43 model.testNbResults(CS1, 1)
44 model.testNbSubResults(CS1, [0])
45 model.testNbSubShapes(CS1, GeomAPI_Shape.SOLID, [1])
46 model.testNbSubShapes(CS1, GeomAPI_Shape.FACE, [6])
47 model.testHaveNamingFaces(CS1, model, Part_1_doc)
48
49 model.testNbResults(CS2, 1)
50 model.testNbSubResults(CS2, [0])
51 model.testNbSubShapes(CS2, GeomAPI_Shape.SOLID, [1])
52 model.testNbSubShapes(CS2, GeomAPI_Shape.FACE, [6])
53 model.testHaveNamingFaces(CS2, model, Part_1_doc)
54
55 model.testNbResults(CS3, 1)
56 model.testNbSubResults(CS3, [0])
57 model.testNbSubShapes(CS3, GeomAPI_Shape.SOLID, [1])
58 model.testNbSubShapes(CS3, GeomAPI_Shape.FACE, [6])
59 model.testHaveNamingFaces(CS3, model, Part_1_doc)
60
61 model.testNbResults(CS4, 1)
62 model.testNbSubResults(CS4, [0])
63 model.testNbSubShapes(CS4, GeomAPI_Shape.SOLID, [1])
64 model.testNbSubShapes(CS4, GeomAPI_Shape.FACE, [6])
65 model.testHaveNamingFaces(CS4, model, Part_1_doc)
66
67 model.testNbResults(CS5, 1)
68 model.testNbSubResults(CS5, [0])
69 model.testNbSubShapes(CS5, GeomAPI_Shape.SOLID, [1])
70 model.testNbSubShapes(CS5, GeomAPI_Shape.FACE, [6])
71 model.testHaveNamingFaces(CS5, model, Part_1_doc)
72
73 model.testNbResults(CS6, 1)
74 model.testNbSubResults(CS6, [0])
75 model.testNbSubShapes(CS6, GeomAPI_Shape.SOLID, [1])
76 model.testNbSubShapes(CS6, GeomAPI_Shape.FACE, [5])
77 model.testHaveNamingFaces(CS6, model, Part_1_doc)
78
79 model.testNbResults(CS7, 1)
80 model.testNbSubResults(CS7, [0])
81 model.testNbSubShapes(CS7, GeomAPI_Shape.SOLID, [1])
82 model.testNbSubShapes(CS7, GeomAPI_Shape.FACE, [4])
83 model.testHaveNamingFaces(CS7, model, Part_1_doc)
84
85 model.testNbResults(CS16, 1)
86 model.testNbSubResults(CS16, [0])
87 model.testNbSubShapes(CS16, GeomAPI_Shape.SOLID, [1])
88 model.testNbSubShapes(CS16, GeomAPI_Shape.FACE, [6])
89 model.testHaveNamingFaces(CS16, model, Part_1_doc)
90
91 model.testNbResults(CS8, 0)
92 assert(CS8.feature().error() == "Cone Segment builder :: rmin1 is negative.")
93
94 model.testNbResults(CS9, 0)
95 assert(CS9.feature().error() == "Cone Segment builder :: rmin1 is larger than rmax1.")
96
97 model.testNbResults(CS10, 0)
98 assert(CS10.feature().error() == "Cone Segment builder :: rmin2 is larger than rmax2.")
99
100 model.testNbResults(CS11, 0)
101 assert(CS11.feature().error() == "Cone Segment builder :: rmin2 is negative.")
102
103 model.testNbResults(CS12, 0)
104 assert(CS12.feature().error() == "Cone Segment builder :: z is negative or null.")
105
106 model.testNbResults(CS13, 0)
107 assert(CS13.feature().error() == "Cone Segment builder :: z is negative or null.")
108
109 model.testNbResults(CS14, 0)
110 assert(CS14.feature().error() == "Cone Segment builder :: deltaphi is negative or null.")
111
112 model.testNbResults(CS15, 0)
113 assert(CS15.feature().error() == "Cone Segment builder :: deltaphi is larger than 360 degree.")