]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Adding torus tests for parametric API.
authorClarisse Genrault <clarisse.genrault@cea.fr>
Mon, 2 Oct 2017 13:52:09 +0000 (15:52 +0200)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Mon, 2 Oct 2017 13:52:09 +0000 (15:52 +0200)
test.API/SHAPER/CMakeLists.txt
test.API/SHAPER/Primitives/TestTorus.py [new file with mode: 0644]

index 46dad6a534cc97ae5f5cf7d88ba64a06165422da..f29553032c48f6e086764a670226980a5c3b4c0c 100644 (file)
@@ -25,6 +25,7 @@ ADD_UNIT_TESTS_API(
   Primitives/TestCone.py
   Primitives/TestCylinder.py
   Primitives/TestSphere.py
+  Primitives/TestTorus.py
   Primitives/TestAPI_Box.py
   Primitives/TestAPI_Cylinder.py
   GDML/TestConeSegment.py
diff --git a/test.API/SHAPER/Primitives/TestTorus.py b/test.API/SHAPER/Primitives/TestTorus.py
new file mode 100644 (file)
index 0000000..a60d9da
--- /dev/null
@@ -0,0 +1,80 @@
+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, "r", "10")
+model.addParameter(Part_1_doc, "ring", "3")
+
+# Tests
+Torus_1 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 15, 3)
+Torus_2 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Torus_3 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 0, 3)
+Torus_4 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), -10, 3)
+Torus_5 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 15, 0)
+Torus_6 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 15, -3)
+Torus_7 = model.addTorus(Part_1_doc, Point_1, model.selection("EDGE", "PartSet/OX"), 12, 7)
+Torus_8 = model.addTorus(Part_1_doc, Point_1, Axis_1, 15, 4)
+Torus_9 = model.addTorus(Part_1_doc, Point_2, model.selection("EDGE", "PartSet/OZ"), 15, 4)
+Torus_10 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), Axis_2, 15, 4)
+Torus_11 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r", "ring")
+
+model.do()
+model.end()
+
+# Checks
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Torus_1, 1)
+model.testNbSubResults(Torus_1, [0])
+model.testNbSubShapes(Torus_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Torus_1, GeomAPI_Shape.FACE, [1])
+model.testHaveNamingFaces(Torus_1, model, Part_1_doc)
+
+model.testNbResults(Torus_7, 1)
+model.testNbSubResults(Torus_7, [0])
+model.testNbSubShapes(Torus_7, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Torus_7, GeomAPI_Shape.FACE, [1])
+model.testHaveNamingFaces(Torus_7, model, Part_1_doc)
+
+model.testNbResults(Torus_8, 1)
+model.testNbSubResults(Torus_8, [0])
+model.testNbSubShapes(Torus_8, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Torus_8, GeomAPI_Shape.FACE, [1])
+model.testHaveNamingFaces(Torus_8, model, Part_1_doc)
+
+model.testNbResults(Torus_11, 1)
+model.testNbSubResults(Torus_11, [0])
+model.testNbSubShapes(Torus_11, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Torus_11, GeomAPI_Shape.FACE, [1])
+model.testHaveNamingFaces(Torus_11, model, Part_1_doc)
+
+model.testNbResults(Torus_2, 0)
+assert(Torus_2.feature().error() == "Torus builder :: ring radius is greater than the radius.")
+
+model.testNbResults(Torus_3, 0)
+assert(Torus_3.feature().error() == "Torus builder :: radius is negative or null.")
+
+model.testNbResults(Torus_4, 0)
+assert(Torus_4.feature().error() == "Torus builder :: radius is negative or null.")
+
+model.testNbResults(Torus_5, 0)
+assert(Torus_5.feature().error() == "Torus builder :: ring radius is negative or null.")
+
+model.testNbResults(Torus_6, 0)
+assert(Torus_6.feature().error() == "Torus builder :: ring radius is negative or null.")
+
+model.testNbResults(Torus_9, 0)
+assert(Torus_9.feature().error() == "Attribute \"base_point\" is not initialized.")
+
+model.testNbResults(Torus_10, 0)
+assert(Torus_10.feature().error() == "Attribute \"axis\" is not initialized.")