]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Correction following Mikhail's mail (21/11/2016).
authorClarisse Genrault <clarisse.genrault@cea.fr>
Mon, 21 Nov 2016 14:45:43 +0000 (15:45 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Mon, 21 Nov 2016 14:45:43 +0000 (15:45 +0100)
src/FeaturesAPI/APIParam_Translation.py [new file with mode: 0644]
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI_Translation.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/Test/APIParam_Translation.py [deleted file]
src/FeaturesPlugin/Test/TestTranslation.py
src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp

diff --git a/src/FeaturesAPI/APIParam_Translation.py b/src/FeaturesAPI/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 3f4e5fe9a4e25d0cb2a5f411041f3397df3bf037..155141244d859a7e4d789677bf557974bf120f27 100644 (file)
@@ -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
index 7a14f8a88940ab67f6992a6018fc6008f226c83a..91f3e7e1444fb3fd31794e6554ff40a8431a9b51 100644 (file)
@@ -30,15 +30,15 @@ public:
 
   /// Constructor with values.
   FEATURESAPI_EXPORT
-  FeaturesAPI_Translation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                          const std::list<ModelHighAPI_Selection>& theMainObjects,
-                          const ModelHighAPI_Selection& theAxisObject,
-                          const ModelHighAPI_Double& theDistance);
+  explicit FeaturesAPI_Translation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                   const std::list<ModelHighAPI_Selection>& theMainObjects,
+                                   const ModelHighAPI_Selection& theAxisObject,
+                                   const ModelHighAPI_Double& theDistance);
 
   /// Constructor with values.
   FEATURESAPI_EXPORT
-  FeaturesAPI_Translation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                          const std::list<ModelHighAPI_Selection>& theMainObjects,
+  explicit FeaturesAPI_Translation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                   const std::list<ModelHighAPI_Selection>& theMainObjects,
                           const ModelHighAPI_Double& theDx,
                           const ModelHighAPI_Double& theDy,
                           const ModelHighAPI_Double& theDz);
index 53c6e292ec6e312954fb08b1087d8c5810e3e132..8afae28a6758f8abcd9fa410f28fe2e176baef2d 100644 (file)
@@ -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 (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
index 8991ebad40a269a46f2ea488a835832a442d433e..59208b43c8b982a1bc33ea77201cc9968b4ca658 100644 (file)
@@ -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())
index 148bfacf8658fa71431e12bb905c5144e8e74dc6..9fee16ebf9495f790b2979f999034f28c10473f1 100644 (file)
@@ -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;