From 8d7a1d0b17149a1a8841de65ba678fc2cdb81508 Mon Sep 17 00:00:00 2001 From: Clarisse Genrault Date: Fri, 24 Feb 2017 14:21:05 +0100 Subject: [PATCH] Corrections for tests. --- src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp | 4 ++-- src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp | 2 +- src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp | 9 +++++++++ src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp | 12 ++++++------ test.API/SHAPER/Primitives/TestAPI_Box.py | 8 ++++---- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp index 05b15667f..1e51608a3 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp @@ -48,11 +48,11 @@ bool GeomAlgoAPI_Box::check() } } else if (myMethodType == MethodType::BOX_POINTS) { if (!myFirstPoint.get()) { - myError = "Box builder with points :: the first point is not correct."; + myError = "Box builder with points :: the first point is not valid."; return false; } if (!mySecondPoint.get()) { - myError = "Box builder with points :: the second point is not correct."; + myError = "Box builder with points :: the second point is not valid."; return false; } if (myFirstPoint->distance(mySecondPoint) < Precision::Confusion()) { diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp index c08ab48df..a7512d382 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp @@ -48,7 +48,7 @@ GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder(std::shared_ptr theAxis, bool GeomAlgoAPI_Cylinder::check() { if (!myAxis) { - myError = "Cylinder builder :: axis is invalid."; + myError = "Cylinder builder :: axis is not valid."; return false; } if (myRadius < Precision::Confusion()) { diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp index a27dc623b..8b3539c26 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -70,6 +70,15 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr theBasePoint, std::shared_ptr theEdge, double theRadius, double theHeight) throw (GeomAlgoAPI_Exception) { + // Check if the base point is OK + if (!theBasePoint) { + throw GeomAlgoAPI_Exception("Cylinder builder :: the base point is not valid."); + } + // Check if the edge is OK + if (!theEdge) { + throw GeomAlgoAPI_Exception("Cylinder builder :: the axis is not valid."); + } + std::shared_ptr anAxis; anAxis = std::shared_ptr(new GeomAPI_Ax2(theBasePoint, theEdge->line()->direction())); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp index 55ed0e89c..3724bcf2e 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp @@ -53,29 +53,29 @@ bool GeomAlgoAPI_Translation::check() switch (myMethodType) { case BY_DISTANCE: { if (!myAxis) { - myError = "Translation builder :: axis is invalid."; + myError = "Translation builder :: axis is not valid."; return false; } if (!mySourceShape) { - myError = "Translation builder :: source shape is invalid."; + myError = "Translation builder :: source shape is not valid."; return false; } return true; } case BY_DIM: { if (!mySourceShape) { - myError = "Translation builder :: source shape is invalid."; + myError = "Translation builder :: source shape is not valid."; return false; } return true; } case BY_POINTS: { if (!myStartPoint) { - myError = "Translation builder :: start point is invalid."; + myError = "Translation builder :: start point is not valid."; return false; } if (!myEndPoint) { - myError = "Translation builder :: start point is invalid."; + myError = "Translation builder :: start point is not valid."; return false; } if (!mySourceShape) { @@ -146,4 +146,4 @@ void GeomAlgoAPI_Translation::build() aShape->setImpl(new TopoDS_Shape(aResult)); setShape(aShape); setDone(true); -} \ No newline at end of file +} diff --git a/test.API/SHAPER/Primitives/TestAPI_Box.py b/test.API/SHAPER/Primitives/TestAPI_Box.py index 0249e928b..92f66dca1 100644 --- a/test.API/SHAPER/Primitives/TestAPI_Box.py +++ b/test.API/SHAPER/Primitives/TestAPI_Box.py @@ -80,14 +80,14 @@ except myExcept,ec: assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : - Box_13 = shaperpy.makeBox(pnt2,None) + Box_13 = shaperpy.makeBox(None, pnt2) except myExcept,ec: - assert(ec.what() == "Box builder with points :: the second point is not correct.") + assert(ec.what() == "Box builder with points :: the first point is not valid.") try : - Box_14 = shaperpy.makeBox(None,pnt2) + Box_14 = shaperpy.makeBox(pnt2, None) except myExcept,ec: - assert(ec.what() == "Box builder with points :: the first point is not correct.") + assert(ec.what() == "Box builder with points :: the second point is not valid.") -- 2.39.2