Salome HOME
Task 2.5. Combination operations on Groups (issue #2935)
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Intersection.cpp
index e2a48a02676b06e3ed06a3137030132a59c7c66b..1fa9079247f632a9cf86732de0a28b271bfada7e 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_Intersection.h"
@@ -27,6 +26,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 
 #include <GeomAlgoAPI_Intersection.h>
+#include <GeomAlgoAPI_Tools.h>
 #include <GeomAPI_ShapeExplorer.h>
 
 #include <sstream>
@@ -71,19 +71,9 @@ void FeaturesPlugin_Intersection::execute()
   GeomMakeShapePtr anIntersectionAlgo(new GeomAlgoAPI_Intersection(anObjects));
 
   // Checking that the algorithm worked properly.
-  if (!anIntersectionAlgo->isDone()) {
-    static const std::string aFeatureError = "Error: Intersection algorithm failed.";
-    setError(aFeatureError);
-    return;
-  }
-  if (anIntersectionAlgo->shape()->isNull()) {
-    static const std::string aShapeError = "Error: Resulting shape is Null.";
-    setError(aShapeError);
-    return;
-  }
-  if (!anIntersectionAlgo->isValid()) {
-    std::string aFeatureError = "Error: Resulting shape is not valid.";
-    setError(aFeatureError);
+  std::string anError;
+  if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anIntersectionAlgo, getKind(), anError)) {
+    setError(anError);
     return;
   }
 
@@ -92,7 +82,6 @@ void FeaturesPlugin_Intersection::execute()
   setResult(aResultBody, aResultIndex);
   aResultIndex++;
 
-
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
 }
@@ -103,7 +92,13 @@ void FeaturesPlugin_Intersection::loadNamingDS(ResultBodyPtr theResultBody,
                                                const GeomMakeShapePtr& theMakeShape)
 {
   std::shared_ptr<GeomAPI_Shape> aResultShape = theMakeShape->shape();
-  theResultBody->storeModified(theObjects.front(), aResultShape);
+
+  if(theObjects.front()->isEqual(aResultShape)) {
+    theResultBody->store(aResultShape, false);
+    return;
+  }
+
+  theResultBody->storeModified(theObjects, aResultShape, theMakeShape);
 
   const int aShapeTypesNb = 3;
   const GeomAPI_Shape::ShapeType aShapeTypes[aShapeTypesNb] = {GeomAPI_Shape::VERTEX,