From: Clarisse Genrault Date: Mon, 21 Nov 2016 15:00:03 +0000 (+0100) Subject: Add test for ShapeAPI translation. X-Git-Tag: V_2.6.0~73 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=74cbc56bd08f0deaeffb3e049a6c09be87982ff6;p=modules%2Fshaper.git Add test for ShapeAPI translation. --- diff --git a/src/FeaturesAPI/APIParam_Translation.py b/src/FeaturesAPI/APIParam_Translation.py deleted file mode 100644 index 53b176781..000000000 --- a/src/FeaturesAPI/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/FeaturesAPI/Test/APIParam_Translation.py b/src/FeaturesAPI/Test/APIParam_Translation.py new file mode 100644 index 000000000..53b176781 --- /dev/null +++ b/src/FeaturesAPI/Test/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/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 75015c1f3..783cbf385 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -152,5 +152,5 @@ INSTALL(TARGETS GeomAlgoAPI DESTINATION ${SHAPER_INSTALL_BIN}) INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG}) ADD_UNIT_TESTS(TestAPI_Box.py -) + TestAPI_Translation.py) diff --git a/src/GeomAlgoAPI/Test/TestAPI_Translation.py b/src/GeomAlgoAPI/Test/TestAPI_Translation.py new file mode 100644 index 000000000..0d405fbaf --- /dev/null +++ b/src/GeomAlgoAPI/Test/TestAPI_Translation.py @@ -0,0 +1,35 @@ +# Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +# File: TestAPI_Translation.py +# Created: 15 Nov 2016 +# Author: Clarisse Genrault (CEA) + +from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy +from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept +from GeomAPI import GeomAPI_Ax1 as axis +from GeomAPI import GeomAPI_Pnt as pnt +from GeomAPI import GeomAPI_Dir as direction + +# Create a box +try : + box = shaperpy.makeBox(10.,10.,10.) + +except myExcept, ec: + print ec.what() + +# Perfom a translation with an axis and a distance. +try : + origin = pnt(0.,0.,0.) + xDir = direction(1.,0.,0.) + xAxis = axis(origin, xDir) + translation1 = shaperpy.makeTranslation(box,xAxis,15.) + +except myExcept, ec: + print ec.what() + +# Perfom a translation with dimensions. +try : + translation2 = shaperpy.makeTranslation(box,10,0,0) + +except myExcept, ec: + print ec.what()