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