From: Clarisse Genrault Date: Mon, 21 Nov 2016 14:45:43 +0000 (+0100) Subject: Correction following Mikhail's mail (21/11/2016). X-Git-Tag: V_2.6.0~74 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0c9b5c21593b0a8a1319502a56e505ffe24a4a4d;p=modules%2Fshaper.git Correction following Mikhail's mail (21/11/2016). --- diff --git a/src/FeaturesAPI/APIParam_Translation.py b/src/FeaturesAPI/APIParam_Translation.py new file mode 100644 index 000000000..53b176781 --- /dev/null +++ b/src/FeaturesAPI/APIParam_Translation.py @@ -0,0 +1,35 @@ +""" +Test case for Translation feature. +Written on High API. +""" +from ModelAPI import * +from GeomAPI import * + +import model + +# Get session +aSession = ModelAPI_Session.get() + +# Create a part +aDocument = aSession.activeDocument() +aSession.startOperation() +model.addPart(aDocument) +aDocument = aSession.activeDocument() +aSession.finishOperation() + +# Create a box + +aSession.startOperation() +aBox = model.addBox(aDocument, 10, 10, 10) + +# Perform a translation by an axis and a distance +aSession.startOperation() +aTranslation1 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Bottom"), 20).result() +aSession.finishOperation() +assert (aTranslation1 is not None) + +# Perform a translation by DX, DY, DZ vector +aSession.startOperation() +aTranslation2 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], 10, 10, 10).result() +aSession.finishOperation() +assert (aTranslation2 is not None) \ No newline at end of file diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index 3f4e5fe9a..155141244 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -1,6 +1,7 @@ -## Copyright (C) 2014-20xx CEA/DEN, EDF R&D +## Copyright (C) 2014-2016 CEA/DEN, EDF R&D INCLUDE(Common) +INCLUDE(UnitTest) SET(PROJECT_HEADERS FeaturesAPI.h @@ -90,3 +91,5 @@ ENDIF(WIN32) INSTALL(TARGETS _FeaturesAPI DESTINATION ${SHAPER_INSTALL_SWIG}) INSTALL(TARGETS FeaturesAPI DESTINATION ${SHAPER_INSTALL_BIN}) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/FeaturesAPI.py DESTINATION ${SHAPER_INSTALL_SWIG}) + +ADD_UNIT_TESTS(APIParam_Translation.py) \ No newline at end of file diff --git a/src/FeaturesAPI/FeaturesAPI_Translation.h b/src/FeaturesAPI/FeaturesAPI_Translation.h index 7a14f8a88..91f3e7e14 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.h +++ b/src/FeaturesAPI/FeaturesAPI_Translation.h @@ -30,15 +30,15 @@ public: /// Constructor with values. FEATURESAPI_EXPORT - FeaturesAPI_Translation(const std::shared_ptr& theFeature, - const std::list& theMainObjects, - const ModelHighAPI_Selection& theAxisObject, - const ModelHighAPI_Double& theDistance); + explicit FeaturesAPI_Translation(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxisObject, + const ModelHighAPI_Double& theDistance); /// Constructor with values. FEATURESAPI_EXPORT - FeaturesAPI_Translation(const std::shared_ptr& theFeature, - const std::list& theMainObjects, + explicit FeaturesAPI_Translation(const std::shared_ptr& theFeature, + const std::list& theMainObjects, const ModelHighAPI_Double& theDx, const ModelHighAPI_Double& theDy, const ModelHighAPI_Double& theDz); diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 53c6e292e..8afae28a6 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -131,5 +131,4 @@ ADD_UNIT_TESTS(TestExtrusion.py TestUnion.py TestRemoveSubShapes.py TestPipe.py - TestRecover.py - APIParam_Translation.py) + TestRecover.py) diff --git a/src/FeaturesPlugin/Test/APIParam_Translation.py b/src/FeaturesPlugin/Test/APIParam_Translation.py deleted file mode 100644 index 53b176781..000000000 --- a/src/FeaturesPlugin/Test/APIParam_Translation.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -Test case for Translation feature. -Written on High API. -""" -from ModelAPI import * -from GeomAPI import * - -import model - -# Get session -aSession = ModelAPI_Session.get() - -# Create a part -aDocument = aSession.activeDocument() -aSession.startOperation() -model.addPart(aDocument) -aDocument = aSession.activeDocument() -aSession.finishOperation() - -# Create a box - -aSession.startOperation() -aBox = model.addBox(aDocument, 10, 10, 10) - -# Perform a translation by an axis and a distance -aSession.startOperation() -aTranslation1 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Bottom"), 20).result() -aSession.finishOperation() -assert (aTranslation1 is not None) - -# Perform a translation by DX, DY, DZ vector -aSession.startOperation() -aTranslation2 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], 10, 10, 10).result() -aSession.finishOperation() -assert (aTranslation2 is not None) \ No newline at end of file diff --git a/src/FeaturesPlugin/Test/TestTranslation.py b/src/FeaturesPlugin/Test/TestTranslation.py index 8991ebad4..59208b43c 100644 --- a/src/FeaturesPlugin/Test/TestTranslation.py +++ b/src/FeaturesPlugin/Test/TestTranslation.py @@ -133,5 +133,5 @@ assert (len(aMoveFt.results()) > 0) aMoveResult = modelAPI_ResultBody(aMoveFt.firstResult()) assert (aMoveResult is not None) -#import model -#assert(model.checkPythonDump()) +import model +assert(model.checkPythonDump()) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp index 148bfacf8..9fee16ebf 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp @@ -45,7 +45,6 @@ bool GeomAlgoAPI_Translation::check() myError = "Translation builder :: axis is invalid."; return false; } - // TODO : verification de la distance if (!mySourceShape) { myError = "Translation builder :: source shape is invalid."; return false; @@ -53,12 +52,6 @@ bool GeomAlgoAPI_Translation::check() return true; } case BY_DIM: { - if ((fabs(myDx) < Precision::Confusion()) && - (fabs(myDy) < Precision::Confusion()) && - (fabs(myDz) < Precision::Confusion())) { - myError = "Translation builder :: Dx, Dy and Dz are null."; - return false; - } if (!mySourceShape) { myError = "Translation builder :: source shape is invalid."; return false;