]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[Code coverage]: Move checking the algorithm's result into separate function
authorazv <azv@opencascade.com>
Mon, 10 Dec 2018 08:52:48 +0000 (11:52 +0300)
committerazv <azv@opencascade.com>
Mon, 10 Dec 2018 08:52:59 +0000 (11:52 +0300)
32 files changed:
src/BuildPlugin/BuildPlugin_Edge.cpp
src/BuildPlugin/BuildPlugin_Filling.cpp
src/BuildPlugin/BuildPlugin_Filling.h
src/BuildPlugin/BuildPlugin_Polyline.cpp
src/BuildPlugin/BuildPlugin_Shell.cpp
src/BuildPlugin/BuildPlugin_Vertex.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp
src/FeaturesPlugin/FeaturesPlugin_Fillet.h
src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Recover.cpp
src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Scale.cpp
src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp
src/FeaturesPlugin/FeaturesPlugin_Union.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Tools.h

index a3a247e30f226e4f613bc43954a3cd887710b00b..28be282f6055237a5de19eb62dc3147b443a67a7 100644 (file)
@@ -24,6 +24,7 @@
 #include <ModelAPI_ResultBody.h>
 
 #include <GeomAlgoAPI_Copy.h>
+#include <GeomAlgoAPI_Tools.h>
 
 //=================================================================================================
 BuildPlugin_Edge::BuildPlugin_Edge()
@@ -78,21 +79,9 @@ void BuildPlugin_Edge::execute()
     // Copy shape.
     GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aShape));
 
-    // Check that algo is done.
-    if(!aCopyAlgo->isDone()) {
-      setError("Error: " + getKind() + " algorithm failed.");
-      return;
-    }
-
-    // Check if shape is not null.
-    if(!aCopyAlgo->shape().get() || aCopyAlgo->shape()->isNull()) {
-      setError("Error: Resulting shape is null.");
-      return;
-    }
-
-    // Check that resulting shape is valid.
-    if(!aCopyAlgo->isValid()) {
-      setError("Error: Resulting shape is not valid.");
+    std::string anError;
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
index 6e95dd32c31c6b7753483e2b07e56093be55d031..dcf51a8b540186976cef84f2b8370ba9e9108568 100644 (file)
@@ -30,6 +30,7 @@
 #include <GeomAlgoAPI_Copy.h>
 #include <GeomAlgoAPI_Filling.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_ShapeExplorer.h>
@@ -116,7 +117,9 @@ void BuildPlugin_Filling::execute()
 
   // build result
   aFilling->build(aParameters.isApprox);
-  if (isAlgorithmFailed(aFilling)) {
+  std::string anError;
+  if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilling, getKind(), anError)) {
+    setError(anError);
     removeResults(0);
     return;
   }
@@ -134,32 +137,6 @@ void BuildPlugin_Filling::execute()
   setResult(aResultBody, 0);
 }
 
-bool BuildPlugin_Filling::isAlgorithmFailed(
-    const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
-{
-  if (!theAlgorithm->isDone()) {
-    static const std::string aFeatureError = "Error: filling algorithm failed.";
-    std::string anAlgoError = theAlgorithm->getError();
-    if (anAlgoError.empty())
-      anAlgoError = aFeatureError;
-    else
-      anAlgoError = aFeatureError + " " + anAlgoError;
-    setError(anAlgoError);
-    return true;
-  }
-  if (theAlgorithm->shape()->isNull()) {
-    static const std::string aShapeError = "Error: Resulting shape of filling is Null.";
-    setError(aShapeError);
-    return true;
-  }
-  if (!theAlgorithm->isValid()) {
-    std::string aFeatureError = "Error: Resulting shape of filling is not valid.";
-    setError(aFeatureError);
-    return true;
-  }
-  return false;
-}
-
 //=================================================================================================
 void BuildPlugin_Filling::attributeChanged(const std::string& theID)
 {
index cb19f063f0efe373ac3846126d5e424ebdc2ed34..aadc2292dc0e2cff4f6a1c3a13455ee96189aa90 100644 (file)
@@ -164,9 +164,6 @@ public:
   BUILDPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
 private:
-  /// Check the filling algorithm is failed
-  bool isAlgorithmFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
-
   /// Convert shape to edge according to construction method
   std::shared_ptr<GeomAPI_Edge> toEdge(const std::shared_ptr<GeomAPI_Shape>& theShape,
                                        const std::string& theMethod);
index 17702ae33c452b2cf6c756cf35ec4e0bf8434072..da0bbfb99e99a84abdc1d69439a15bf2495e0919 100644 (file)
@@ -92,10 +92,10 @@ void BuildPlugin_Polyline::execute()
 
   // Create wire from edges
   GeomShapePtr aWire = GeomAlgoAPI_WireBuilder::wire(anEdges);
-       if (!aWire.get()) {
-               setError("Error: Result polyline is empty.");
-               return;
-       }
+  if (!aWire.get()) {
+    setError("Error: Result polyline is empty.");
+    return;
+  }
 
   // Check the wire.
   if (GeomAlgoAPI_WireBuilder::isSelfIntersected(aWire)) {
index cc361be5992ace4735b409ceae09bda6426a220c..bd73c2f1fd1ac6ec5486cab5f7032a6d0561ebe4 100644 (file)
@@ -25,6 +25,7 @@
 #include <ModelAPI_ResultConstruction.h>
 
 #include <GeomAlgoAPI_Sewing.h>
+#include <GeomAlgoAPI_Tools.h>
 #include <GeomAPI_ShapeExplorer.h>
 
 //=================================================================================================
@@ -58,21 +59,9 @@ void BuildPlugin_Shell::execute()
   // Sew faces.
   GeomMakeShapePtr aSewingAlgo(new GeomAlgoAPI_Sewing(aShapes));
 
-  // Check that algo is done.
-  if(!aSewingAlgo->isDone()) {
-    setError("Error: " + getKind() + " algorithm failed.");
-    return;
-  }
-
-  // Check if shape is not null.
-  if(!aSewingAlgo->shape().get() || aSewingAlgo->shape()->isNull()) {
-    setError("Error: Resulting shape is null.");
-    return;
-  }
-
-  // Check that resulting shape is valid.
-  if(!aSewingAlgo->isValid()) {
-    setError("Error: Resulting shape is not valid.");
+  std::string anError;
+  if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSewingAlgo, getKind(), anError)) {
+    setError(anError);
     return;
   }
 
index 585682a32ff6bde03ee202ab3a898ce1bdbc975f..a2475d8702a5d3566deb1eae6387316b51d43610 100644 (file)
@@ -24,6 +24,7 @@
 #include <ModelAPI_ResultBody.h>
 
 #include <GeomAlgoAPI_Copy.h>
+#include <GeomAlgoAPI_Tools.h>
 
 //=================================================================================================
 BuildPlugin_Vertex::BuildPlugin_Vertex()
@@ -76,29 +77,17 @@ void BuildPlugin_Vertex::execute()
     }
 
     // Copy shape.
-    GeomAlgoAPI_Copy aCopyAlgo(aShape);
+    std::shared_ptr<GeomAlgoAPI_Copy> aCopyAlgo(new GeomAlgoAPI_Copy(aShape));
 
-    // Check that algo is done.
-    if(!aCopyAlgo.isDone()) {
-      setError("Error: " + getKind() + " algorithm failed.");
-      return;
-    }
-
-    // Check if shape is not null.
-    if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) {
-      setError("Error: Resulting shape is null.");
-      return;
-    }
-
-    // Check that resulting shape is valid.
-    if(!aCopyAlgo.isValid()) {
-      setError("Error: Resulting shape is not valid.");
+    std::string anError;
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
     // Store result.
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    aResultBody->storeModified(aShape, aCopyAlgo.shape());
+    aResultBody->storeModified(aShape, aCopyAlgo->shape());
     setResult(aResultBody, aResultIndex);
     ++aResultIndex;
   }
index 942279a4f125a087bd776b63e710757738aaa860..df16a3149b6764ad80f33797b6e6fc1ad915d95d 100644 (file)
@@ -36,6 +36,7 @@
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAlgoAPI_PaveFiller.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
 
 
 //==================================================================================================
@@ -128,6 +129,7 @@ void FeaturesPlugin_BooleanCommon::execute()
   }
 
   int aResultIndex = 0;
+  std::string anError;
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
   std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
@@ -142,19 +144,8 @@ void FeaturesPlugin_BooleanCommon::execute()
                                 *anObjectsIt,
                                 GeomAlgoAPI_Boolean::BOOL_COMMON));
 
-      if (!aCommonAlgo->isDone()) {
-        std::string aFeatureError = "Error: An algorithm failed.";
-        setError(aFeatureError);
-        return;
-      }
-      if (aCommonAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        return;
-      }
-      if (!aCommonAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) {
+        setError(anError);
         return;
       }
 
@@ -220,19 +211,8 @@ void FeaturesPlugin_BooleanCommon::execute()
       aResShape = aBoolAlgo->shape();
 
       // Checking that the algorithm worked properly.
-      if (!aBoolAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-        setError(aFeatureError);
-        return;
-      }
-      if (aResShape->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        return;
-      }
-      if (!aBoolAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
+        setError(anError);
         return;
       }
 
@@ -294,19 +274,8 @@ void FeaturesPlugin_BooleanCommon::execute()
           GeomAlgoAPI_Boolean::BOOL_COMMON));
 
       // Checking that the algorithm worked properly.
-      if (!aCommonAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-        setError(aFeatureError);
-        return;
-      }
-      if (aCommonAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        return;
-      }
-      if (!aCommonAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) {
+        setError(anError);
         return;
       }
 
@@ -386,19 +355,8 @@ void FeaturesPlugin_BooleanCommon::execute()
           GeomAlgoAPI_Boolean::BOOL_COMMON));
 
       // Checking that the algorithm worked properly.
-      if (!aCommonAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-        setError(aFeatureError);
-        return;
-      }
-      if (aCommonAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        return;
-      }
-      if (!aCommonAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) {
+        setError(anError);
         return;
       }
 
index ae5cac2f5add913a2b01f1c5bcd7a0a84b4c81dc..bfe0fdc2c26127ce96e9ba425a361a57dc3dc82b 100644 (file)
@@ -31,6 +31,8 @@
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_PaveFiller.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
+
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
 
@@ -103,6 +105,7 @@ void FeaturesPlugin_BooleanCut::execute()
 
   std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
+  std::string anError;
 
   // For solids cut each object with all tools.
   for(ListOfShape::iterator anObjectsIt = anObjects.begin();
@@ -117,19 +120,8 @@ void FeaturesPlugin_BooleanCut::execute()
     GeomShapePtr aResShape = aCutAlgo->shape();
 
     // Checking that the algorithm worked properly.
-    if (!aCutAlgo->isDone()) {
-      static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-      setError(aFeatureError);
-      return;
-    }
-    if(aResShape->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      return;
-    }
-    if (!aCutAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
@@ -192,19 +184,8 @@ void FeaturesPlugin_BooleanCut::execute()
                               GeomAlgoAPI_Boolean::BOOL_CUT));
 
     // Checking that the algorithm worked properly.
-    if (!aCutAlgo->isDone()) {
-      static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-      setError(aFeatureError);
-      return;
-    }
-    if (aCutAlgo->shape()->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      return;
-    }
-    if (!aCutAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
@@ -284,19 +265,8 @@ void FeaturesPlugin_BooleanCut::execute()
                               GeomAlgoAPI_Boolean::BOOL_CUT));
 
     // Checking that the algorithm worked properly.
-    if (!aCutAlgo->isDone()) {
-      static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-      setError(aFeatureError);
-      return;
-    }
-    if (aCutAlgo->shape()->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      return;
-    }
-    if (!aCutAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
index 1bf9809428391ed68df021fafde435e96c82f11a..d9f7faf2becb34a67a68f402d78b4afda4e0f4b0 100644 (file)
@@ -30,6 +30,8 @@
 #include <GeomAlgoAPI_Partition.h>
 #include <GeomAlgoAPI_PaveFiller.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
+
 #include <GeomAPI_Face.h>
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
@@ -46,6 +48,7 @@ FeaturesPlugin_BooleanFill::FeaturesPlugin_BooleanFill()
 //=================================================================================================
 void FeaturesPlugin_BooleanFill::execute()
 {
+  std::string anError;
   ListOfShape anObjects, aTools, anEdgesAndFaces, aPlanes;
   std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
 
@@ -148,19 +151,8 @@ void FeaturesPlugin_BooleanFill::execute()
     }
 
     // Checking that the algorithm worked properly.
-    if(!aBoolAlgo->isDone()) {
-      static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-      setError(aFeatureError);
-      return;
-    }
-    if(aResShape->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      return;
-    }
-    if(!aBoolAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
@@ -224,19 +216,8 @@ void FeaturesPlugin_BooleanFill::execute()
     aBoolAlgo.reset(new GeomAlgoAPI_Partition(aUsedInOperationSolids, aToolsWithPlanes));
 
     // Checking that the algorithm worked properly.
-    if(!aBoolAlgo->isDone()) {
-      static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-      setError(aFeatureError);
-      return;
-    }
-    if(aBoolAlgo->shape()->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      return;
-    }
-    if(!aBoolAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
index b09cde2e789df9def3dc58a434ea18b1caa17610..f6e4599f730e695f2288301057c3d34a5c149211 100644 (file)
@@ -34,6 +34,7 @@
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_PaveFiller.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
 #include <GeomAlgoAPI_UnifySameDomain.h>
 #include <GeomAPI_ShapeExplorer.h>
 
@@ -60,6 +61,7 @@ void FeaturesPlugin_BooleanFuse::initAttributes()
 //==================================================================================================
 void FeaturesPlugin_BooleanFuse::execute()
 {
+  std::string anError;
   ListOfShape anObjects, aTools, anEdgesAndFaces;
   std::map<GeomShapePtr, ListOfShape> aCompSolidsObjects;
 
@@ -218,19 +220,8 @@ void FeaturesPlugin_BooleanFuse::execute()
       GeomAlgoAPI_Boolean::BOOL_FUSE));
 
     // Checking that the algorithm worked properly.
-    if (!aFuseAlgo->isDone()) {
-      static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-      setError(aFeatureError);
-      return;
-    }
-    if (aFuseAlgo->shape()->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      return;
-    }
-    if (!aFuseAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFuseAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
@@ -250,19 +241,8 @@ void FeaturesPlugin_BooleanFuse::execute()
     }
     std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
       new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
-    if (!aFillerAlgo->isDone()) {
-      std::string aFeatureError = "Error: PaveFiller algorithm failed.";
-      setError(aFeatureError);
-      return;
-    }
-    if (aFillerAlgo->shape()->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      return;
-    }
-    if (!aFillerAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
@@ -280,19 +260,8 @@ void FeaturesPlugin_BooleanFuse::execute()
     std::shared_ptr<GeomAlgoAPI_UnifySameDomain> aUnifyAlgo(
       new GeomAlgoAPI_UnifySameDomain(aShape));
 
-    if (!aUnifyAlgo->isDone()) {
-      std::string aFeatureError = "Error: PaveFiller algorithm failed.";
-      setError(aFeatureError);
-      return;
-    }
-    if (aUnifyAlgo->shape()->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      return;
-    }
-    if (!aUnifyAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aUnifyAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
index 65f1a77fe69b5925dc218f659414cb9ef56ed590..ee6c3c78538ac45b9210235df7242576d60370ff 100644 (file)
@@ -31,6 +31,8 @@
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_PaveFiller.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
+
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
 
@@ -50,6 +52,7 @@ void FeaturesPlugin_BooleanSmash::initAttributes()
 //==================================================================================================
 void FeaturesPlugin_BooleanSmash::execute()
 {
+  std::string anError;
   ListOfShape anObjects, aTools;
   std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
 
@@ -180,21 +183,11 @@ void FeaturesPlugin_BooleanSmash::execute()
                             GeomAlgoAPI_Boolean::BOOL_CUT));
 
   // Checking that the algorithm worked properly.
-  if (!aBoolAlgo->isDone()) {
-    static const std::string aFeatureError = "Error: Boolean algorithm failed.";
-    setError(aFeatureError);
-    return;
-  }
-  if (aBoolAlgo->shape()->isNull()) {
-    static const std::string aShapeError = "Error: Resulting shape is Null.";
-    setError(aShapeError);
-    return;
-  }
-  if (!aBoolAlgo->isValid()) {
-    std::string aFeatureError = "Error: Resulting shape is not valid.";
-    setError(aFeatureError);
+  if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
+    setError(anError);
     return;
   }
+
   aMakeShapeList->appendAlgo(aBoolAlgo);
 
   // Put all (cut result, tools and not used solids) to PaveFiller.
@@ -211,19 +204,8 @@ void FeaturesPlugin_BooleanSmash::execute()
   else {
     std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
       new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
-    if (!aFillerAlgo->isDone()) {
-      std::string aFeatureError = "Error: PaveFiller algorithm failed.";
-      setError(aFeatureError);
-      return;
-    }
-    if (aFillerAlgo->shape()->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      return;
-    }
-    if (!aFillerAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
index 272b43001f51c77bfcd0cd5563caf18ec39b9d64..e3d5803ba2ae256197942166cc5d11c3dd031893 100644 (file)
@@ -84,11 +84,12 @@ int FeaturesPlugin_CompositeSketch::numberOfSubs(bool forTree) const
 std::shared_ptr<ModelAPI_Feature> FeaturesPlugin_CompositeSketch::subFeature(const int theIndex,
                                                                              bool forTree)
 {
+  FeaturePtr aSubFeature;
   if(theIndex == 0) {
-    return std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_ID())->value());
+    aSubFeature =
+        std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_ID())->value());
   }
-
-  return std::shared_ptr<ModelAPI_Feature>();
+  return aSubFeature;
 }
 
 //=================================================================================================
@@ -108,14 +109,14 @@ int FeaturesPlugin_CompositeSketch::subFeatureId(const int theIndex) const
 //=================================================================================================
 bool FeaturesPlugin_CompositeSketch::isSub(ObjectPtr theObject) const
 {
+  bool isSubFeature = false;
   // Check is this feature of result
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
-  if(!aFeature.get()) {
-    return false;
+  if (aFeature.get()) {
+    ObjectPtr aSub = data()->reference(SKETCH_ID())->value();
+    isSubFeature = aSub == theObject;
   }
-
-  ObjectPtr aSub = data()->reference(SKETCH_ID())->value();
-  return aSub == theObject;
+  return isSubFeature;
 }
 
 //=================================================================================================
@@ -235,31 +236,6 @@ void FeaturesPlugin_CompositeSketch::getBaseShapes(ListOfShape& theBaseShapesLis
   }
 }
 
-//=================================================================================================
-bool FeaturesPlugin_CompositeSketch::isMakeShapeValid(
-  const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
-{
-  // Check that algo is done.
-  if(!theMakeShape->isDone()) {
-    setError("Error: " + getKind() + " algorithm failed.");
-    return false;
-  }
-
-  // Check if shape is not null.
-  if(!theMakeShape->shape().get() || theMakeShape->shape()->isNull()) {
-    setError("Error: Resulting shape is null.");
-    return false;
-  }
-
-  // Check that resulting shape is valid.
-  if(!theMakeShape->isValid()) {
-    setError("Error: Resulting shape is not valid.");
-    return false;
-  }
-
-  return true;
-}
-
 //=================================================================================================
 void FeaturesPlugin_CompositeSketch::storeResult(const GeomShapePtr theBaseShape,
                                         const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
index e4774bde88458bf02d52b6ce613e7afc0ef1db1b..f714351aa3c038b5791dbc7b2b2b2afc4fa7bba0 100644 (file)
@@ -83,9 +83,6 @@ protected:
   /// \param[in] theIsMakeShells if true make shells from faces with shared edges.
   void getBaseShapes(ListOfShape& theBaseShapesList, const bool theIsMakeShells = true);
 
-  /// Checks make shape algo.
-  bool isMakeShapeValid(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
-
   /// Stores result of generation.
   void storeResult(const GeomShapePtr theBaseShape,
                    const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
index 8944dd36273bc3346664f98ab55f0d3c33f15194..05a31bb3e8b4eea5b2795c38d78fc6764a7e4bd9 100644 (file)
@@ -27,6 +27,7 @@
 #include <ModelAPI_Validator.h>
 
 #include <GeomAlgoAPI_Prism.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Edge.h>
@@ -167,6 +168,7 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
   }
 
   // Generating result for each base shape.
+  std::string anError;
   for(ListOfShape::const_iterator
       anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anIter;
@@ -174,7 +176,8 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
     std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo(new GeomAlgoAPI_Prism(aBaseShape, aDir,
                                                                         aToShape, aToSize,
                                                                         aFromShape, aFromSize));
-    if(!isMakeShapeValid(aPrismAlgo)) {
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPrismAlgo, getKind(), anError)) {
+      setError(anError);
       return false;
     }
 
index b4ce7d588badd97d7926ae166f79477979a264f5..cf1dda3d287a099f5d4b80700c6e06b769673cc1 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <GeomAlgoAPI_Fillet.h>
 #include <GeomAlgoAPI_MakeShapeList.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_DataMapOfShapeMapOfShapes.h>
 #include <GeomAPI_ShapeExplorer.h>
@@ -147,6 +148,7 @@ void FeaturesPlugin_Fillet::execute()
   GeomAlgoAPI_MakeShapeList aMakeShapeList;
   std::shared_ptr<GeomAlgoAPI_Fillet> aFilletBuilder;
   int aResultIndex = 0;
+  std::string anError;
 
   GeomAPI_DataMapOfShapeMapOfShapes::iterator anIt = aSolidsAndSubs.begin();
   for (; anIt != aSolidsAndSubs.end(); ++anIt) {
@@ -158,8 +160,11 @@ void FeaturesPlugin_Fillet::execute()
       aFilletBuilder.reset(new GeomAlgoAPI_Fillet(aSolid, aFilletEdges, aRadius1));
     else
       aFilletBuilder.reset(new GeomAlgoAPI_Fillet(aSolid, aFilletEdges, aRadius1, aRadius2));
-    if (isFailed(aFilletBuilder))
+
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilletBuilder, getKind(), anError)) {
+      setError(anError);
       return;
+    }
 
     GeomShapePtr aResult = unwrapCompound(aFilletBuilder->shape());
     std::shared_ptr<ModelAPI_ResultBody> aResultBody =
@@ -172,27 +177,6 @@ void FeaturesPlugin_Fillet::execute()
   removeResults(aResultIndex);
 }
 
-bool FeaturesPlugin_Fillet::isFailed(
-    const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
-{
-  if (!theAlgorithm->isDone()) {
-    static const std::string aFeatureError = "Error: fillet algorithm failed.";
-    setError(aFeatureError);
-    return true;
-  }
-  if (theAlgorithm->shape()->isNull()) {
-    static const std::string aShapeError = "Error: Resulting shape of fillet is Null.";
-    setError(aShapeError);
-    return true;
-  }
-  if (!theAlgorithm->isValid()) {
-    std::string aFeatureError = "Error: Resulting shape of fillet is not valid.";
-    setError(aFeatureError);
-    return true;
-  }
-  return false;
-}
-
 void FeaturesPlugin_Fillet::loadNamingDS(
     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
     const std::shared_ptr<GeomAPI_Shape> theBaseShape,
index c91956ae0058746b3ec88edd5a7d021930852c52..15472e2179684a0b717f7112252aab367ef0c051 100644 (file)
@@ -106,9 +106,6 @@ public:
   FeaturesPlugin_Fillet();
 
 private:
-  /// Check algorithm is finished correctly and store error otherwise
-  bool isFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
-
   /// Load Naming data structure of the feature to the document
   void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     const std::shared_ptr<GeomAPI_Shape> theBaseShape,
index d9973525da8cf60ea7335fa4682c27474fb2b460..22e2d8383df9f6321bba22e74ec9e43ac1f0ebdd 100644 (file)
@@ -30,6 +30,7 @@
 #include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_ShapeExplorer.h>
 
+#include <GeomAlgoAPI_Tools.h>
 #include <GeomAlgoAPI_UnifySameDomain.h>
 
 
@@ -60,16 +61,9 @@ void FeaturesPlugin_FusionFaces::execute()
   std::shared_ptr<GeomAlgoAPI_UnifySameDomain> anAlgo(new GeomAlgoAPI_UnifySameDomain(aBaseShape));
 
   // Check algo status
-  if (!anAlgo->isDone()) {
-    setError("Error: Fusion algorithm failed.");
-    return;
-  }
-  if (anAlgo->shape()->isNull()) {
-    setError("Error: Resulting shape is Null.");
-    return;
-  }
-  if (!anAlgo->isValid()) {
-    setError("Error: Resulting shape is not valid.");
+  std::string anError;
+  if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anAlgo, getKind(), anError)) {
+    setError(anError);
     return;
   }
 
index 6c8f51aff1447a0b9cd8e116e34777968892822a..93a02c79fe6399e022263c595acfd5ce5a4f37be 100644 (file)
@@ -27,6 +27,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 
 #include <GeomAlgoAPI_Intersection.h>
+#include <GeomAlgoAPI_Tools.h>
 #include <GeomAPI_ShapeExplorer.h>
 
 #include <sstream>
@@ -71,19 +72,9 @@ void FeaturesPlugin_Intersection::execute()
   GeomMakeShapePtr anIntersectionAlgo(new GeomAlgoAPI_Intersection(anObjects));
 
   // Checking that the algorithm worked properly.
-  if (!anIntersectionAlgo->isDone()) {
-    static const std::string aFeatureError = "Error: Intersection algorithm failed.";
-    setError(aFeatureError);
-    return;
-  }
-  if (anIntersectionAlgo->shape()->isNull()) {
-    static const std::string aShapeError = "Error: Resulting shape is Null.";
-    setError(aShapeError);
-    return;
-  }
-  if (!anIntersectionAlgo->isValid()) {
-    std::string aFeatureError = "Error: Resulting shape is not valid.";
-    setError(aFeatureError);
+  std::string anError;
+  if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anIntersectionAlgo, getKind(), anError)) {
+    setError(anError);
     return;
   }
 
index 9391b36e0f5ea0b58a0f2fbd584f8a32d4a42fe4..622ea8de835414dcee174464885e4e51a0fb83ea 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
 #include <GeomAlgoAPI_Translation.h>
 
 #include <GeomAPI_ShapeExplorer.h>
@@ -172,6 +173,7 @@ void FeaturesPlugin_MultiRotation::performRotation1D()
         aResultIndex++;
       }
     } else {
+      std::string anError;
       ListOfShape aListOfShape;
       std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > aListOfRotationAlgo;
 
@@ -187,19 +189,8 @@ void FeaturesPlugin_MultiRotation::performRotation1D()
         aRotationnAlgo->build();
 
         // Checking that the algorithm worked properly.
-        if (!aRotationnAlgo->isDone()) {
-          static const std::string aFeatureError = "Error : Multitranslation algorithm failed.";
-          setError(aFeatureError);
-          break;
-        }
-        if (aRotationnAlgo->shape()->isNull()) {
-          static const std::string aShapeError = "Error : Resulting shape is null.";
-          setError(aShapeError);
-          break;
-        }
-        if (!aRotationnAlgo->isValid()) {
-          static const std::string aFeatureError = "Error : Resulting shape in not valid.";
-          setError(aFeatureError);
+        if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationnAlgo, getKind(), anError)) {
+          setError(anError);
           break;
         }
         aListOfShape.push_back(aRotationnAlgo->shape());
index ffe7c5b25ab7d3cb87b6cbf04ce78ee7a6cd386b..4657f8e0a450380c02fc147fbeaeacf9c50e08d4 100644 (file)
@@ -21,6 +21,7 @@
 #include <FeaturesPlugin_MultiTranslation.h>
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Ax1.h>
 #include <GeomAPI_Edge.h>
@@ -173,6 +174,7 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
         aResultIndex++;
       }
     } else {
+      std::string anError;
       ListOfShape aListOfShape;
       std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
 
@@ -188,19 +190,8 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
         aTranslationAlgo->build();
 
         // Checking that the algorithm worked properly.
-        if (!aTranslationAlgo->isDone()) {
-          static const std::string aFeatureError = "Error : Multitranslation algorithm failed.";
-          setError(aFeatureError);
-          break;
-        }
-        if (aTranslationAlgo->shape()->isNull()) {
-          static const std::string aShapeError = "Error : Resulting shape is null.";
-          setError(aShapeError);
-          break;
-        }
-        if (!aTranslationAlgo->isValid()) {
-          static const std::string aFeatureError = "Error : Resulting shape in not valid.";
-          setError(aFeatureError);
+        if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+          setError(anError);
           break;
         }
         aListOfShape.push_back(aTranslationAlgo->shape());
@@ -380,6 +371,7 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
         }
       }
     } else {
+      std::string anError;
       ListOfShape aListOfShape;
       std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
 
@@ -399,21 +391,10 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
           aTranslationAlgo->build();
 
           // Checking that the algorithm worked properly.
-          if (!aTranslationAlgo->isDone()) {
-            static const std::string aFeatureError = "Error : Multitranslation algorithm failed.";
-            setError(aFeatureError);
+          if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+            setError(anError);
             break;
           }
-          if (aTranslationAlgo->shape()->isNull()) {
-            static const std::string aShapeError = "Error : Resulting shape is null.";
-            setError(aShapeError);
-            break;
-          }
-          if (!aTranslationAlgo->isValid()) {
-            static const std::string aFeatureError = "Error : Resulting shape in not valid.";
-            setError(aFeatureError);
-           break;
-          }
           aListOfShape.push_back(aTranslationAlgo->shape());
           aListOfTranslationAlgo.push_back(aTranslationAlgo);
         }
index ca91f21b63008e36e0cb6c115c9b09cd225a6b60..43ae4130c0fa13b171c932b375b2cab4a6ec431b 100755 (executable)
@@ -38,6 +38,7 @@
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_Partition.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Face.h>
 #include <GeomAPI_ShapeExplorer.h>
@@ -66,9 +67,6 @@ static bool cutUnusedSubs(CompsolidSubs& theObjects, CompsolidSubs& theNotUsed,
                           std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
                           std::string& theError);
 
-static bool isAlgoFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
-                         std::string& theError);
-
 
 //=================================================================================================
 FeaturesPlugin_Partition::FeaturesPlugin_Partition()
@@ -125,7 +123,7 @@ void FeaturesPlugin_Partition::execute()
     new GeomAlgoAPI_Partition(aTargetObjects, aPlanes));
 
   // Checking that the algorithm worked properly.
-  if (isAlgoFailed(aPartitionAlgo, aError)) {
+  if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPartitionAlgo, getKind(), aError)) {
     setError(aError);
     return;
   }
@@ -143,7 +141,7 @@ void FeaturesPlugin_Partition::execute()
     aPartitionAlgo.reset(new GeomAlgoAPI_Partition(aTargetObjects, ListOfShape()));
 
     // Checking that the algorithm worked properly.
-    if (isAlgoFailed(aPartitionAlgo, aError)) {
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPartitionAlgo, getKind(), aError)) {
       setError(aError);
       return;
     }
@@ -376,7 +374,7 @@ static bool cutSubs(const GeomShapePtr& theFirstArgument,
     // cut from current list of solids
     aCutAlgo.reset(
         new GeomAlgoAPI_Boolean(aUIt->second, theTools, GeomAlgoAPI_Boolean::BOOL_CUT));
-    if (isAlgoFailed(aCutAlgo, theError))
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, "", theError))
       return false;
     theMakeShapeList->appendAlgo(aCutAlgo);
 
@@ -411,22 +409,3 @@ bool cutUnusedSubs(CompsolidSubs& theObjects, CompsolidSubs& theNotUsed,
   return cutSubs(aFirstArgument, theObjects, aToolsForUsed, theMakeShapeList, theError)
       && cutSubs(aFirstArgument, theNotUsed, aToolsForUnused, theMakeShapeList, theError);
 }
-
-bool isAlgoFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo, std::string& theError)
-{
-  if (!theAlgo->isDone()) {
-    theError = "Error: Partition algorithm failed.";
-    return true;
-  }
-  if (theAlgo->shape()->isNull()) {
-    theError = "Error: Resulting shape is Null.";
-    return true;
-  }
-  if (!theAlgo->isValid()) {
-    theError = "Error: Resulting shape is not valid.";
-    return true;
-  }
-
-  theError.clear();
-  return false;
-}
index 425ac1f49b315a5c9664f81c9debb5ce4a1aacc1..b81823597a4224558ff4409e4d5e505b32b6f3ba 100644 (file)
@@ -30,6 +30,8 @@
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_Pipe.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_Tools.h>
+
 #include <GeomAPI_PlanarEdges.h>
 #include <GeomAPI_ShapeExplorer.h>
 
@@ -222,6 +224,7 @@ void FeaturesPlugin_Pipe::execute()
 
   // Generating result for each object.
   int aResultIndex = 0;
+  std::string anError;
   if(aCreationMethod == CREATION_METHOD_SIMPLE() ||
       aCreationMethod == CREATION_METHOD_BINORMAL()) {
     for(ListOfShape::const_iterator
@@ -235,20 +238,8 @@ void FeaturesPlugin_Pipe::execute()
                                                                            aPathShape,
                                                                            aBiNormal));
 
-      if(!aPipeAlgo->isDone()) {
-        setError("Error: Pipe algorithm failed.");
-        aResultIndex = 0;
-        break;
-      }
-
-      // Check if shape is valid
-      if(!aPipeAlgo->shape().get() || aPipeAlgo->shape()->isNull()) {
-        setError("Error: Resulting shape is Null.");
-        aResultIndex = 0;
-        break;
-      }
-      if(!aPipeAlgo->isValid()) {
-        setError("Error: Resulting shape is not valid.");
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPipeAlgo, getKind(), anError)) {
+        setError(anError);
         aResultIndex = 0;
         break;
       }
@@ -260,20 +251,8 @@ void FeaturesPlugin_Pipe::execute()
                                                                      aLocations,
                                                                      aPathShape));
 
-    if(!aPipeAlgo->isDone()) {
-      setError("Error: Pipe algorithm failed.");
-      removeResults(0);
-      return;
-    }
-
-    // Check if shape is valid
-    if(!aPipeAlgo->shape().get() || aPipeAlgo->shape()->isNull()) {
-      setError("Error: Resulting shape is Null.");
-      removeResults(0);
-      return;
-    }
-    if(!aPipeAlgo->isValid()) {
-      setError("Error: Resulting shape is not valid.");
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPipeAlgo, getKind(), anError)) {
+      setError(anError);
       removeResults(0);
       return;
     }
index de1e0a219cee53d84ae12a05384749375714b9cb..b4ae07c3dfaced96bf43be420a91111e024ae5ff 100644 (file)
@@ -34,6 +34,7 @@
 #include <GeomAPI_ShapeIterator.h>
 #include <GeomAlgoAPI_Placement.h>
 #include <GeomAlgoAPI_Transform.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <FeaturesPlugin_Tools.h>
 
@@ -142,6 +143,7 @@ void FeaturesPlugin_Placement::execute()
 
   // Applying transformation to each object.
   int aResultIndex = 0;
+  std::string anError;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
       anObjectsIt++, aContext++) {
@@ -158,19 +160,8 @@ void FeaturesPlugin_Placement::execute()
                                                                                       aTrsf));
 
       // Checking that the algorithm worked properly.
-      if(!aTransformAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Transform algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aTransformAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aTransformAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTransformAlgo, getKind(), anError)) {
+        setError(anError);
         break;
       }
 
index f4c92fee81c3064b529fde87fb8516f52cdb8dbd..0bf95c30101e7c1f39b3b5396c1cd6460522b8ab 100644 (file)
@@ -31,6 +31,7 @@
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_Tools.h>
 #include <GeomAlgoAPI_Copy.h>
+#include <GeomAlgoAPI_Tools.h>
 
 FeaturesPlugin_Recover::FeaturesPlugin_Recover()
 {
@@ -45,6 +46,7 @@ void FeaturesPlugin_Recover::initAttributes()
 
 void FeaturesPlugin_Recover::execute()
 {
+  std::string anError;
   int aResultIndex = 0;
   AttributeRefListPtr aRecovered = reflist(RECOVERED_ENTITIES());
   for(int anIndex = aRecovered->size() - 1; anIndex >= 0; anIndex--) {
@@ -61,18 +63,8 @@ void FeaturesPlugin_Recover::execute()
     // Copy shape.
     std::shared_ptr<GeomAlgoAPI_Copy> aCopyAlgo(new GeomAlgoAPI_Copy(aShape));
     // Check that algo is done.
-    if(!aCopyAlgo->isDone()) {
-      setError("Error: recover algorithm failed.");
-      return;
-    }
-    // Check if shape is not null.
-    if(!aCopyAlgo->shape().get() || aCopyAlgo->shape()->isNull()) {
-      setError("Error: resulting shape is null.");
-      return;
-    }
-    // Check that resulting shape is valid.
-    if(!aCopyAlgo->isValid()) {
-      setError("Error: resulting shape is not valid.");
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
index 2f941d59e0034d74a4ced88dd54766a755faadac..bbd7b41f30071a2b91a4e1c23fb83589d5c4494b 100644 (file)
@@ -27,6 +27,7 @@
 #include <ModelAPI_Validator.h>
 
 #include <GeomAlgoAPI_Revolution.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
@@ -177,6 +178,7 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes,
   }
 
   // Generating result for each base shape.
+  std::string anError;
   for(ListOfShape::const_iterator
       anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) {
     GeomShapePtr aBaseShape = *anIter;
@@ -185,7 +187,8 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes,
                                                        aBaseShape, anAxis,
                                                        aToShape, aToAngle,
                                                        aFromShape, aFromAngle));
-    if(!isMakeShapeValid(aRevolAlgo)) {
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRevolAlgo, getKind(), anError)) {
+      setError(anError);
       return false;
     }
 
index 7305870f46bd44115d6c50f5f46ae31587a84769..01547d62f91c041c62b0414019ec2f1c46b9dc73 100755 (executable)
@@ -27,6 +27,7 @@
 #include <ModelAPI_ResultPart.h>
 
 #include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
@@ -137,6 +138,7 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle()
   double anAngle = real(FeaturesPlugin_Rotation::ANGLE_ID())->value();
 
   // Rotating each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -165,19 +167,8 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle()
       aRotationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aRotationAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Rotation algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aRotationAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aRotationAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) {
+        setError(anError);
         break;
       }
 
@@ -245,6 +236,7 @@ void FeaturesPlugin_Rotation::performTranslationByThreePoints()
   }
 
   // Rotating each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -274,19 +266,8 @@ void FeaturesPlugin_Rotation::performTranslationByThreePoints()
       aRotationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aRotationAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Rotation algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aRotationAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error : Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aRotationAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) {
+        setError(anError);
         break;
       }
 
index bc1ef0189fae7416a0b7da65a4261cbc57190f87..a2c6105c8bce9258524498c03f1714a582f61f9f 100644 (file)
@@ -21,6 +21,7 @@
 #include <FeaturesPlugin_Scale.h>
 
 #include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
@@ -114,6 +115,7 @@ void FeaturesPlugin_Scale::performScaleByFactor()
   double aScaleFactor = real(FeaturesPlugin_Scale::SCALE_FACTOR_ID())->value();
 
   // Moving each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -130,19 +132,8 @@ void FeaturesPlugin_Scale::performScaleByFactor()
     aScaleAlgo->build();
 
     // Checking that the algorithm worked properly.
-    if(!aScaleAlgo->isDone()) {
-      static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
-      setError(aFeatureError);
-      break;
-    }
-    if(aScaleAlgo->shape()->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      break;
-    }
-    if(!aScaleAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aScaleAlgo, getKind(), anError)) {
+      setError(anError);
       break;
     }
 
@@ -199,6 +190,7 @@ void FeaturesPlugin_Scale::performScaleByDimensions()
   double aScaleFactorZ = real(FeaturesPlugin_Scale::SCALE_FACTOR_Z_ID())->value();
 
   // Moving each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -218,19 +210,8 @@ void FeaturesPlugin_Scale::performScaleByDimensions()
     aScaleAlgo->build();
 
     // Checking that the algorithm worked properly.
-    if(!aScaleAlgo->isDone()) {
-      static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
-      setError(aFeatureError);
-      break;
-    }
-    if(aScaleAlgo->shape()->isNull()) {
-      static const std::string aShapeError = "Error: Resulting shape is Null.";
-      setError(aShapeError);
-      break;
-    }
-    if(!aScaleAlgo->isValid()) {
-      std::string aFeatureError = "Error: Resulting shape is not valid.";
-      setError(aFeatureError);
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aScaleAlgo, getKind(), anError)) {
+      setError(anError);
       break;
     }
 
index 93707eeb088c68f9c4e1bad04537aec6afd77921..333820a8d32146e6a5f42d9073efb70a68ccab55 100644 (file)
@@ -25,6 +25,7 @@
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomAlgoAPI_Copy.h>
 #include <GeomAlgoAPI_MakeShapeList.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Face.h>
@@ -134,6 +135,7 @@ void FeaturesPlugin_Symmetry::performSymmetryByPoint()
   }
 
   // Moving each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -160,19 +162,8 @@ void FeaturesPlugin_Symmetry::performSymmetryByPoint()
       aSymmetryAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aSymmetryAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aSymmetryAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aSymmetryAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSymmetryAlgo, getKind(), anError)) {
+        setError(anError);
         break;
       }
 
@@ -230,6 +221,7 @@ void FeaturesPlugin_Symmetry::performSymmetryByAxis()
 
 
   // Moving each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -256,19 +248,8 @@ void FeaturesPlugin_Symmetry::performSymmetryByAxis()
       aSymmetryAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aSymmetryAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aSymmetryAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aSymmetryAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSymmetryAlgo, getKind(), anError)) {
+        setError(anError);
         break;
       }
 
@@ -326,6 +307,7 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane()
 
 
   // Moving each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -351,19 +333,8 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane()
       aSymmetryAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aSymmetryAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aSymmetryAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aSymmetryAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSymmetryAlgo, getKind(), anError)) {
+        setError(anError);
         break;
       }
 
index 14de51957495cab9d5ece56bf93838060611d125..e303f2b125c2def5ee388fcf618885bc56292b9d 100644 (file)
@@ -34,6 +34,7 @@
 #include <GeomAPI_Trsf.h>
 
 #include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <FeaturesPlugin_Tools.h>
 
@@ -150,6 +151,7 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance()
   double aDistance = real(FeaturesPlugin_Translation::DISTANCE_ID())->value();
 
   // Moving each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -177,19 +179,8 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance()
       aTranslationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aTranslationAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Translation algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aTranslationAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aTranslationAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+        setError(anError);
         break;
       }
 
@@ -236,6 +227,7 @@ void FeaturesPlugin_Translation::performTranslationByDimensions()
   double aDZ = real(FeaturesPlugin_Translation::DZ_ID())->value();
 
   // Moving each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -263,19 +255,8 @@ void FeaturesPlugin_Translation::performTranslationByDimensions()
       aTranslationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aTranslationAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Translation algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aTranslationAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aTranslationAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+        setError(anError);
         break;
       }
 
@@ -335,6 +316,7 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints()
   }
 
   // Moving each object.
+  std::string anError;
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
@@ -362,19 +344,8 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints()
       aTranslationAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aTranslationAlgo->isDone()) {
-        static const std::string aFeatureError = "Error: Translation algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aTranslationAlgo->shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aTranslationAlgo->isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
+      if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) {
+        setError(anError);
         break;
       }
 
index e9cbaee7de9a13a1aaa3a2d56001da00a5becfaf..fe7122c4a705b398d3e1ed55d071f7d572a230d7 100644 (file)
@@ -23,6 +23,7 @@
 #include <GeomAlgoAPI_Boolean.h>
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_PaveFiller.h>
+#include <GeomAlgoAPI_Tools.h>
 #include <GeomAlgoAPI_UnifySameDomain.h>
 
 #include <GeomAPI_ShapeExplorer.h>
@@ -109,6 +110,7 @@ void FeaturesPlugin_Union::execute()
   }
 
   // Fuse objects.
+  std::string anError;
   std::shared_ptr<GeomAlgoAPI_MakeShape> anAlgo;
   ListOfShape aTools;
   if (anObjects.front()->shapeType() == GeomAPI_Shape::SOLID) {
@@ -123,16 +125,8 @@ void FeaturesPlugin_Union::execute()
   // Checking that the algorithm worked properly.
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
   GeomAPI_DataMapOfShapeShape aMapOfShapes;
-  if(!anAlgo->isDone()) {
-    setError("Error: Boolean algorithm failed.");
-    return;
-  }
-  if(anAlgo->shape()->isNull()) {
-    setError("Error: Resulting shape is Null.");
-    return;
-  }
-  if(!anAlgo->isValid()) {
-    setError("Error: Resulting shape is not valid.");
+  if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anAlgo, getKind(), anError)) {
+    setError(anError);
     return;
   }
 
@@ -149,16 +143,8 @@ void FeaturesPlugin_Union::execute()
     aShapesToAdd.push_back(aShape);
     std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
       new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
-    if(!aFillerAlgo->isDone()) {
-      setError("Error: PaveFiller algorithm failed.");
-      return;
-    }
-    if(aFillerAlgo->shape()->isNull()) {
-      setError("Error: Resulting shape is Null.");
-      return;
-    }
-    if(!aFillerAlgo->isValid()) {
-      setError("Error: Resulting shape is not valid.");
+    if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) {
+      setError(anError);
       return;
     }
 
index 5a893f50b218d813a3530f39685d26f19ce924ed..e642cc59f65fe7385ee73c179bcea2dad2e032bb 100644 (file)
@@ -19,6 +19,7 @@
 //
 
 #include "GeomAlgoAPI_Tools.h"
+#include "GeomAlgoAPI_MakeShape.h"
 
 #include <clocale>
 
@@ -58,3 +59,32 @@ std::string File_Tools::name(const std::string& theFileName)
   OSD_Path aPath(aFileName);
   return aPath.Name().ToCString();
 }
+
+bool AlgoError::isAlgorithmFailed(const GeomMakeShapePtr& theAlgorithm,
+                                  const std::string& theFeature,
+                                  std::string& theError)
+{
+  theError.clear();
+  if (!theAlgorithm->isDone()) {
+    theError = "Error: " + (theFeature.empty() ? "The" : theFeature) + " algorithm failed.";
+    std::string anAlgoError = theAlgorithm->getError();
+    if (!anAlgoError.empty())
+      theError += " " + anAlgoError;
+    return true;
+  }
+  if (!theAlgorithm->shape() || theAlgorithm->shape()->isNull()) {
+    theError = "Error: Resulting shape";
+    if (!theFeature.empty())
+      theError += "of " + theFeature;
+    theError += " is Null.";
+    return true;
+  }
+  if (!theAlgorithm->isValid()) {
+    theError = "Error: Resulting shape";
+    if (!theFeature.empty())
+      theError += "of " + theFeature;
+    theError += " is not valid.";
+    return true;
+  }
+  return false;
+}
index f17efdc3b735b1040812bb1872adab95d602ebb2..bb0c28f2b3faf961a3b6ab1a97826f7a46b9e385 100644 (file)
 
 #include <GeomAlgoAPI.h>
 
+#include <memory>
 #include <string>
 
+class GeomAlgoAPI_MakeShape;
+
 namespace GeomAlgoAPI_Tools {
 
 /** \class Localizer
@@ -56,6 +59,24 @@ public:
   GEOMALGOAPI_EXPORT static std::string name(const std::string& theFileName);
 };
 
+/** \class AlgoError
+ *  \ingroup DataAlgo
+ *  \brief Verify error in MakeShape algorithm.
+ */
+class AlgoError {
+public:
+  /** \brief Verify MakeShape algorithm for failures
+   *  \param[in]  theAlgorithm object to verify the failure
+   *  \param[in]  theFeature   kind of the feature, the algorithm belongs to
+   *  \param[out] theError     error string (empty if the feature succeed)
+   *  \return \c true if succeed
+   */
+  GEOMALGOAPI_EXPORT static bool isAlgorithmFailed(
+      const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm,
+      const std::string& theFeature,
+      std::string& theError);
+};
+
 } // GeomAlgoAPI_Tools
 
 #endif /* GEOMALGOAPI_TOOLS_H_ */