1 # Copyright (C) 2017-2024 CEA, EDF
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 from salome.shaper import model
22 partSet = model.moduleDocument()
23 Part_1 = model.addPart(partSet)
24 Part_1_doc = Part_1.document()
27 model.addParameter(Part_1_doc, "rmin", "10")
28 model.addParameter(Part_1_doc, "rmax", "12")
29 model.addParameter(Part_1_doc, "h", "20.5")
32 Tube_1 = model.addTube(Part_1_doc, 3, 5, 12)
33 Tube_2 = model.addTube(Part_1_doc, "rmin", "rmax", "h")
34 Tube_3 = model.addTube(Part_1_doc, 5, 3, 12)
35 Tube_4 = model.addTube(Part_1_doc, -2.5, 5, 12)
36 Tube_5 = model.addTube(Part_1_doc, 3, 5, -10)
42 from GeomAPI import GeomAPI_Shape
44 model.testNbResults(Tube_1, 1)
45 model.testNbSubResults(Tube_1, [0])
46 model.testNbSubShapes(Tube_1, GeomAPI_Shape.SOLID, [1])
47 model.testNbSubShapes(Tube_1, GeomAPI_Shape.FACE, [4])
48 model.testHaveNamingFaces(Tube_1, model, Part_1_doc)
50 model.testNbResults(Tube_2, 1)
51 model.testNbSubResults(Tube_2, [0])
52 model.testNbSubShapes(Tube_2, GeomAPI_Shape.SOLID, [1])
53 model.testNbSubShapes(Tube_2, GeomAPI_Shape.FACE, [4])
54 model.testHaveNamingFaces(Tube_2, model, Part_1_doc)
56 model.testNbResults(Tube_3, 0)
57 print(Tube_3.feature().error())
58 assert(Tube_3.feature().error() == "Tube builder :: rmin is greater then or equal to rmax.")
60 model.testNbResults(Tube_4, 0)
61 print(Tube_4.feature().error())
62 assert(Tube_4.feature().error() == "Tube builder :: rmin is negative.")
64 model.testNbResults(Tube_5, 0)
65 print(Tube_5.feature().error())
66 assert(Tube_5.feature().error() == "Tube builder :: z is negative or null.")