Salome HOME
cf80aab10c0eea6dc6390dfb500ee63520e93bbb
[modules/shaper.git] / test.API / SHAPER / Primitives / TestSphere.py
1 from salome.shaper import model
2
3 model.begin()
4 partSet = model.moduleDocument()
5 Part_1 = model.addPart(partSet)
6 Part_1_doc = Part_1.document()
7
8 # Init
9 Point_1 = model.addPoint(Part_1_doc, 10, 10, 10).result()
10 Point_2 = model.selection("VERTEX", "pnt")
11
12 # Parameters
13 model.addParameter(Part_1_doc, "r", "5")
14
15 # Tests
16 Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10)
17 Sphere_2 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 0)
18 Sphere_3 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), -5)
19 Sphere_4 = model.addSphere(Part_1_doc, Point_1, 10)
20 Sphere_5 = model.addSphere(Part_1_doc, Point_2, 10)
21 Sphere_6 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r")
22
23 model.do()
24 model.end()
25
26 # Checks
27 from GeomAPI import GeomAPI_Shape
28
29 model.testNbResults(Sphere_1, 1)
30 model.testNbSubResults(Sphere_1, [0])
31 model.testNbSubShapes(Sphere_1, GeomAPI_Shape.SOLID, [1])
32 model.testNbSubShapes(Sphere_1, GeomAPI_Shape.FACE, [1])
33 model.testHaveNamingFaces(Sphere_1, model, Part_1_doc)
34
35 model.testNbResults(Sphere_4, 1)
36 model.testNbSubResults(Sphere_4, [0])
37 model.testNbSubShapes(Sphere_4, GeomAPI_Shape.SOLID, [1])
38 model.testNbSubShapes(Sphere_4, GeomAPI_Shape.FACE, [1])
39 model.testHaveNamingFaces(Sphere_4, model, Part_1_doc)
40
41 model.testNbResults(Sphere_6, 1)
42 model.testNbSubResults(Sphere_6, [0])
43 model.testNbSubShapes(Sphere_6, GeomAPI_Shape.SOLID, [1])
44 model.testNbSubShapes(Sphere_6, GeomAPI_Shape.FACE, [1])
45 model.testHaveNamingFaces(Sphere_4, model, Part_1_doc)
46
47 model.testNbResults(Sphere_2, 0)
48 assert(Sphere_2.feature().error() == "Sphere builder :: radius is negative or null.")
49
50 model.testNbResults(Sphere_3, 0)
51 assert(Sphere_3.feature().error() == "Sphere builder :: radius is negative or null.")
52
53 model.testNbResults(Sphere_5, 0)
54 assert(Sphere_5.feature().error() == "Attribute \"center_point\" is not initialized.")