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