Salome HOME
Update copyrights
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_FusionFaces.cpp
index b3cc312c52097f8113056fb743f35972132a157e..c7a9f62c2c31fd519ecfbab4ac141b9280d260ee 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_FusionFaces.h"
@@ -30,6 +29,7 @@
 #include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_ShapeExplorer.h>
 
+#include <GeomAlgoAPI_Tools.h>
 #include <GeomAlgoAPI_UnifySameDomain.h>
 
 
@@ -60,16 +60,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;
   }
 
@@ -81,15 +74,8 @@ void FeaturesPlugin_FusionFaces::execute()
   } else {
     aResultBody->storeModified(aBaseShape, aResultShape);
 
-    const int aModifyEdgeTag = 1;
-    const int aModifyFaceTag = 2;
-    const std::string aModEName = "Modified_Edge";
-    const std::string aModFName = "Modified_Face";
-    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = anAlgo->mapOfSubShapes();
-    aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::EDGE,
-      aModifyEdgeTag, aModEName, *aMapOfShapes.get(), true);
-    aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::FACE,
-      aModifyFaceTag, aModFName, *aMapOfShapes.get(), true);
+    aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::EDGE);
+    aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::FACE);
   }
   setResult(aResultBody);
 }