Salome HOME
Copyright update 2022
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_ShapeAPI.cpp
index 550bf68f3f0b74d9d9e824b29c685f244d4e172e..e213403006f3d3e7907d0f1f55de3f90b868b9ec 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  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
 //
 // 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
+// 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>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "GeomAlgoAPI_ShapeAPI.h"
 
 #include <math.h>
 
+static GeomShapePtr runAlgo(GeomAlgoAPI_MakeShape& theAlgo)
+{
+  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)
+{
+  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
 {
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
     const double theDx, const double theDy,
-    const double theDz) throw (GeomAlgoAPI_Exception)
+    const double theDz)
   {
+    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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
     std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
-    std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
+    std::shared_ptr<GeomAPI_Pnt> theSecondPoint)
   {
+    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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
     std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
-    double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
+    double theRadius, double theHeight)
   {
     // Check if the base point is OK
     if (!theBasePoint) {
@@ -103,25 +104,14 @@ 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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
     std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
-    double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
+    double theRadius, double theHeight, double theAngle)
   {
     // Check if the base point is OK
     if (!theBasePoint) {
@@ -138,24 +128,13 @@ 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::makeCylinder(
-    double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
+    double theRadius, double theHeight)
   {
     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
@@ -166,24 +145,13 @@ 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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
-    double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
+    double theRadius, double theHeight, double theAngle)
   {
     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
@@ -194,73 +162,35 @@ 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)
+      std::shared_ptr<GeomAPI_Pnt> theCenterPoint, double theRadius)
   {
+    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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(double theRadius)
-      throw (GeomAlgoAPI_Exception)
   {
     std::shared_ptr<GeomAPI_Pnt> aCenterPoint =
       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
 
     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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(
       std::shared_ptr<GeomAPI_Pnt> theBasePoint,
       std::shared_ptr<GeomAPI_Edge> theEdge,double theRadius, double theRingRadius)
-      throw (GeomAlgoAPI_Exception)
   {
     // Check if the base point is OK
     if (!theBasePoint) {
@@ -277,25 +207,13 @@ 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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(double theRadius,
-      double theRingRadius) throw (GeomAlgoAPI_Exception)
+      double theRingRadius)
   {
     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
@@ -306,20 +224,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);
   }
 
   //===============================================================================================
@@ -327,7 +233,7 @@ namespace GeomAlgoAPI_ShapeAPI
       std::shared_ptr<GeomAPI_Pnt> theBasePoint,
       std::shared_ptr<GeomAPI_Edge> theEdge,
       double theBaseRadius, double theTopRadius,
-      double theHeight) throw (GeomAlgoAPI_Exception)
+      double theHeight)
   {
     // Check if the base point is OK
     if (!theBasePoint) {
@@ -344,26 +250,14 @@ 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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
       double theBaseRadius, double theTopRadius,
-      double theHeight) throw (GeomAlgoAPI_Exception)
+      double theHeight)
   {
     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
@@ -374,41 +268,18 @@ 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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Ax1>   theAxis,
-    const double theDistance) throw (GeomAlgoAPI_Exception)
+    const double theDistance)
   {
     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);
   }
 
   //===============================================================================================
@@ -416,63 +287,30 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     const double theDx,
     const double theDy,
-    const double theDz) throw (GeomAlgoAPI_Exception)
+    const double theDz)
   {
     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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Pnt>   theStartPoint,
-    std::shared_ptr<GeomAPI_Pnt>   theEndPoint) throw (GeomAlgoAPI_Exception)
+    std::shared_ptr<GeomAPI_Pnt>   theEndPoint)
   {
     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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeRotation(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Ax1> theAxis,
-    const double theAngle) throw (GeomAlgoAPI_Exception)
+    const double theAngle)
   {
     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);
   }
 
   //===============================================================================================
@@ -480,102 +318,47 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
     std::shared_ptr<GeomAPI_Pnt> theStartPoint,
-    std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception)
+    std::shared_ptr<GeomAPI_Pnt> theEndPoint)
   {
     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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
-    std::shared_ptr<GeomAPI_Pnt>   thePoint) throw (GeomAlgoAPI_Exception)
+    std::shared_ptr<GeomAPI_Pnt>   thePoint)
   {
     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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
-    std::shared_ptr<GeomAPI_Ax1>   theAxis) throw (GeomAlgoAPI_Exception)
+    std::shared_ptr<GeomAPI_Ax1>   theAxis)
   {
     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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
-    std::shared_ptr<GeomAPI_Ax2>   thePlane) throw (GeomAlgoAPI_Exception)
+    std::shared_ptr<GeomAPI_Ax2>   thePlane)
   {
     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);
   }
 
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
-    const double                   theScaleFactor) throw (GeomAlgoAPI_Exception)
+    const double                   theScaleFactor)
   {
     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);
   }
 
   //===============================================================================================
@@ -584,22 +367,11 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
     const double                   theScaleFactorX,
     const double                   theScaleFactorY,
-    const double                   theScaleFactorZ) throw (GeomAlgoAPI_Exception)
+    const double                   theScaleFactorZ)
   {
     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);
   }
 
   //===============================================================================================
@@ -607,7 +379,7 @@ namespace GeomAlgoAPI_ShapeAPI
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Ax1> theAxis,
     const double theStep,
-    const int theNumber) throw (GeomAlgoAPI_Exception)
+    const int theNumber)
   {
     if (!theAxis) {
       std::string aError = "Multitranslation builder ";
@@ -637,7 +409,7 @@ namespace GeomAlgoAPI_ShapeAPI
     const int theFirstNumber,
     std::shared_ptr<GeomAPI_Ax1> theSecondAxis,
     const double theSecondStep,
-    const int theSecondNumber) throw (GeomAlgoAPI_Exception)
+    const int theSecondNumber)
   {
     if (!theFirstAxis) {
       std::string aError = "Multitranslation builder ";
@@ -747,23 +519,12 @@ namespace GeomAlgoAPI_ShapeAPI
     const double theRMin1, const double theRMax1,
     const double theRMin2, const double theRMax2,
     const double theZ,
-    const double theStartPhi, const double theDeltaPhi) throw (GeomAlgoAPI_Exception)
+    const double theStartPhi, const double theDeltaPhi)
   {
     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);
   }
 }