Salome HOME
[Code coverage GeomAlgoAPI]: Refactoring of ShapeAPI and additional unit tests
authorazv <azv@opencascade.com>
Wed, 19 Dec 2018 11:24:02 +0000 (14:24 +0300)
committerazv <azv@opencascade.com>
Wed, 19 Dec 2018 11:24:02 +0000 (14:24 +0300)
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h
test.API/SHAPER/CMakeLists.txt
test.API/SHAPER/Primitives/TestAPI_Cone.py [new file with mode: 0644]
test.API/SHAPER/Primitives/TestAPI_Sphere.py [new file with mode: 0644]
test.API/SHAPER/Primitives/TestAPI_Torus.py [new file with mode: 0644]
test.API/SHAPER/Transformations/TestAPI_MultiRotation.py [new file with mode: 0644]

index c5c586855ac586e2f41616c65c91d13b38fcf2d8..7b3c78f35fc77e908086ebed0e838a8e4245b850 100644 (file)
@@ -73,6 +73,9 @@ public:
     initialize();
   }
 
+  /// Execute the algorithm.
+  GEOMALGOAPI_EXPORT virtual void build() {}
+
   /// \return status of builder.
   GEOMALGOAPI_EXPORT bool isDone() const;
 
index 550bf68f3f0b74d9d9e824b29c685f244d4e172e..2a70bf4080f9771211b47c2d439e84e49af2c308 100644 (file)
 
 #include <math.h>
 
+static GeomShapePtr runAlgo(GeomAlgoAPI_MakeShape& theAlgo)  throw (GeomAlgoAPI_Exception)
+{
+  if (!theAlgo.check())
+    throw GeomAlgoAPI_Exception(theAlgo.getError());
+
+  theAlgo.build();
+
+  if (!theAlgo.isDone())
+    throw GeomAlgoAPI_Exception(theAlgo.getError());
+
+  return theAlgo.shape();
+}
+
+static GeomShapePtr runAlgoAndCheckShape(GeomAlgoAPI_MakeShape& theAlgo, const std::string& theMsg)
+throw (GeomAlgoAPI_Exception)
+{
+  if (!theAlgo.check())
+    throw GeomAlgoAPI_Exception(theAlgo.getError());
+
+  theAlgo.build();
+
+  if (!theAlgo.isDone() || !theAlgo.checkValid(theMsg))
+    throw GeomAlgoAPI_Exception(theAlgo.getError());
+
+  return theAlgo.shape();
+}
+
 namespace GeomAlgoAPI_ShapeAPI
 {
   //===============================================================================================
@@ -44,21 +71,9 @@ namespace GeomAlgoAPI_ShapeAPI
     const double theDx, const double theDy,
     const double theDz) throw (GeomAlgoAPI_Exception)
   {
+    static const std::string aMsg("Box builder with dimensions");
     GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz);
-
-    if (!aBoxAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
-    }
-
-    aBoxAlgo.build();
-
-    if(!aBoxAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
-    }
-    if (!aBoxAlgo.checkValid("Box builder with dimensions")) {
-      throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
-    }
-    return aBoxAlgo.shape();
+    return runAlgoAndCheckShape(aBoxAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -66,21 +81,9 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
     std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
   {
+    static const std::string aMsg("Box builder with two points");
     GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint);
-
-    if (!aBoxAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
-    }
-
-    aBoxAlgo.build();
-
-    if(!aBoxAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
-    }
-    if (!aBoxAlgo.checkValid("Box builder with two points")) {
-      throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
-    }
-    return aBoxAlgo.shape();
+    return runAlgoAndCheckShape(aBoxAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -103,19 +106,8 @@ namespace GeomAlgoAPI_ShapeAPI
 
     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
 
-    if (!aCylinderAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-
-    aCylinderAlgo.build();
-
-    if(!aCylinderAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-    if (!aCylinderAlgo.checkValid("Cylinder builder")) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-    return aCylinderAlgo.shape();
+    static const std::string aMsg("Cylinder builder");
+    return runAlgoAndCheckShape(aCylinderAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -138,19 +130,8 @@ namespace GeomAlgoAPI_ShapeAPI
 
     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
 
-    if (!aCylinderAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-
-    aCylinderAlgo.build();
-
-    if(!aCylinderAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-    if (!aCylinderAlgo.checkValid("Cylinder portion builder")) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-    return aCylinderAlgo.shape();
+    static const std::string aMsg("Cylinder portion builder");
+    return runAlgoAndCheckShape(aCylinderAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -166,19 +147,8 @@ namespace GeomAlgoAPI_ShapeAPI
 
     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
 
-    if (!aCylinderAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-
-    aCylinderAlgo.build();
-
-    if(!aCylinderAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-    if (!aCylinderAlgo.checkValid("Cylinder builder")) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-    return aCylinderAlgo.shape();
+    static const std::string aMsg("Cylinder builder");
+    return runAlgoAndCheckShape(aCylinderAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -194,41 +164,17 @@ namespace GeomAlgoAPI_ShapeAPI
 
     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
 
-    if (!aCylinderAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-
-    aCylinderAlgo.build();
-
-    if(!aCylinderAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-    if (!aCylinderAlgo.checkValid("Cylinder portion builder")) {
-      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
-    }
-    return aCylinderAlgo.shape();
+    static const std::string aMsg("Cylinder portion builder");
+    return runAlgoAndCheckShape(aCylinderAlgo, aMsg);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(
       std::shared_ptr<GeomAPI_Pnt> theCenterPoint, double theRadius) throw (GeomAlgoAPI_Exception)
   {
+    static const std::string aMsg("Sphere builder");
     GeomAlgoAPI_Sphere aSphereAlgo(theCenterPoint, theRadius);
-
-    if (!aSphereAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
-    }
-
-    aSphereAlgo.build();
-
-    if(!aSphereAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
-    }
-
-    if (!aSphereAlgo.checkValid("Sphere builder")) {
-      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
-    }
-    return aSphereAlgo.shape();
+    return runAlgoAndCheckShape(aSphereAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -240,20 +186,8 @@ namespace GeomAlgoAPI_ShapeAPI
 
     GeomAlgoAPI_Sphere aSphereAlgo(aCenterPoint, theRadius);
 
-    if (!aSphereAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
-    }
-
-    aSphereAlgo.build();
-
-    if(!aSphereAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
-    }
-
-    if (!aSphereAlgo.checkValid("Sphere builder")) {
-      throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
-    }
-    return aSphereAlgo.shape();
+    static const std::string aMsg("Sphere builder");
+    return runAlgoAndCheckShape(aSphereAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -277,20 +211,8 @@ namespace GeomAlgoAPI_ShapeAPI
 
     GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
 
-    if (!aTorusAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
-    }
-
-    aTorusAlgo.build();
-
-    if(!aTorusAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
-    }
-
-    if (!aTorusAlgo.checkValid("Torus builder")) {
-      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
-    }
-    return aTorusAlgo.shape();
+    static const std::string aMsg("Torus builder");
+    return runAlgoAndCheckShape(aTorusAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -306,20 +228,8 @@ namespace GeomAlgoAPI_ShapeAPI
 
     GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
 
-    if (!aTorusAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
-    }
-
-    aTorusAlgo.build();
-
-    if(!aTorusAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
-    }
-
-    if (!aTorusAlgo.checkValid("Torus builder")) {
-      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
-    }
-    return aTorusAlgo.shape();
+    static const std::string aMsg("Torus builder");
+    return runAlgoAndCheckShape(aTorusAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -344,20 +254,8 @@ namespace GeomAlgoAPI_ShapeAPI
 
     GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
 
-    if (!aConeAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
-    }
-
-    aConeAlgo.build();
-
-    if(!aConeAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
-    }
-
-    if (!aConeAlgo.checkValid("Cone builder")) {
-      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
-    }
-    return aConeAlgo.shape();
+    static const std::string aMsg("Cone builder");
+    return runAlgoAndCheckShape(aConeAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -374,20 +272,8 @@ namespace GeomAlgoAPI_ShapeAPI
 
     GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
 
-    if (!aConeAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
-    }
-
-    aConeAlgo.build();
-
-    if(!aConeAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
-    }
-
-    if (!aConeAlgo.checkValid("Cone builder")) {
-      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
-    }
-    return aConeAlgo.shape();
+    static const std::string aMsg("Cone builder");
+    return runAlgoAndCheckShape(aConeAlgo, aMsg);
   }
 
   //===============================================================================================
@@ -397,18 +283,7 @@ namespace GeomAlgoAPI_ShapeAPI
     const double theDistance) throw (GeomAlgoAPI_Exception)
   {
     GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance);
-
-    if (!aTranslationAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
-    }
-
-    aTranslationAlgo.build();
-
-    if(!aTranslationAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
-    }
-
-    return aTranslationAlgo.shape();
+    return runAlgo(aTranslationAlgo);
   }
 
   //===============================================================================================
@@ -419,18 +294,7 @@ namespace GeomAlgoAPI_ShapeAPI
     const double theDz) throw (GeomAlgoAPI_Exception)
   {
     GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz);
-
-    if (!aTranslationAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
-    }
-
-    aTranslationAlgo.build();
-
-    if(!aTranslationAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
-    }
-
-    return aTranslationAlgo.shape();
+    return runAlgo(aTranslationAlgo);
   }
 
   //===============================================================================================
@@ -440,18 +304,7 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Pnt>   theEndPoint) throw (GeomAlgoAPI_Exception)
   {
     GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint);
-
-    if (!aTranslationAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
-    }
-
-    aTranslationAlgo.build();
-
-    if(!aTranslationAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
-    }
-
-    return aTranslationAlgo.shape();
+    return runAlgo(aTranslationAlgo);
   }
 
   //===============================================================================================
@@ -461,18 +314,7 @@ namespace GeomAlgoAPI_ShapeAPI
     const double theAngle) throw (GeomAlgoAPI_Exception)
   {
     GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theAxis, theAngle);
-
-    if (!aRotationAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
-    }
-
-    aRotationAlgo.build();
-
-    if(!aRotationAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
-    }
-
-    return aRotationAlgo.shape();
+    return runAlgo(aRotationAlgo);
   }
 
   //===============================================================================================
@@ -483,18 +325,7 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception)
   {
     GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theCenterPoint, theStartPoint, theEndPoint);
-
-    if (!aRotationAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
-    }
-
-    aRotationAlgo.build();
-
-    if(!aRotationAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
-    }
-
-    return aRotationAlgo.shape();
+    return runAlgo(aRotationAlgo);
   }
 
   //===============================================================================================
@@ -503,18 +334,7 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Pnt>   thePoint) throw (GeomAlgoAPI_Exception)
   {
     GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePoint);
-
-    if (!aSymmetryAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
-    }
-
-    aSymmetryAlgo.build();
-
-    if(!aSymmetryAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
-    }
-
-    return aSymmetryAlgo.shape();
+    return runAlgo(aSymmetryAlgo);
   }
 
   //===============================================================================================
@@ -523,18 +343,7 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Ax1>   theAxis) throw (GeomAlgoAPI_Exception)
   {
     GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, theAxis);
-
-    if (!aSymmetryAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
-    }
-
-    aSymmetryAlgo.build();
-
-    if(!aSymmetryAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
-    }
-
-    return aSymmetryAlgo.shape();
+    return runAlgo(aSymmetryAlgo);
   }
 
   //===============================================================================================
@@ -543,18 +352,7 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Ax2>   thePlane) throw (GeomAlgoAPI_Exception)
   {
     GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePlane);
-
-    if (!aSymmetryAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
-    }
-
-    aSymmetryAlgo.build();
-
-    if(!aSymmetryAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
-    }
-
-    return aSymmetryAlgo.shape();
+    return runAlgo(aSymmetryAlgo);
   }
 
   //===============================================================================================
@@ -564,18 +362,7 @@ namespace GeomAlgoAPI_ShapeAPI
     const double                   theScaleFactor) throw (GeomAlgoAPI_Exception)
   {
     GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint, theScaleFactor);
-
-    if (!aScaleAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
-    }
-
-    aScaleAlgo.build();
-
-    if(!aScaleAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
-    }
-
-    return aScaleAlgo.shape();
+    return runAlgo(aScaleAlgo);
   }
 
   //===============================================================================================
@@ -588,18 +375,7 @@ namespace GeomAlgoAPI_ShapeAPI
   {
     GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint,
                                  theScaleFactorX, theScaleFactorY, theScaleFactorZ);
-
-    if (!aScaleAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
-    }
-
-    aScaleAlgo.build();
-
-    if(!aScaleAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
-    }
-
-    return aScaleAlgo.shape();
+    return runAlgo(aScaleAlgo);
   }
 
   //===============================================================================================
@@ -691,7 +467,7 @@ namespace GeomAlgoAPI_ShapeAPI
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiRotation(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Ax1> theAxis,
-    const int theNumber)
+    const int theNumber) throw (GeomAlgoAPI_Exception)
   {
     if (!theAxis) {
       std::string aError = "Multirotation builder ";
@@ -720,7 +496,7 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Ax1> theAxis,
     const double theStep,
-    const int theNumber)
+    const int theNumber) throw (GeomAlgoAPI_Exception)
   {
     if (!theAxis) {
       std::string aError = "Multirotation builder ";
@@ -752,18 +528,7 @@ namespace GeomAlgoAPI_ShapeAPI
     GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2,
                                              theZ, theStartPhi, theDeltaPhi);
 
-    if (!aConeSegmentAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
-    }
-
-    aConeSegmentAlgo.build();
-
-    if(!aConeSegmentAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
-    }
-    if (!aConeSegmentAlgo.checkValid("Cone Segment builder")) {
-      throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
-    }
-    return aConeSegmentAlgo.shape();
+    static const std::string aMsg("Cone Segment builder");
+    return runAlgoAndCheckShape(aConeSegmentAlgo, aMsg);
   }
 }
index 65b3f1769402a809e729304482396ecb4a54532a..9ef383227de9fb28a1277071783afcee80631f12 100644 (file)
@@ -263,7 +263,7 @@ public:
   static std::shared_ptr<GeomAPI_Shape> makeMultiRotation(
                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
                      std::shared_ptr<GeomAPI_Ax1> theAxis,
-                     const int theNumber);
+                     const int theNumber) throw (GeomAlgoAPI_Exception);
 
   /// Performs a multi rotation along one axis, at a step and a number of times
   /// \param theSourceShape Shape to be moved
@@ -274,7 +274,7 @@ public:
                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
                      std::shared_ptr<GeomAPI_Ax1> theAxis,
                      const double theStep,
-                     const int theNumber);
+                     const int theNumber) throw (GeomAlgoAPI_Exception);
 
   /// Creates a cone segment using standard GDML parameters.
   /// \param theRMin1 Inner radius at base of cone
index 72ca9e7d4316ceb6caed3241f7471de66986f4e5..c1322565054e264b64ee9aa9aec27b52c1b7957c 100644 (file)
@@ -27,9 +27,13 @@ ADD_UNIT_TESTS_API(
   Primitives/TestSphere.py
   Primitives/TestTorus.py
   Primitives/TestAPI_Box.py
+  Primitives/TestAPI_Cone.py
   Primitives/TestAPI_Cylinder.py
+  Primitives/TestAPI_Sphere.py
+  Primitives/TestAPI_Torus.py
   GDML/TestConeSegment.py
   GDML/TestAPI_ConeSegment.py
+  Transformations/TestAPI_MultiRotation.py
   Transformations/TestAPI_MultiTranslation.py
   Transformations/TestAPI_Rotation.py
   Transformations/TestAPI_Scale.py
diff --git a/test.API/SHAPER/Primitives/TestAPI_Cone.py b/test.API/SHAPER/Primitives/TestAPI_Cone.py
new file mode 100644 (file)
index 0000000..23feea8
--- /dev/null
@@ -0,0 +1,65 @@
+## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
+from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
+from GeomAlgoAPI import GeomAlgoAPI_EdgeBuilder as edgeBuilder
+from GeomAPI import GeomAPI_Pnt as pnt
+from GeomAPI import GeomAPI_Ax1 as axis
+from GeomAPI import GeomAPI_Dir as direction
+
+# Points
+pnt1 = pnt(0., 0., 0.)
+pnt2 = pnt(10., 10., 10.)
+
+# Axis
+yDir = direction(0.,10.,0.)
+ax1 = axis(pnt1, yDir)
+
+# Edges
+edgaxis = edgeBuilder.line(ax1.dir().x(), ax1.dir().y(), ax1.dir().z())
+
+Cone_1 = shaperpy.makeCone(5., 10., 10.)
+Cone_2 = shaperpy.makeCone(0., 10., 10.)
+Cone_3 = shaperpy.makeCone(5., 0., 10.)
+
+try:
+  Cone_4 = shaperpy.makeCone(5., 10., 0.)
+except myExcept as ec:
+  assert(ec.what() == "Cone builder :: height is negative or null.")
+
+Cone_5 = shaperpy.makeCone(pnt2, edgaxis, 5., 10., 10.)
+Cone_6 = shaperpy.makeCone(pnt2, edgaxis, 0., 10., 10.)
+Cone_7 = shaperpy.makeCone(pnt2, edgaxis, 5., 0., 10.)
+
+try:
+  Cone_8 = shaperpy.makeCone(None, edgaxis, 5., 10., 10.)
+except myExcept as ec:
+  assert(ec.what() == "Cone builder :: the base point is not valid.")
+
+try:
+  Cone_9 = shaperpy.makeCone(pnt2, None, 5., 10., 10.)
+except myExcept as ec:
+  assert(ec.what() == "Cone builder :: the axis is not valid.")
+
+try:
+  Cone_10 = shaperpy.makeCone(pnt2, edgaxis, 5., 10., 0.)
+except myExcept as ec:
+  assert(ec.what() == "Cone builder :: height is negative or null.")
diff --git a/test.API/SHAPER/Primitives/TestAPI_Sphere.py b/test.API/SHAPER/Primitives/TestAPI_Sphere.py
new file mode 100644 (file)
index 0000000..c449b7d
--- /dev/null
@@ -0,0 +1,44 @@
+## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
+from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
+from GeomAPI import GeomAPI_Pnt as pnt
+
+# Points
+pnt1 = pnt(10., 10., 10.)
+
+Sphere_1 = shaperpy.makeSphere(pnt1, 10.)
+Sphere_2 = shaperpy.makeSphere(10.)
+
+try:
+  Sphere_3 = shaperpy.makeSphere(pnt1, 0.)
+except myExcept as ec:
+  assert(ec.what() == "Sphere builder :: radius is negative or null.")
+
+try:
+  Sphere_4 = shaperpy.makeSphere(0.)
+except myExcept as ec:
+  assert(ec.what() == "Sphere builder :: radius is negative or null.")
+
+try:
+  Sphere_5 = shaperpy.makeSphere(None, 10.)
+except myExcept as ec:
+  assert(ec.what() == "Sphere builder :: center is not valid.")
diff --git a/test.API/SHAPER/Primitives/TestAPI_Torus.py b/test.API/SHAPER/Primitives/TestAPI_Torus.py
new file mode 100644 (file)
index 0000000..807dadb
--- /dev/null
@@ -0,0 +1,76 @@
+## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
+from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
+from GeomAlgoAPI import GeomAlgoAPI_EdgeBuilder as edgeBuilder
+from GeomAPI import GeomAPI_Pnt as pnt
+from GeomAPI import GeomAPI_Ax1 as axis
+from GeomAPI import GeomAPI_Dir as direction
+
+# Points
+pnt1 = pnt(0., 0., 0.)
+pnt2 = pnt(10., 10., 10.)
+
+# Axis
+yDir = direction(0.,10.,0.)
+ax1 = axis(pnt1, yDir)
+
+# Edges
+edgaxis = edgeBuilder.line(ax1.dir().x(), ax1.dir().y(), ax1.dir().z())
+
+Torus_1 = shaperpy.makeTorus(10., 5.)
+
+try:
+  Torus_2 = shaperpy.makeTorus(0., 5.)
+except myExcept as ec:
+  assert(ec.what() == "Torus builder :: radius is negative or null.")
+
+try:
+  Torus_3 = shaperpy.makeTorus(10., 0.)
+except myExcept as ec:
+  assert(ec.what() == "Torus builder :: ring radius is negative or null.")
+
+try:
+  Torus_4 = shaperpy.makeTorus(5., 10.)
+except myExcept as ec:
+  assert(ec.what() == "Torus builder :: ring radius is greater than the radius.")
+
+Torus_5 = shaperpy.makeTorus(pnt2, edgaxis, 10., 5.)
+
+try:
+  Torus_6 = shaperpy.makeTorus(None, edgaxis, 10., 5.)
+except myExcept as ec:
+  assert(ec.what() == "Torus builder :: the base point is not valid.")
+
+try:
+  Torus_7 = shaperpy.makeTorus(pnt2, None, 10., 5.)
+except myExcept as ec:
+  assert(ec.what() == "Torus builder :: the axis is not valid.")
+
+try:
+  Torus_8 = shaperpy.makeTorus(pnt2, edgaxis, 0., 5.)
+except myExcept as ec:
+  assert(ec.what() == "Torus builder :: radius is negative or null.")
+
+try:
+  Torus_8 = shaperpy.makeTorus(pnt2, edgaxis, 10., 0.)
+except myExcept as ec:
+  assert(ec.what() == "Torus builder :: ring radius is negative or null.")
diff --git a/test.API/SHAPER/Transformations/TestAPI_MultiRotation.py b/test.API/SHAPER/Transformations/TestAPI_MultiRotation.py
new file mode 100644 (file)
index 0000000..803d3b8
--- /dev/null
@@ -0,0 +1,76 @@
+## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
+from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
+from GeomAPI import GeomAPI_Ax1 as axis, GeomAPI_Pnt as pnt, GeomAPI_Dir as direction
+
+# Create Boxes
+Box_1 = shaperpy.makeBox(10.,10.,10.)
+Box_2 = shaperpy.makeBox(10.,10.,10.)
+Box_3 = shaperpy.makeBox(10.,10.,10.)
+Box_4 = shaperpy.makeBox(10.,10.,10.)
+Box_5 = shaperpy.makeBox(10.,10.,10.)
+Box_6 = shaperpy.makeBox(10.,10.,10.)
+Box_7 = shaperpy.makeBox(10.,10.,10.)
+
+# Points
+pntOrigin = pnt(0.,0.,0.)
+pnt1 = pnt(10.,0.,0.)
+
+# Axis
+xDir = direction(10., 0., 0.)
+ax1 = axis(pntOrigin, xDir)
+
+# Create MultiRotations
+MultiRotation_1 = shaperpy.makeMultiRotation(Box_1, ax1, 45., 5)
+MultiRotation_2 = shaperpy.makeMultiRotation(Box_2, ax1, 0., 5)
+
+try:
+  MultiRotation_3 = shaperpy.makeMultiRotation(Box_3, ax1, 45., -5)
+except myExcept as ec:
+  assert(ec.what() == "Multirotation builder :: the number of copies is null or negative.")
+
+try:
+  MultiRotation_4 = shaperpy.makeMultiRotation(None, ax1, 45., 5)
+except myExcept as ec:
+  assert(ec.what() == "Rotation builder :: source shape is not valid.")
+
+try:
+  MultiRotation_5 = shaperpy.makeMultiRotation(Box_4, None, 45., 5)
+except myExcept as ec:
+  assert(ec.what() == "Multirotation builder :: the axis is not valid")
+
+MultiRotation_6 = shaperpy.makeMultiRotation(Box_5, ax1, 5)
+
+try:
+  MultiRotation_7 = shaperpy.makeMultiRotation(Box_6, ax1, -5)
+except myExcept as ec:
+  assert(ec.what() == "Multirotation builder :: the number of copies is null or negative.")
+
+try:
+  MultiRotation_8 = shaperpy.makeMultiRotation(None, ax1, 5)
+except myExcept as ec:
+  assert(ec.what() == "Rotation builder :: source shape is not valid.")
+
+try:
+  MultiRotation_9 = shaperpy.makeMultiRotation(Box_7, None, 5)
+except myExcept as ec:
+  assert(ec.what() == "Multirotation builder :: the axis is not valid")