]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add test for ShapeAPI translation.
authorClarisse Genrault <clarisse.genrault@cea.fr>
Mon, 21 Nov 2016 15:00:03 +0000 (16:00 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Mon, 21 Nov 2016 15:00:03 +0000 (16:00 +0100)
src/FeaturesAPI/APIParam_Translation.py [deleted file]
src/FeaturesAPI/Test/APIParam_Translation.py [new file with mode: 0644]
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/Test/TestAPI_Translation.py [new file with mode: 0644]

diff --git a/src/FeaturesAPI/APIParam_Translation.py b/src/FeaturesAPI/APIParam_Translation.py
deleted file mode 100644 (file)
index 53b1767..0000000
+++ /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 (file)
index 0000000..53b1767
--- /dev/null
@@ -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
index 75015c1f351383375ee8c24eba6154934533cf20..783cbf3851673ab5f2185f2874acfb7f94397052 100644 (file)
@@ -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 (file)
index 0000000..0d405fb
--- /dev/null
@@ -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()