Salome HOME
Merge branch 'master' into V9_3_BR
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Extrusion.cpp
index ceb01e79336a84f291aa644980e52435afb6d828..3ff47274e205bde1c282998eb26c699a0910af94 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  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 "FeaturesPlugin_Extrusion.h"
@@ -27,6 +26,7 @@
 #include <ModelAPI_Validator.h>
 
 #include <GeomAlgoAPI_Prism.h>
+#include <GeomAlgoAPI_Tools.h>
 
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Edge.h>
@@ -148,7 +148,7 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
       if(!aToShape.get() && aSelection->context().get()) {
         aToShape = aSelection->context()->shape();
       }
-      if (aToShape->isCompound()) {
+      if (aToShape.get() && aToShape->isCompound()) {
         GeomAPI_ShapeIterator anIt(aToShape);
         aToShape = anIt.current();
       }
@@ -159,7 +159,7 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
       if(!aFromShape.get() && aSelection->context().get()) {
         aFromShape = aSelection->context()->shape();
       }
-      if (aFromShape->isCompound()) {
+      if (aFromShape.get() && aFromShape->isCompound()) {
         GeomAPI_ShapeIterator anIt(aFromShape);
         aFromShape = anIt.current();
       }
@@ -167,6 +167,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 +175,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;
     }