Salome HOME
updated copyright message
[modules/shaper.git] / src / GDMLPlugin / Test / TestEllipsoid.py
1 # Copyright (C) 2018-2023  CEA, EDF
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 from salome.shaper import model
21 from GeomAPI import GeomAPI_Shape
22
23 model.begin()
24 partSet = model.moduleDocument()
25
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Ellipsoid_1 = model.addEllipsoid(Part_1_doc, 10, 20, 40)
29
30 model.testNbResults(Ellipsoid_1, 1)
31 model.testNbSubResults(Ellipsoid_1, [0])
32 model.testNbSubShapes(Ellipsoid_1, GeomAPI_Shape.SOLID, [1])
33 model.testNbSubShapes(Ellipsoid_1, GeomAPI_Shape.FACE, [1])
34 model.testNbSubShapes(Ellipsoid_1, GeomAPI_Shape.EDGE, [4])
35 model.testNbSubShapes(Ellipsoid_1, GeomAPI_Shape.VERTEX, [8])
36 model.testResultsVolumes(Ellipsoid_1, [4188.80255909031])
37
38 Part_2 = model.addPart(partSet)
39 Part_2_doc = Part_2.document()
40 Ellipsoid_2 = model.addEllipsoid(Part_2_doc, 20, 10, 30, 5, 5)
41
42 model.testNbResults(Ellipsoid_2, 1)
43 model.testNbSubResults(Ellipsoid_2, [0])
44 model.testNbSubShapes(Ellipsoid_2, GeomAPI_Shape.SOLID, [1])
45 model.testNbSubShapes(Ellipsoid_2, GeomAPI_Shape.FACE, [3])
46 model.testNbSubShapes(Ellipsoid_2, GeomAPI_Shape.EDGE, [6])
47 model.testNbSubShapes(Ellipsoid_2, GeomAPI_Shape.VERTEX, [12])
48 model.testResultsVolumes(Ellipsoid_2, [1512.62177363772])
49
50 Part_3 = model.addPart(partSet)
51 Part_3_doc = Part_3.document()
52 Ellipsoid_3 = model.addEllipsoid(Part_3_doc, 20, 20, 40)
53 Ellipsoid_3.setZCut1(5)
54
55 model.testNbResults(Ellipsoid_3, 1)
56 model.testNbSubResults(Ellipsoid_3, [0])
57 model.testNbSubShapes(Ellipsoid_3, GeomAPI_Shape.SOLID, [1])
58 model.testNbSubShapes(Ellipsoid_3, GeomAPI_Shape.FACE, [2])
59 model.testNbSubShapes(Ellipsoid_3, GeomAPI_Shape.EDGE, [7])
60 model.testNbSubShapes(Ellipsoid_3, GeomAPI_Shape.VERTEX, [14])
61 model.testResultsVolumes(Ellipsoid_3, [5726.87643051263])
62
63 Part_4 = model.addPart(partSet)
64 Part_4_doc = Part_4.document()
65 Ellipsoid_4 = model.addEllipsoid(Part_4_doc, 20, 20, 40)
66 Ellipsoid_4.setZCut2(5)
67
68 model.testNbResults(Ellipsoid_4, 1)
69 model.testNbSubResults(Ellipsoid_4, [0])
70 model.testNbSubShapes(Ellipsoid_4, GeomAPI_Shape.SOLID, [1])
71 model.testNbSubShapes(Ellipsoid_4, GeomAPI_Shape.FACE, [2])
72 model.testNbSubShapes(Ellipsoid_4, GeomAPI_Shape.EDGE, [7])
73 model.testNbSubShapes(Ellipsoid_4, GeomAPI_Shape.VERTEX, [14])
74 model.testResultsVolumes(Ellipsoid_4, [5726.87643051263])
75
76 # Check ellipsoid errors
77 Part_5 = model.addPart(partSet)
78 Part_5_doc = Part_5.document()
79 Ellipsoid_5 = model.addEllipsoid(Part_5_doc, 0, 20, 30)
80 model.do()
81 assert(Ellipsoid_5.feature().error() != "")
82 Part_5_doc.removeFeature(Ellipsoid_5.feature())
83
84 Ellipsoid_5 = model.addEllipsoid(Part_5_doc, 10, 0, 30)
85 model.do()
86 assert(Ellipsoid_5.feature().error() != "")
87 Part_5_doc.removeFeature(Ellipsoid_5.feature())
88
89 Ellipsoid_5 = model.addEllipsoid(Part_5_doc, 10, 20, 0)
90 model.do()
91 assert(Ellipsoid_5.feature().error() != "")
92 Part_5_doc.removeFeature(Ellipsoid_5.feature())
93
94 Ellipsoid_5 = model.addEllipsoid(Part_5_doc, 10, 20, 30, -5, 5)
95 model.do()
96 assert(Ellipsoid_5.feature().error() != "")
97 Part_5_doc.removeFeature(Ellipsoid_5.feature())
98
99 Ellipsoid_5 = model.addEllipsoid(Part_5_doc, 10, 20, 30, 5, -5)
100 model.do()
101 assert(Ellipsoid_5.feature().error() != "")
102 Part_5_doc.removeFeature(Ellipsoid_5.feature())
103
104 Ellipsoid_5 = model.addEllipsoid(Part_5_doc, 10, 20, 30, 0, 0)
105 model.do()
106 assert(Ellipsoid_5.feature().error() != "")
107 Part_5_doc.removeFeature(Ellipsoid_5.feature())
108
109 partSet.removeFeature(Part_5.feature())
110
111 model.end()
112
113 assert(model.checkPythonDump())