Salome HOME
[PythonAPI] Fix error in parameter wrapper
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Partition.cpp
index 44ab7cc84a963cefda27dc903aa8b82d05137dce..2a584910c218521ee7350e879b2a02d8122ec9ca 100755 (executable)
@@ -22,6 +22,8 @@
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
+#include <sstream>
+
 //=================================================================================================
 FeaturesPlugin_Partition::FeaturesPlugin_Partition()
 {
@@ -76,6 +78,7 @@ void FeaturesPlugin_Partition::execute()
   }
 
   GeomAlgoAPI_MakeShapeList aMakeShapeList;
+  std::list<std::shared_ptr<GeomAPI_Pnt> > aBoundingPoints = GeomAlgoAPI_ShapeTools::getBoundingBox(anObjects, 1.0);
 
   // Getting tools.
   AttributeSelectionListPtr aToolsSelList = selectionList(FeaturesPlugin_Partition::TOOL_LIST_ID());
@@ -86,7 +89,7 @@ void FeaturesPlugin_Partition::execute()
       // it could be a construction plane
       ResultPtr aContext = aToolAttr->context();
       if(aContext.get()) {
-        aTool = GeomAlgoAPI_ShapeTools::faceToInfinitePlane(aContext->shape());
+        aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aContext->shape(), aBoundingPoints);
         std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(new GeomAlgoAPI_MakeShapeCustom);
         aMkShCustom->addModified(aContext->shape(), aTool);
         aMakeShapeList.append(aMkShCustom);
@@ -190,21 +193,28 @@ void FeaturesPlugin_Partition::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody>
   if(theBaseShape->isEqual(theResultShape)) {
     theResultBody->store(theResultShape);
   } else {
-    const int aModifyTag = 1;
-    const int aDeletedTag = 2;
-    const int aSubsolidsTag = 3; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
+    const int aDeletedTag = 1;
+    const int aSubsolidsTag = 2; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
+    const int aModifyTag = 100000;
+    int aModifyToolsTag = 200000;
+    std::ostringstream aStream;
 
     theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
 
     std::string aModName = "Modified";
     theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
-                                               aModifyTag, aModName, theMapOfShapes);
+                                               aModifyTag, aModName, theMapOfShapes, true);
     theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aDeletedTag);
 
+    int anIndex = 1;
     for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
+      aStream.str(std::string());
+      aStream.clear();
+      aStream << aModName << "_" << anIndex++;
       theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
-                                                 aModifyTag, aModName, theMapOfShapes);
+                                                 aModifyToolsTag, aStream.str(), theMapOfShapes, true);
       theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
+      aModifyToolsTag += 10000;
     }
   }
 }