Salome HOME
Small refactoring: separate storing a compound of sub-results.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Boolean.cpp
index e39c1f99fbbc6a3ed2ec8785a64ee1479861c30a..066bf02af3c038979b3b535fa332e8c266f9da08 100644 (file)
@@ -488,6 +488,42 @@ GeomShapePtr FeaturesPlugin_Boolean::keepUnusedSubsOfCompound(
   return aResultShape;
 }
 
+//=================================================================================================
+void FeaturesPlugin_Boolean::storeResult(
+    const ListOfShape& theObjects,
+    const ListOfShape& theTools,
+    const GeomShapePtr theResultShape,
+    int& theResultIndex,
+    std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList,
+    std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList)
+{
+  if (!theResultShape)
+    return;
+
+  std::shared_ptr<ModelAPI_ResultBody> aResultBody =
+      document()->createBody(data(), theResultIndex);
+
+  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+                                           theObjects,
+                                           theTools,
+                                           theMakeShapeList,
+                                           theResultShape);
+  setResult(aResultBody, theResultIndex++);
+
+  // merge algorithms
+  FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+  aRBA.resultBody = aResultBody;
+  aRBA.baseShape = theObjects.front();
+  for (std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>::iterator
+       aRBAIt = theResultBaseAlgoList.begin();
+       aRBAIt != theResultBaseAlgoList.end(); ++aRBAIt) {
+    theMakeShapeList->appendAlgo(aRBAIt->makeShape);
+  }
+  aRBA.makeShape = theMakeShapeList;
+  theResultBaseAlgoList.clear();
+  theResultBaseAlgoList.push_back(aRBA);
+}
+
 //=================================================================================================
 int FeaturesPlugin_Boolean::version()
 {
@@ -575,16 +611,14 @@ void FeaturesPlugin_Boolean::ObjectHierarchy::SplitCompound(const GeomShapePtr&
   if (aFoundIndex == myParentIndices.end())
     return; // no such shape
 
-  const ListOfShape& aSubs = mySubshapes[aFoundIndex->second].second;
+  theUsed = mySubshapes[aFoundIndex->second].second;
   SetOfShape aSubsSet;
-  aSubsSet.insert(aSubs.begin(), aSubs.end());
+  aSubsSet.insert(theUsed.begin(), theUsed.end());
 
   for (GeomAPI_ShapeIterator anExp(theCompShape); anExp.more(); anExp.next()) {
     GeomShapePtr aCurrent = anExp.current();
     if (aSubsSet.find(aCurrent) == aSubsSet.end())
       theNotUsed.push_back(aCurrent);
-    else
-      theUsed.push_back(aCurrent);
   }
 }