From fcc66b5a49bafd39c7b87bf8914ea2be0d89d7af Mon Sep 17 00:00:00 2001 From: Clarisse Genrault Date: Mon, 20 Apr 2020 14:16:51 +0200 Subject: [PATCH] Add test for the new mode of a sphere --- src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp | 5 ++++- test.API/SHAPER/Primitives/TestAPI_Sphere.py | 6 ++++++ test.API/SHAPER/Primitives/TestSphere.py | 12 ++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp index 6f4f673e4..6c75f7f70 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp @@ -59,7 +59,10 @@ GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere(const double theRMin, const double theRMa bool GeomAlgoAPI_Sphere::check() { if (isRootGeo) { - // traitement a faire plus tard + if ((myRMin-myRMax) > Precision::Confusion()) { + myError = "Sphere builder :: RMin is larger than RMax."; + return false; + } } else { if (!myCenterPoint) { myError = "Sphere builder :: center is not valid."; diff --git a/test.API/SHAPER/Primitives/TestAPI_Sphere.py b/test.API/SHAPER/Primitives/TestAPI_Sphere.py index 1717a7267..6d5c9c802 100644 --- a/test.API/SHAPER/Primitives/TestAPI_Sphere.py +++ b/test.API/SHAPER/Primitives/TestAPI_Sphere.py @@ -41,3 +41,9 @@ try: Sphere_5 = shaperpy.makeSphere(None, 10.) except myExcept as ec: assert(ec.what() == "Sphere builder :: center is not valid.") + +Sphere_6 = shaperpy.makeSphere(10., 40.,0,180.,0.,180.) +try: + Sphere_7 = shaperpy.makeSphere(40., 10.,0,180.,0.,180.) +except myExcept as ec: + assert(ec.what() == "Sphere builder :: RMin is larger than RMax.") \ No newline at end of file diff --git a/test.API/SHAPER/Primitives/TestSphere.py b/test.API/SHAPER/Primitives/TestSphere.py index d7e599aa5..70690a334 100644 --- a/test.API/SHAPER/Primitives/TestSphere.py +++ b/test.API/SHAPER/Primitives/TestSphere.py @@ -41,6 +41,9 @@ Sphere_6 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin Sphere_7 = model.addSphere(Part_1_doc, 10) Sphere_7.setCenterPoint(Point_1) +Sphere_8 = model.addSphere(Part_1_doc,10,40,0,180,0,180) +Sphere_9 = model.addSphere(Part_1_doc,40,10,0,180,0,180) + model.do() model.end() @@ -71,6 +74,12 @@ model.testNbSubShapes(Sphere_7, GeomAPI_Shape.SOLID, [1]) model.testNbSubShapes(Sphere_7, GeomAPI_Shape.FACE, [1]) model.testHaveNamingFaces(Sphere_7, model, Part_1_doc) +model.testNbResults(Sphere_8, 1) +model.testNbSubResults(Sphere_8, [0]) +model.testNbSubShapes(Sphere_8, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Sphere_8, GeomAPI_Shape.FACE, [4]) +model.testHaveNamingFaces(Sphere_8, model, Part_1_doc) + model.testNbResults(Sphere_2, 0) assert(Sphere_2.feature().error() == "Sphere builder :: radius is negative or null.") @@ -79,3 +88,6 @@ assert(Sphere_3.feature().error() == "Sphere builder :: radius is negative or nu model.testNbResults(Sphere_5, 0) assert(Sphere_5.feature().error() == "Attribute \"center_point\" is not initialized.") + +model.testNbResults(Sphere_9, 0) +assert(Sphere_9.feature().error() == "Sphere builder :: RMin is larger than RMax.") -- 2.39.2