From 0fb6e72c562c3df310a698f37455b1af32ceb45a Mon Sep 17 00:00:00 2001 From: Clarisse Genrault Date: Mon, 2 Oct 2017 15:22:13 +0200 Subject: [PATCH] Adding cone tests for parametric API. --- test.API/SHAPER/Primitives/TestCone.py | 106 +++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 test.API/SHAPER/Primitives/TestCone.py diff --git a/test.API/SHAPER/Primitives/TestCone.py b/test.API/SHAPER/Primitives/TestCone.py new file mode 100644 index 000000000..ebe3d5086 --- /dev/null +++ b/test.API/SHAPER/Primitives/TestCone.py @@ -0,0 +1,106 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Init +Point_1 = model.addPoint(Part_1_doc, 10, 10, 10).result() +Point_2 = model.selection("VERTEX", "pnt") +Axis_1 = model.addAxis(Part_1_doc, 0, 10, 0).result() +Axis_2 = model.selection("EDGE", "edge") + +# Parameters +model.addParameter(Part_1_doc, "baseRadius", "10") +model.addParameter(Part_1_doc, "topRadius", "7") +model.addParameter(Part_1_doc, "h", "15") + +# Tests +Cone_1 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10., 5., 10.) +Cone_2 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5., 10., 10.) +Cone_3 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 0., 5., 10.) +Cone_4 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), -3., 5., 10.) +Cone_5 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10., 0., 10.) +Cone_6 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10., -5., 10.) +Cone_7 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10., 5., 0.) +Cone_8 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10., 5., -10.) +Cone_9 = model.addCone(Part_1_doc, Point_1, model.selection("EDGE", "PartSet/OZ"), 10., 7., 15.) +Cone_10 = model.addCone(Part_1_doc, Point_1, Axis_1, 10., 7., 15.) +Cone_11 = model.addCone(Part_1_doc, Point_2, model.selection("EDGE", "PartSet/OZ"), 10., 7., 15.) +Cone_12= model.addCone(Part_1_doc, Point_1, Axis_2, 10., 7., 15.) +Cone_13 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 0., 0., 15.) +Cone_14 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10., 10., 15.) +Cone_15 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "baseRadius", "topRadius", "h") + +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cone_1, 1) +model.testNbSubResults(Cone_1, [0]) +model.testNbSubShapes(Cone_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cone_1, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cone_1, model, Part_1_doc) + +model.testNbResults(Cone_2, 1) +model.testNbSubResults(Cone_2, [0]) +model.testNbSubShapes(Cone_2, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cone_2, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cone_2, model, Part_1_doc) + +model.testNbResults(Cone_3, 1) +model.testNbSubResults(Cone_3, [0]) +model.testNbSubShapes(Cone_3, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cone_3, GeomAPI_Shape.FACE, [2]) +model.testHaveNamingFaces(Cone_3, model, Part_1_doc) + +model.testNbResults(Cone_5, 1) +model.testNbSubResults(Cone_5, [0]) +model.testNbSubShapes(Cone_5, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cone_5, GeomAPI_Shape.FACE, [2]) +model.testHaveNamingFaces(Cone_5, model, Part_1_doc) + +model.testNbResults(Cone_9, 1) +model.testNbSubResults(Cone_9, [0]) +model.testNbSubShapes(Cone_9, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cone_9, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cone_9, model, Part_1_doc) + +model.testNbResults(Cone_10, 1) +model.testNbSubResults(Cone_10, [0]) +model.testNbSubShapes(Cone_10, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cone_10, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cone_10, model, Part_1_doc) + +model.testNbResults(Cone_15, 1) +model.testNbSubResults(Cone_15, [0]) +model.testNbSubShapes(Cone_15, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cone_15, GeomAPI_Shape.FACE, [3]) +model.testHaveNamingFaces(Cone_15, model, Part_1_doc) + +model.testNbResults(Cone_4, 0) +assert(Cone_4.feature().error() == "Cone builder :: base radius is negative.") + +model.testNbResults(Cone_6, 0) +assert(Cone_6.feature().error() == "Cone builder :: top radius is negative.") + +model.testNbResults(Cone_7, 0) +assert(Cone_7.feature().error() == "Cone builder :: height is negative or null.") + +model.testNbResults(Cone_8, 0) +assert(Cone_8.feature().error() == "Cone builder :: height is negative or null.") + +model.testNbResults(Cone_11, 0) +assert(Cone_11.feature().error() == "Attribute \"base_point\" is not initialized.") + +model.testNbResults(Cone_12, 0) +assert(Cone_12.feature().error() == "Attribute \"axis\" is not initialized.") + +model.testNbResults(Cone_13, 0) +assert(Cone_13.feature().error() == "Cone builder :: base radius and top radius are negative or null.") + +model.testNbResults(Cone_14, 0) +assert(Cone_14.feature().error() == "Cone builder :: base radius and top radius are too close.") -- 2.39.2