]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp
Salome HOME
[Code coverage]: Move checking the algorithm's result into separate function
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_BooleanSmash.cpp
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;
     }