Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / test.API / SHAPER / GDML / TestConeSegment.py
1 ## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 ##
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
7 ##
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 ## Lesser General Public License for more details.
12 ##
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 ##
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 """
22 Test case for GDML Primitive Cone Segment feature.
23 Written on High API.
24 """
25 from salome.shaper import model
26
27 model.begin()
28 partSet = model.moduleDocument()
29 Part_1 = model.addPart(partSet)
30 Part_1_doc = Part_1.document()
31
32 # Parameters
33 model.addParameter(Part_1_doc, "rmin1", "7")
34 model.addParameter(Part_1_doc, "rmax1", "11")
35 model.addParameter(Part_1_doc, "rmin2", "5")
36 model.addParameter(Part_1_doc, "rmax2", "8")
37 model.addParameter(Part_1_doc, "z", "12")
38 model.addParameter(Part_1_doc, "startphi", "0")
39 model.addParameter(Part_1_doc, "deltaphi", "270")
40
41 CS1 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 0 , 270)
42 CS2 = model.addConeSegment(Part_1_doc, 5, 10, 7, 15, 15, 45 , 180)
43 CS3 = model.addConeSegment(Part_1_doc, 5, 10, 7, 15, 15, -45 , 180)
44 CS4 = model.addConeSegment(Part_1_doc, 0, 10, 2, 7, 3, 0 , 270)
45 CS5 = model.addConeSegment(Part_1_doc, 5, 8, 0, 6, 10, 45 , 270)
46 CS6 = model.addConeSegment(Part_1_doc, 0, 6, 0, 4, 17, 0 , 270)
47 CS7 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 0 , 360)
48 CS8 = model.addConeSegment(Part_1_doc, -5, 11, 5, 8, 12, 0 , 270)
49 CS9 = model.addConeSegment(Part_1_doc, 11, 7, 5, 8, 12, 0 , 270)
50 CS10 = model.addConeSegment(Part_1_doc, 7, 11, 8, 5, 12, 0 , 270)
51 CS11 = model.addConeSegment(Part_1_doc, 7, 11, -3, 5, 12, 0 , 270)
52 CS12 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 0, 0 , 270)
53 CS13 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, -10, 0 , 270)
54 CS14 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, -45 , -45)
55 CS15 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 45 , 450)
56 CS16 = model.addConeSegment(Part_1_doc, "rmin1", "rmax1", "rmin2", "rmax2", "z", "startphi" , "deltaphi")
57 model.do()
58 model.end()
59
60 # Checks
61 from GeomAPI import GeomAPI_Shape
62
63 model.testNbResults(CS1, 1)
64 model.testNbSubResults(CS1, [0])
65 model.testNbSubShapes(CS1, GeomAPI_Shape.SOLID, [1])
66 model.testNbSubShapes(CS1, GeomAPI_Shape.FACE, [6])
67 model.testHaveNamingFaces(CS1, model, Part_1_doc)
68
69 model.testNbResults(CS2, 1)
70 model.testNbSubResults(CS2, [0])
71 model.testNbSubShapes(CS2, GeomAPI_Shape.SOLID, [1])
72 model.testNbSubShapes(CS2, GeomAPI_Shape.FACE, [6])
73 model.testHaveNamingFaces(CS2, model, Part_1_doc)
74
75 model.testNbResults(CS3, 1)
76 model.testNbSubResults(CS3, [0])
77 model.testNbSubShapes(CS3, GeomAPI_Shape.SOLID, [1])
78 model.testNbSubShapes(CS3, GeomAPI_Shape.FACE, [6])
79 model.testHaveNamingFaces(CS3, model, Part_1_doc)
80
81 model.testNbResults(CS4, 1)
82 model.testNbSubResults(CS4, [0])
83 model.testNbSubShapes(CS4, GeomAPI_Shape.SOLID, [1])
84 model.testNbSubShapes(CS4, GeomAPI_Shape.FACE, [6])
85 model.testHaveNamingFaces(CS4, model, Part_1_doc)
86
87 model.testNbResults(CS5, 1)
88 model.testNbSubResults(CS5, [0])
89 model.testNbSubShapes(CS5, GeomAPI_Shape.SOLID, [1])
90 model.testNbSubShapes(CS5, GeomAPI_Shape.FACE, [6])
91 model.testHaveNamingFaces(CS5, model, Part_1_doc)
92
93 model.testNbResults(CS6, 1)
94 model.testNbSubResults(CS6, [0])
95 model.testNbSubShapes(CS6, GeomAPI_Shape.SOLID, [1])
96 model.testNbSubShapes(CS6, GeomAPI_Shape.FACE, [5])
97 model.testHaveNamingFaces(CS6, model, Part_1_doc)
98
99 model.testNbResults(CS7, 1)
100 model.testNbSubResults(CS7, [0])
101 model.testNbSubShapes(CS7, GeomAPI_Shape.SOLID, [1])
102 model.testNbSubShapes(CS7, GeomAPI_Shape.FACE, [4])
103 model.testHaveNamingFaces(CS7, model, Part_1_doc)
104
105 model.testNbResults(CS16, 1)
106 model.testNbSubResults(CS16, [0])
107 model.testNbSubShapes(CS16, GeomAPI_Shape.SOLID, [1])
108 model.testNbSubShapes(CS16, GeomAPI_Shape.FACE, [6])
109 model.testHaveNamingFaces(CS16, model, Part_1_doc)
110
111 model.testNbResults(CS8, 0)
112 assert(CS8.feature().error() == "Cone Segment builder :: rmin1 is negative.")
113
114 model.testNbResults(CS9, 0)
115 assert(CS9.feature().error() == "Cone Segment builder :: rmin1 is larger than rmax1.")
116
117 model.testNbResults(CS10, 0)
118 assert(CS10.feature().error() == "Cone Segment builder :: rmin2 is larger than rmax2.")
119
120 model.testNbResults(CS11, 0)
121 assert(CS11.feature().error() == "Cone Segment builder :: rmin2 is negative.")
122
123 model.testNbResults(CS12, 0)
124 assert(CS12.feature().error() == "Cone Segment builder :: z is negative or null.")
125
126 model.testNbResults(CS13, 0)
127 assert(CS13.feature().error() == "Cone Segment builder :: z is negative or null.")
128
129 model.testNbResults(CS14, 0)
130 assert(CS14.feature().error() == "Cone Segment builder :: deltaphi is negative or null.")
131
132 model.testNbResults(CS15, 0)
133 assert(CS15.feature().error() == "Cone Segment builder :: deltaphi is larger than 360 degree.")