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